diff options
author | Ahmed Hussein <me@ahmedgeek.com> | 2023-05-07 22:00:24 +0300 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-05-08 11:28:52 +0200 |
commit | 214eaebe73811ca197aaacd0dcdee1f894814e3c (patch) | |
tree | 18c52102f8713905a46e03e840485858b05c0d2f /Userland/Libraries/LibGUI | |
parent | 064b7a62169e9b2302344447b201ef43acd293b7 (diff) | |
download | serenity-214eaebe73811ca197aaacd0dcdee1f894814e3c.zip |
LibGUI: Use cursor position when calculating autoscroll delta
Autoscroll delta now takes into account the cursor
position relative to the widget inner rect height
to allow for faster rubber band autoscrolling.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp b/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp index cd31d08efd..0d3d762fbb 100644 --- a/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp +++ b/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp @@ -333,9 +333,9 @@ Gfx::IntPoint AbstractScrollableWidget::automatic_scroll_delta_from_position(Gfx Gfx::IntPoint delta { 0, 0 }; if (pos.y() < m_autoscroll_threshold) - delta.set_y(clamp(-(m_autoscroll_threshold - pos.y()), -m_autoscroll_threshold, 0)); + delta.set_y(AK::min(pos.y() - m_autoscroll_threshold, 0)); else if (pos.y() > widget_inner_rect().height() - m_autoscroll_threshold) - delta.set_y(clamp(m_autoscroll_threshold - (widget_inner_rect().height() - pos.y()), 0, m_autoscroll_threshold)); + delta.set_y(AK::max(pos.y() + m_autoscroll_threshold - widget_inner_rect().height(), 0)); if (pos.x() < m_autoscroll_threshold) delta.set_x(clamp(-(m_autoscroll_threshold - pos.x()), -m_autoscroll_threshold, 0)); |