LibGUI: Allow setting smooth/coarse scrolling animation on ScrollBar

This commit is contained in:
MacDue 2022-03-08 21:50:42 +00:00 committed by Andreas Kling
commit 91fff3f1ae
Notes: sideshowbarker 2024-07-17 17:30:20 +09:00
2 changed files with 17 additions and 0 deletions

View file

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