mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +00:00
LibGUI: Make scrollbars keep scrolling by page while clicking the gutter
Note that m_hovered_component is only updated on mouse move, not while just keeping left down. It's arguably wrong to update it on mouse move while the mouse is down, I'll probably change things so that it doesn't update there either. The behavior on click-in-gutter-keep-left-down-then-move-mouse varies a surprising amount between platforms. This implements the macOS behavior where the scrubber follows the mouse direction while scrolling by pages. (To be precise, it's the macOS behavior of Finder and Preview, Safari has Windows's scrollbar behavior). On Windows, the first click locks in the scroll direction and then dragging the mouse off the scrubber in that direction makes the scroll continue, but dragging it off the other direction has no effect. I see no reason for that behavior.
This commit is contained in:
parent
0a462dac14
commit
98dd034c29
Notes:
sideshowbarker
2024-07-19 03:10:37 +09:00
Author: https://github.com/nico
Commit: 98dd034c29
Pull-request: https://github.com/SerenityOS/serenity/pull/3297
2 changed files with 11 additions and 3 deletions
|
@ -269,6 +269,10 @@ void ScrollBar::on_automatic_scrolling_timer_fired()
|
|||
set_value(value() + m_step);
|
||||
return;
|
||||
}
|
||||
if (m_automatic_scrolling_kind == AutomaticScrollingKind::Gutter && component_at_position(m_last_mouse_position) == Component::Gutter) {
|
||||
scroll_by_page(m_last_mouse_position);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollBar::mousedown_event(MouseEvent& event)
|
||||
|
@ -308,8 +312,8 @@ void ScrollBar::mousedown_event(MouseEvent& event)
|
|||
ASSERT(!event.shift());
|
||||
|
||||
ASSERT(clicked_component == Component::Gutter);
|
||||
// FIXME: If scrolling by page, scroll every second or so while mouse is down.
|
||||
scroll_by_page(event.position());
|
||||
set_automatic_scrolling_active(true, AutomaticScrollingKind::Gutter);
|
||||
update();
|
||||
}
|
||||
|
||||
void ScrollBar::mouseup_event(MouseEvent& event)
|
||||
|
@ -333,6 +337,10 @@ void ScrollBar::mousewheel_event(MouseEvent& event)
|
|||
void ScrollBar::set_automatic_scrolling_active(bool active, AutomaticScrollingKind kind)
|
||||
{
|
||||
m_automatic_scrolling_kind = kind;
|
||||
if (m_automatic_scrolling_kind == AutomaticScrollingKind::Gutter)
|
||||
m_automatic_scrolling_timer->set_interval(200);
|
||||
else
|
||||
m_automatic_scrolling_timer->set_interval(100);
|
||||
|
||||
if (active) {
|
||||
on_automatic_scrolling_timer_fired();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue