From ba80b0c16a0df1edcd83be9b352e2a0fe37f049d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 27 Nov 2017 22:12:26 +0100 Subject: [PATCH] Use one common function for zooming to range. --- server/TracyView.cpp | 22 +++++++++++----------- server/TracyView.hpp | 2 ++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index b0da573b..1872651d 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -2050,8 +2050,7 @@ bool View::DrawZoneFrames() if( ImGui::IsMouseClicked( 2 ) ) { - m_zvStartNext = fbegin; - m_zvEndNext = fend; + ZoomToRange( fbegin, fend ); m_pause = true; } } @@ -2422,8 +2421,7 @@ int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, if( ImGui::IsMouseClicked( 2 ) && rend - ev.start > 0 ) { - m_zvStartNext = ev.start; - m_zvEndNext = rend; + ZoomToRange( ev.start, rend ); } } else @@ -2618,8 +2616,7 @@ int View::DrawGpuZoneLevel( const Vector& vec, bool hover, double pxn if( ImGui::IsMouseClicked( 2 ) && rend - ev.gpuStart > 0 ) { - m_zvStartNext = ev.gpuStart; - m_zvEndNext = rend; + ZoomToRange( ev.gpuStart, rend ); } } else @@ -3631,8 +3628,7 @@ void View::DrawMessages() { m_pause = true; const auto hr = std::max( 1, ( m_zvEnd - m_zvStart ) / 2 ); - m_zvStart = v->time - hr; - m_zvEnd = v->time + hr; + ZoomToRange( v->time - hr, v->time + hr ); } } ImGui::End(); @@ -3724,15 +3720,19 @@ void View::ZoomToZone( const ZoneEvent& ev ) { const auto end = GetZoneEnd( ev ); if( end - ev.start <= 0 ) return; - m_zvStartNext = ev.start; - m_zvEndNext = end; + ZoomToRange( ev.start, end ); } void View::ZoomToZone( const GpuEvent& ev ) { const auto end = GetZoneEnd( ev ); if( end - ev.gpuStart <= 0 ) return; - m_zvStartNext = ev.gpuStart; + ZoomToRange( ev.gpuStart, end ); +} + +void View::ZoomToRange( int64_t start, int64_t end ) +{ + m_zvStartNext = start; m_zvEndNext = end; } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index fbfda7db..cc4bd0da 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -154,6 +154,8 @@ private: void ZoomToZone( const ZoneEvent& ev ); void ZoomToZone( const GpuEvent& ev ); + void ZoomToRange( int64_t start, int64_t end ); + void ZoneTooltip( const ZoneEvent& ev ); void ZoneTooltip( const GpuEvent& ev ); const ZoneEvent* GetZoneParent( const ZoneEvent& zone ) const;