diff options
author | Elyse <kevincristian@outlook.com> | 2021-12-28 21:46:19 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-30 14:31:50 +0100 |
commit | 8b8f4041466c40acce1adb14882de752020082fb (patch) | |
tree | 6f72f8dce3ee1fdbd9c0a136fd3dd95c9aef8044 /Userland | |
parent | 4427386d5f7b376d923a791eb4197ce6c26501bb (diff) | |
download | serenity-8b8f4041466c40acce1adb14882de752020082fb.zip |
LibGUI: Add movement methods to AbstractSlider
These methods give us a simple way to move up and down the slider,
without needing to repeat the 'set_value(value() + some_value)'
pattern that multiple applications and libraries use.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/AbstractSlider.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/AbstractSlider.h b/Userland/Libraries/LibGUI/AbstractSlider.h index a254eb4808..7d22aa7cc3 100644 --- a/Userland/Libraries/LibGUI/AbstractSlider.h +++ b/Userland/Libraries/LibGUI/AbstractSlider.h @@ -38,6 +38,13 @@ public: void set_page_step(int page_step); void set_jump_to_cursor(bool b) { m_jump_to_cursor = b; } + void increase_slider_by(int delta) { set_value(value() + delta); } + void decrease_slider_by(int delta) { set_value(value() - delta); } + void increase_slider_by_page_steps(int page_steps) { set_value(value() + page_step() * page_steps); } + void decrease_slider_by_page_steps(int page_steps) { set_value(value() - page_step() * page_steps); } + void increase_slider_by_steps(int steps) { set_value(value() + step() * steps); } + void decrease_slider_by_steps(int steps) { set_value(value() - step() * steps); } + Function<void(int)> on_change; protected: |