From 1b44b31effb73edb1c10dab0e9c4650ac98de147 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 5 Aug 2018 01:19:08 +0200 Subject: [PATCH] Prevent range-zoom when range has zero length. --- server/TracyView.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 8c7e1427..a0d33114 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -828,23 +828,30 @@ void View::HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, d } else if( m_highlightZoom.active ) { - const auto s = std::min( m_highlightZoom.start, m_highlightZoom.end ); - const auto e = std::max( m_highlightZoom.start, m_highlightZoom.end ); - - // ZoomToRange disables m_highlightZoom.active - if( io.KeyCtrl ) + if( m_highlightZoom.start != m_highlightZoom.end ) { - const auto tsOld = m_zvEnd - m_zvStart; - const auto tsNew = e - s; - const auto mul = double( tsOld ) / tsNew; - const auto left = s - m_zvStart; - const auto right = m_zvEnd - e; + const auto s = std::min( m_highlightZoom.start, m_highlightZoom.end ); + const auto e = std::max( m_highlightZoom.start, m_highlightZoom.end ); - ZoomToRange( m_zvStart - left * mul, m_zvEnd + right * mul ); + // ZoomToRange disables m_highlightZoom.active + if( io.KeyCtrl ) + { + const auto tsOld = m_zvEnd - m_zvStart; + const auto tsNew = e - s; + const auto mul = double( tsOld ) / tsNew; + const auto left = s - m_zvStart; + const auto right = m_zvEnd - e; + + ZoomToRange( m_zvStart - left * mul, m_zvEnd + right * mul ); + } + else + { + ZoomToRange( s, e ); + } } else { - ZoomToRange( s, e ); + m_highlightZoom.active = false; } }