Add scroll modifier options

This commit is contained in:
imkunet 2024-06-17 03:32:30 -04:00 committed by Bartosz Taudul
parent 3c0db7e3c3
commit 0cac843ad7
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
6 changed files with 31 additions and 2 deletions

View File

@ -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();

View File

@ -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;

View File

@ -56,6 +56,8 @@ View::View( void(*cbMainThread)(const std::function<void()>&, 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<void()>&, 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

View File

@ -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<FlameGraphItem> m_flameGraphData;
struct

View File

@ -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;

View File

@ -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 );