mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +00:00
LibGUI: Fix scroll_into_view flipping between left/top and right/bottom
This fixes flipping between left/top and right/bottom when the rectangle to make visible doesn't fit into the visible portion each time the function is called.
This commit is contained in:
parent
a823d2a962
commit
307f0bc778
Notes:
sideshowbarker
2024-07-19 01:48:58 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/307f0bc7789 Pull-request: https://github.com/SerenityOS/serenity/pull/3808 Reviewed-by: https://github.com/awesomekling
2 changed files with 4 additions and 6 deletions
|
@ -438,10 +438,8 @@ void AbstractView::set_cursor(ModelIndex index, SelectionUpdate selection_update
|
|||
|
||||
m_cursor_index = index;
|
||||
|
||||
if (scroll_cursor_into_view) {
|
||||
// FIXME: We should scroll into view both vertically *and* horizontally.
|
||||
scroll_into_view(index, false, true);
|
||||
}
|
||||
if (scroll_cursor_into_view)
|
||||
scroll_into_view(index, true, true);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,14 +180,14 @@ void ScrollableWidget::scroll_into_view(const Gfx::IntRect& rect, bool scroll_ho
|
|||
if (scroll_vertically) {
|
||||
if (rect.top() < visible_content_rect.top()) {
|
||||
m_vertical_scrollbar->set_value(rect.top());
|
||||
} else if (rect.bottom() > visible_content_rect.bottom()) {
|
||||
} else if (rect.top() > visible_content_rect.top() && rect.bottom() > visible_content_rect.bottom()) {
|
||||
m_vertical_scrollbar->set_value(rect.bottom() - visible_content_rect.height() + 1);
|
||||
}
|
||||
}
|
||||
if (scroll_horizontally) {
|
||||
if (rect.left() < visible_content_rect.left()) {
|
||||
m_horizontal_scrollbar->set_value(rect.left());
|
||||
} else if (rect.right() > visible_content_rect.right()) {
|
||||
} else if (rect.left() > visible_content_rect.left() && rect.right() > visible_content_rect.right()) {
|
||||
m_horizontal_scrollbar->set_value(rect.right() - visible_content_rect.width() + 1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue