From 39eccd5b08c8ba105e9b62dd095fb70b9a7fafd4 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 22 Jun 2018 20:21:02 +0200 Subject: [PATCH] Extract "center view at time" function. --- server/TracyView.cpp | 9 +++++++-- server/TracyView.hpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 54003e9d..faec74e4 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -3375,8 +3375,7 @@ void View::DrawMessages() ImGui::PushID( v ); if( ImGui::Selectable( TimeToString( v->time - m_worker.GetFrameBegin( 0 ) ), m_msgHighlight == v, ImGuiSelectableFlags_SpanAllColumns ) ) { - const auto hr = std::max( 1, ( m_zvEnd - m_zvStart ) / 2 ); - ZoomToRange( v->time - hr, v->time + hr ); + CenterAtTime( v->time ); } ImGui::PopID(); ImGui::NextColumn(); @@ -5577,6 +5576,12 @@ void View::ZoomToNextFrame() ZoomToRange( fbegin, fend ); } +void View::CenterAtTime( int64_t t ) +{ + const auto hr = std::max( 1, ( m_zvEnd - m_zvStart ) / 2 ); + ZoomToRange( t - hr, t + hr ); +} + void View::ShowZoneInfo( const ZoneEvent& ev ) { if( m_zoneInfoWindow ) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 8b62a697..5e0de331 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -105,6 +105,7 @@ private: void ZoomToRange( int64_t start, int64_t end ); void ZoomToPrevFrame(); void ZoomToNextFrame(); + void CenterAtTime( int64_t t ); void ShowZoneInfo( const ZoneEvent& ev ); void ShowZoneInfo( const GpuEvent& ev, uint64_t thread );