Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scroll modifier options #815

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions profiler/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,12 @@ 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", "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;
Expand All @@ -244,6 +247,8 @@ static bool SaveConfig()

fprintf( f, "\n[timeline]\n" );
fprintf( f, "targetFps = %i\n", s_config.targetFps );
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 );
Expand Down Expand Up @@ -741,6 +746,19 @@ static void DrawContents()
ImGui::SetNextItemWidth( 90 * dpiScale );
if( ImGui::InputInt( "##targetfps", &tmp ) ) { s_config.targetFps = std::clamp( tmp, 1, 9999 ); SaveConfig(); }

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();
Expand Down
2 changes: 2 additions & 0 deletions profiler/src/profiler/TracyConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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;
Expand Down
4 changes: 4 additions & 0 deletions profiler/src/profiler/TracyView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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 )
{
InitTextEditor();

Expand All @@ -82,6 +84,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 )
{
m_notificationTime = 4;
m_notificationText = std::string( "Trace loaded in " ) + TimeToString( m_worker.GetLoadTime() );
Expand Down
2 changes: 2 additions & 0 deletions profiler/src/profiler/TracyView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,8 @@ class View

AchievementsMgr* m_achievementsMgr;
bool m_achievements = false;
double m_horizontalScrollMultiplier = 1.0;
double m_verticalScrollMultiplier = 1.0;
};

}
Expand Down
2 changes: 1 addition & 1 deletion profiler/src/profiler/TracyView_FrameOverview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion profiler/src/profiler/TracyView_Timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down
Loading