LibGUI: Fix off-by-one in ScrollableWidget
This was most notable in the widgets TextBox and TextEditor (and therefore also ComboBox and ColorInput), because there the cursor regularly landed just one pixel outside the visible region when going to the right.
This commit is contained in:
parent
5d3ac4ec9e
commit
b6bea3d25b
Notes:
sideshowbarker
2024-07-19 07:03:01 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/b6bea3d25be Pull-request: https://github.com/SerenityOS/serenity/pull/2036 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/zlotny
1 changed files with 8 additions and 6 deletions
|
@ -171,16 +171,18 @@ void ScrollableWidget::scroll_into_view(const Gfx::Rect& rect, bool scroll_horiz
|
|||
return;
|
||||
|
||||
if (scroll_vertically) {
|
||||
if (rect.top() < visible_content_rect.top())
|
||||
if (rect.top() < visible_content_rect.top()) {
|
||||
m_vertical_scrollbar->set_value(rect.top());
|
||||
else if (rect.bottom() > visible_content_rect.bottom())
|
||||
m_vertical_scrollbar->set_value(rect.bottom() - visible_content_rect.height());
|
||||
} else if (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())
|
||||
if (rect.left() < visible_content_rect.left()) {
|
||||
m_horizontal_scrollbar->set_value(rect.left());
|
||||
else if (rect.right() > visible_content_rect.right())
|
||||
m_horizontal_scrollbar->set_value(rect.right() - visible_content_rect.width());
|
||||
} else if (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