From 598efa60a3554b7e2e9af3b7acde7cfc12b61f13 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 17 Dec 2020 00:50:37 +0100 Subject: [PATCH] LibGUI: Table views with SelectRows should scroll entire rows into view --- Libraries/LibGUI/AbstractTableView.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Libraries/LibGUI/AbstractTableView.cpp b/Libraries/LibGUI/AbstractTableView.cpp index 3095778a07..fdb5872029 100644 --- a/Libraries/LibGUI/AbstractTableView.cpp +++ b/Libraries/LibGUI/AbstractTableView.cpp @@ -240,7 +240,16 @@ void AbstractTableView::move_cursor_relative(int vertical_steps, int horizontal_ void AbstractTableView::scroll_into_view(const ModelIndex& index, bool scroll_horizontally, bool scroll_vertically) { - ScrollableWidget::scroll_into_view(content_rect(index), scroll_horizontally, scroll_vertically); + Gfx::IntRect rect; + switch (selection_behavior()) { + case SelectionBehavior::SelectItems: + rect = content_rect(index); + break; + case SelectionBehavior::SelectRows: + rect = row_rect(index.row()); + break; + } + ScrollableWidget::scroll_into_view(rect, scroll_horizontally, scroll_vertically); } void AbstractTableView::context_menu_event(ContextMenuEvent& event)