From 0cac843ad7d650fbc0c78351d959282b2543e2fe Mon Sep 17 00:00:00 2001 From: imkunet Date: Mon, 17 Jun 2024 03:32:30 -0400 Subject: [PATCH] Add scroll modifier options --- profiler/src/main.cpp | 18 ++++++++++++++++++ profiler/src/profiler/TracyConfig.hpp | 2 ++ profiler/src/profiler/TracyView.cpp | 4 ++++ profiler/src/profiler/TracyView.hpp | 3 +++ .../src/profiler/TracyView_FrameOverview.cpp | 2 +- profiler/src/profiler/TracyView_Timeline.cpp | 4 +++- 6 files changed, 31 insertions(+), 2 deletions(-) diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 438c0833..7cb4c09d 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -224,12 +224,15 @@ static void LoadConfig() if( !ini ) return; int v; + double v1; if( ini_sget( ini, "core", "threadedRendering", "%d", &v ) ) s_config.threadedRendering = v; if( ini_sget( ini, "core", "focusLostLimit", "%d", &v ) ) s_config.focusLostLimit = v; if( ini_sget( ini, "timeline", "targetFps", "%d", &v ) && v >= 1 && v < 10000 ) s_config.targetFps = v; if( ini_sget( ini, "timeline", "dynamicColors", "%d", &v ) ) s_config.dynamicColors = v; if( ini_sget( ini, "timeline", "forceColors", "%d", &v ) ) s_config.forceColors = v; if( ini_sget( ini, "timeline", "shortenName", "%d", &v ) ) s_config.shortenName = v; + if( ini_sget( ini, "timeline", "horizontalScrollMultiplier", "%lf", &v1 ) && v1 > 0.0 ) s_config.horizontalScrollMultiplier = v1; + if( ini_sget( ini, "timeline", "verticalScrollMultiplier", "%lf", &v1 ) && v1 > 0.0 ) s_config.verticalScrollMultiplier = v1; if( ini_sget( ini, "memory", "limit", "%d", &v ) ) s_config.memoryLimit = v; if( ini_sget( ini, "memory", "percent", "%d", &v ) && v >= 1 && v < 1000 ) s_config.memoryLimitPercent = v; if( ini_sget( ini, "achievements", "enabled", "%d", &v ) ) s_config.achievements = v; @@ -253,6 +256,8 @@ static bool SaveConfig() fprintf( f, "dynamicColors = %i\n", s_config.dynamicColors ); fprintf( f, "forceColors = %i\n", (int)s_config.forceColors ); fprintf( f, "shortenName = %i\n", s_config.shortenName ); + fprintf( f, "horizontalScrollMultiplier = %lf\n", s_config.horizontalScrollMultiplier ); + fprintf( f, "verticalScrollMultiplier = %lf\n", s_config.verticalScrollMultiplier ); fprintf( f, "\n[memory]\n" ); fprintf( f, "limit = %i\n", (int)s_config.memoryLimit ); @@ -794,6 +799,19 @@ static void DrawContents() ImGui::PopStyleVar(); ImGui::Unindent(); + ImGui::Spacing(); + ImGui::TextUnformatted( "Scroll Multipliers" ); + ImGui::SameLine(); + tracy::DrawHelpMarker( "The multipliers to the amount to scroll by horizontally and vertically. This is used in the timeline and setting this value can help compensate for scroll wheel sensitivity." ); + ImGui::SameLine(); + double tmpScroll = s_config.horizontalScrollMultiplier; + ImGui::SetNextItemWidth( 45 * dpiScale ); + if( ImGui::InputDouble( "##horizontalscrollmultiplier", &tmpScroll ) ) { s_config.horizontalScrollMultiplier = std::max( tmpScroll, 0.01 ); SaveConfig(); } + tmpScroll = s_config.verticalScrollMultiplier; + ImGui::SameLine(); + ImGui::SetNextItemWidth( 45 * dpiScale ); + if( ImGui::InputDouble( "##verticalscrollmultiplier", &tmpScroll ) ) { s_config.verticalScrollMultiplier = std::max( tmpScroll, 0.01 ); SaveConfig(); } + if( s_totalMem == 0 ) { ImGui::BeginDisabled(); diff --git a/profiler/src/profiler/TracyConfig.hpp b/profiler/src/profiler/TracyConfig.hpp index 3dd1842e..bd0c464e 100644 --- a/profiler/src/profiler/TracyConfig.hpp +++ b/profiler/src/profiler/TracyConfig.hpp @@ -11,6 +11,8 @@ struct Config bool threadedRendering = true; bool focusLostLimit = true; int targetFps = 60; + double horizontalScrollMultiplier = 1.0; + double verticalScrollMultiplier = 1.0; bool memoryLimit = false; int memoryLimitPercent = 80; bool achievements = false; diff --git a/profiler/src/profiler/TracyView.cpp b/profiler/src/profiler/TracyView.cpp index cec5cac8..1668eda8 100644 --- a/profiler/src/profiler/TracyView.cpp +++ b/profiler/src/profiler/TracyView.cpp @@ -56,6 +56,8 @@ View::View( void(*cbMainThread)(const std::function&, bool), const char* , m_cbMainThread( cbMainThread ) , m_achievementsMgr( amgr ) , m_achievements( config.achievements ) + , m_horizontalScrollMultiplier( config.horizontalScrollMultiplier ) + , m_verticalScrollMultiplier( config.verticalScrollMultiplier ) #ifdef __EMSCRIPTEN__ , m_td( 2, "ViewMt" ) #else @@ -85,6 +87,8 @@ View::View( void(*cbMainThread)(const std::function&, bool), FileRead& f , m_cbMainThread( cbMainThread ) , m_achievementsMgr( amgr ) , m_achievements( config.achievements ) + , m_horizontalScrollMultiplier( config.horizontalScrollMultiplier ) + , m_verticalScrollMultiplier( config.verticalScrollMultiplier ) #ifdef __EMSCRIPTEN__ , m_td( 2, "ViewMt" ) #else diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index 19e97662..2f99bb09 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -904,6 +904,9 @@ private: AchievementsMgr* m_achievementsMgr; bool m_achievements = false; + double m_horizontalScrollMultiplier = 1.0; + double m_verticalScrollMultiplier = 1.0; + TaskDispatch m_td; std::vector m_flameGraphData; struct diff --git a/profiler/src/profiler/TracyView_FrameOverview.cpp b/profiler/src/profiler/TracyView_FrameOverview.cpp index 91c24e3f..a24fce89 100644 --- a/profiler/src/profiler/TracyView_FrameOverview.cpp +++ b/profiler/src/profiler/TracyView_FrameOverview.cpp @@ -95,7 +95,7 @@ void View::DrawFrames() if( hover ) { - const auto hwheel_delta = io.MouseWheelH * 100.f; + const auto hwheel_delta = io.MouseWheelH * 100.f * m_horizontalScrollMultiplier; if( IsMouseDragging( 1 ) || hwheel_delta != 0 ) { m_viewMode = ViewMode::Paused; diff --git a/profiler/src/profiler/TracyView_Timeline.cpp b/profiler/src/profiler/TracyView_Timeline.cpp index 107fce4b..75dd9790 100644 --- a/profiler/src/profiler/TracyView_Timeline.cpp +++ b/profiler/src/profiler/TracyView_Timeline.cpp @@ -86,7 +86,7 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w ) } } - const auto hwheel_delta = io.MouseWheelH * 100.f; + const auto hwheel_delta = io.MouseWheelH * 100.f * m_horizontalScrollMultiplier; if( IsMouseDragging( 1 ) || hwheel_delta != 0 ) { m_viewMode = ViewMode::Paused; @@ -143,6 +143,8 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w ) if( io.KeyCtrl ) mod = 0.05; else if( io.KeyShift ) mod = 0.5; + mod *= m_verticalScrollMultiplier; + if( wheel > 0 ) { t0 += int64_t( p1 * mod );