summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGUI/Scrollbar.cpp8
-rw-r--r--Userland/Libraries/LibGUI/Scrollbar.h9
2 files changed, 17 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Scrollbar.cpp b/Userland/Libraries/LibGUI/Scrollbar.cpp
index 785f09f711..59366fa099 100644
--- a/Userland/Libraries/LibGUI/Scrollbar.cpp
+++ b/Userland/Libraries/LibGUI/Scrollbar.cpp
@@ -114,6 +114,11 @@ bool Scrollbar::has_scrubber() const
return max() != min();
}
+void Scrollbar::set_scroll_animation(Animation scroll_animation)
+{
+ m_scroll_animation = scroll_animation;
+}
+
void Scrollbar::set_value(int value, AllowCallback allow_callback)
{
m_target_value = value;
@@ -125,6 +130,9 @@ void Scrollbar::set_value(int value, AllowCallback allow_callback)
void Scrollbar::set_target_value(int new_target_value)
{
+ if (m_scroll_animation == Animation::CoarseScroll)
+ return set_value(new_target_value);
+
new_target_value = clamp(new_target_value, min(), max());
// If we are already at or scrolling to the new target then don't touch anything
diff --git a/Userland/Libraries/LibGUI/Scrollbar.h b/Userland/Libraries/LibGUI/Scrollbar.h
index 3ebbf944af..e5b99185e7 100644
--- a/Userland/Libraries/LibGUI/Scrollbar.h
+++ b/Userland/Libraries/LibGUI/Scrollbar.h
@@ -23,6 +23,13 @@ public:
bool has_scrubber() const;
+ enum class Animation {
+ SmoothScroll,
+ CoarseScroll
+ };
+
+ void set_scroll_animation(Animation scroll_animation);
+
virtual void set_value(int, AllowCallback = AllowCallback::Yes) override;
void set_target_value(int);
@@ -79,6 +86,8 @@ private:
void update_animated_scroll();
+ Animation m_scroll_animation { Animation::SmoothScroll };
+
int m_target_value { 0 };
int m_start_value { 0 };
double m_animation_time_elapsed { 0 };