diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index bcec22e4e..2259b6535 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -64,6 +64,7 @@ bool fullscreen = false; bool altFullscreen = false; bool forceIntegerScaling = true; bool resizable = false; +bool momentumScroll = true; void ClipboardPush(ByteString text) @@ -696,6 +697,7 @@ int main(int argc, char * argv[]) fullscreen = Client::Ref().GetPrefBool("Fullscreen", false); altFullscreen = Client::Ref().GetPrefBool("AltFullscreen", false); forceIntegerScaling = Client::Ref().GetPrefBool("ForceIntegerScaling", true); + momentumScroll = Client::Ref().GetPrefBool("MomentumScroll", true); if(arguments["kiosk"] == "true") @@ -785,6 +787,7 @@ int main(int argc, char * argv[]) ui::Engine::Ref().Fullscreen = fullscreen; ui::Engine::Ref().SetAltFullscreen(altFullscreen); ui::Engine::Ref().SetForceIntegerScaling(forceIntegerScaling); + ui::Engine::Ref().SetMomentumScroll(momentumScroll); engine = &ui::Engine::Ref(); engine->SetMaxSize(desktopWidth, desktopHeight); diff --git a/src/gui/interface/Engine.cpp b/src/gui/interface/Engine.cpp index 1d92fb937..eff118204 100644 --- a/src/gui/interface/Engine.cpp +++ b/src/gui/interface/Engine.cpp @@ -34,7 +34,8 @@ Engine::Engine(): mousexp_(0), mouseyp_(0), maxWidth(0), - maxHeight(0) + maxHeight(0), + momentumScroll(false) { } diff --git a/src/gui/interface/Engine.h b/src/gui/interface/Engine.h index 28e14052b..5c96e869c 100644 --- a/src/gui/interface/Engine.h +++ b/src/gui/interface/Engine.h @@ -119,6 +119,19 @@ namespace ui int maxWidth; int maxHeight; + + bool momentumScroll; + + public: + inline void SetMomentumScroll(bool newMomentumScroll) + { + momentumScroll = newMomentumScroll; + } + + inline bool GetMomentumScroll() const + { + return momentumScroll; + } }; } diff --git a/src/gui/interface/ScrollPanel.cpp b/src/gui/interface/ScrollPanel.cpp index 74f59e2f6..878eb76c4 100644 --- a/src/gui/interface/ScrollPanel.cpp +++ b/src/gui/interface/ScrollPanel.cpp @@ -1,4 +1,5 @@ #include "ScrollPanel.h" +#include "Engine.h" #include "graphics/Graphics.h" @@ -21,10 +22,8 @@ ScrollPanel::ScrollPanel(Point position, Point size): scrollbarSelected(false), scrollbarInitialYOffset(0), scrollbarInitialYClick(0), - scrollbarClickLocation(0), - momentumScroll(false) + scrollbarClickLocation(0) { - momentumScroll = Client::Ref().GetPrefBool("MomentumScroll", true); } int ScrollPanel::GetScrollLimit() @@ -46,7 +45,7 @@ void ScrollPanel::XOnMouseWheelInside(int localx, int localy, int d) { if (!d) return; - if (momentumScroll) + if (ui::Engine::Ref().GetMomentumScroll()) yScrollVel -= d * 2; else yScrollVel -= d * 20; @@ -144,7 +143,7 @@ void ScrollPanel::XTick(float dt) offsetX += xScrollVel; - if (momentumScroll) + if (ui::Engine::Ref().GetMomentumScroll()) { if (yScrollVel > -0.5f && yScrollVel < 0.5) yScrollVel = 0; diff --git a/src/gui/interface/ScrollPanel.h b/src/gui/interface/ScrollPanel.h index c1e342468..ecbc8860a 100644 --- a/src/gui/interface/ScrollPanel.h +++ b/src/gui/interface/ScrollPanel.h @@ -16,7 +16,6 @@ namespace ui bool isMouseInsideScrollbar; bool isMouseInsideScrollbarArea; bool scrollbarSelected; - bool momentumScroll; int scrollbarInitialYOffset; int scrollbarInitialYClick; int scrollbarClickLocation; diff --git a/src/gui/options/OptionsModel.cpp b/src/gui/options/OptionsModel.cpp index f329d63d0..b6fec3b81 100644 --- a/src/gui/options/OptionsModel.cpp +++ b/src/gui/options/OptionsModel.cpp @@ -234,6 +234,7 @@ bool OptionsModel::GetMomentumScroll() void OptionsModel::SetMomentumScroll(bool state) { Client::Ref().SetPref("MomentumScroll", state); + ui::Engine::Ref().SetMomentumScroll(state); notifySettingsChanged(); }