From c2d527e2e71f798d54d579af144d38be0dbda42f Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 28 Aug 2022 13:17:29 +0200 Subject: [PATCH] Cosmetics. --- server/TracyView.hpp | 12 +++++++----- server/TracyView_Timeline.cpp | 14 +++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 61b049fd..2ed85e5e 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -146,8 +146,10 @@ private: Inactive }; - struct KeyboardNavigation { - enum Direction : uint8_t { + struct KeyboardNavigation + { + enum Direction + { // Pan left / right Left, Right, @@ -156,9 +158,9 @@ private: Out }; - constexpr static auto DirectionToKeyMap = std::array{ImGuiKey_A, ImGuiKey_D, ImGuiKey_W, ImGuiKey_S}; - constexpr static auto StartRangeMod = std::array{-1, 1, 1, -1}; - constexpr static auto EndRangeMod = std::array{-1, 1, -1, 1}; + constexpr static auto DirectionToKeyMap = std::array { ImGuiKey_A, ImGuiKey_D, ImGuiKey_W, ImGuiKey_S }; + constexpr static auto StartRangeMod = std::array { -1, 1, 1, -1 }; + constexpr static auto EndRangeMod = std::array { -1, 1, -1, 1 }; std::array m_scrollInertia; }; diff --git a/server/TracyView_Timeline.cpp b/server/TracyView_Timeline.cpp index 63bc59f3..2d512726 100644 --- a/server/TracyView_Timeline.cpp +++ b/server/TracyView_Timeline.cpp @@ -156,7 +156,7 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w, d int64_t nextTimelineRangeStart, nextTimelineRangeEnd; bool anyDeltaApplied = false; - if ( m_zoomAnim.active ) + if( m_zoomAnim.active ) { nextTimelineRangeStart = m_zoomAnim.start1; nextTimelineRangeEnd = m_zoomAnim.end1; @@ -173,11 +173,11 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w, d const auto moveInTimelineNanos = std::max( span / 10, 500 ); const auto movement = moveInTimelineNanos * std::max( std::min( io.DeltaTime, 0.25f ), 0.016f ); - for (int direction = 0; direction < 4; direction++) + for( int direction = 0; direction < 4; direction++ ) { auto& inertia = m_kbNavCtrl.m_scrollInertia[direction]; - if ( ImGui::IsKeyDown( KeyboardNavigation::DirectionToKeyMap[direction] ) ) + if( ImGui::IsKeyDown( KeyboardNavigation::DirectionToKeyMap[direction] ) ) { const auto timeStartDelta = movement * KeyboardNavigation::StartRangeMod[direction]; const auto timeEndDelta = movement * KeyboardNavigation::EndRangeMod[direction]; @@ -187,7 +187,7 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w, d const auto mult = 1 + std::max( 0.0, 0.7 * std::pow( x, 1.6 ) - 0.8 * std::pow( x, 1.4 ) ); // If we are zooming in/out - if ( direction > KeyboardNavigation::Right ) + if( direction > KeyboardNavigation::Right ) { // Bias if equal is 0.5. Multiply by 2 to offset back to the expected movement range. nextTimelineRangeStart += timeStartDelta * mult * 2 * bias; @@ -208,10 +208,10 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w, d } } - if ( anyDeltaApplied ) + if( anyDeltaApplied ) { if( m_viewMode == ViewMode::LastFrames ) m_viewMode = ViewMode::LastRange; - if ( nextTimelineRangeStart > nextTimelineRangeEnd ) return; + if( nextTimelineRangeStart > nextTimelineRangeEnd ) return; // We want to cap the zoom at the range of values that the timeline has data for const auto lastKnownTime = m_worker.GetLastTime(); @@ -221,7 +221,7 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w, d nextTimelineRangeStart = std::max( std::min( nextTimelineRangeStart, lastKnownTime - 50 ), 0 ); nextTimelineRangeEnd = std::max( std::min( nextTimelineRangeEnd, lastKnownTime ), 1 ); - if ( nextTimelineRangeEnd - nextTimelineRangeStart <= 50 ) return; + if( nextTimelineRangeEnd - nextTimelineRangeStart <= 50 ) return; const auto shouldPause = m_viewMode == ViewMode::Paused || !m_worker.IsConnected(); ZoomToRange( nextTimelineRangeStart, nextTimelineRangeEnd, shouldPause ); }