From 2f645c589dc457107968394379fa55987b83b550 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 21 Sep 2017 01:39:07 +0200 Subject: [PATCH] Zoom in/out in zone view. --- server/TracyView.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index d6a5769d..ca9be03f 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -645,8 +645,8 @@ void View::DrawZones() ImGui::InvisibleButton( "##zones", ImVec2( w, h ) ); bool hover = ImGui::IsItemHovered(); - const auto timespan = m_zvEnd - m_zvStart; - const auto pxns = w / double( timespan ); + auto timespan = m_zvEnd - m_zvStart; + auto pxns = w / double( timespan ); if( hover ) { @@ -659,6 +659,28 @@ void View::DrawZones() m_zvEnd -= delta * nspx; io.MouseClickedPos[1].x = io.MousePos.x; } + + const auto wheel = io.MouseWheel; + if( wheel != 0 ) + { + m_pause = true; + const double mouse = io.MousePos.x - wpos.x; + const auto p = mouse / w; + const auto p1 = timespan * p; + const auto p2 = timespan - p1; + if( wheel > 0 ) + { + m_zvStart += int64_t( p1 * 0.1f ); + m_zvEnd -= int64_t( p2 * 0.1f ); + } + else if( timespan < 1000ull * 1000 * 1000 * 60 ) + { + m_zvStart -= std::max( 1ll, int64_t( p1 * 0.1f ) ); + m_zvEnd += std::max( 1ll, int64_t( p2 * 0.1f ) ); + } + timespan = m_zvEnd - m_zvStart; + pxns = w / double( timespan ); + } } const auto zitbegin = std::lower_bound( m_frames.begin(), m_frames.end(), m_zvStart );