From ea1a0299f31fc490e983836e6efb8ca7282b9dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20V=C3=B6r=C3=B6=C5=A1?= Date: Fri, 27 Jan 2023 20:00:05 +0100 Subject: [PATCH] Add switch for vertical centering on/off at compile-time. --- server/TracyView_Timeline.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/TracyView_Timeline.cpp b/server/TracyView_Timeline.cpp index 0b88fdd0..18241db6 100644 --- a/server/TracyView_Timeline.cpp +++ b/server/TracyView_Timeline.cpp @@ -324,9 +324,16 @@ void View::DrawTimeline() ImGui::SetNextWindowContentSize( ImVec2( 0, m_tc.GetHeight() ) ); ImGui::BeginChild( "##zoneWin", ImVec2( ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y ), false, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_NoScrollWithMouse ); + const auto verticallyCenterTimeline = true; + if( m_yDelta != 0 ) { auto& io = ImGui::GetIO(); + if( !verticallyCenterTimeline ) + { + auto y = ImGui::GetScrollY(); + ImGui::SetScrollY( y - m_yDelta ); + } io.MouseClickedPos[1].y = io.MousePos.y; } @@ -378,7 +385,8 @@ void View::DrawTimeline() } } - m_tc.End( pxns, wpos, hover, drawMouseLine && m_viewMode == ViewMode::Paused, yMin, yMax ); + const auto vcenter = verticallyCenterTimeline && drawMouseLine && m_viewMode == ViewMode::Paused; + m_tc.End( pxns, wpos, hover, vcenter, yMin, yMax ); ImGui::EndChild(); m_lockHighlight = m_nextLockHighlight;