From e5a6e297bfbbe158a00fd4c76366fed852be29df Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 24 Aug 2020 21:01:50 +0200 Subject: [PATCH] LibGUI: Add AbstractTableView::scroll_into_view(ModelIndex, bool, bool) This API lets you specify whether to scroll horizontally, vertically, or both. --- Libraries/LibGUI/AbstractTableView.cpp | 6 ++++++ Libraries/LibGUI/AbstractTableView.h | 1 + 2 files changed, 7 insertions(+) diff --git a/Libraries/LibGUI/AbstractTableView.cpp b/Libraries/LibGUI/AbstractTableView.cpp index ff25d77f89..a06d6aa0fc 100644 --- a/Libraries/LibGUI/AbstractTableView.cpp +++ b/Libraries/LibGUI/AbstractTableView.cpp @@ -460,6 +460,12 @@ void AbstractTableView::scroll_into_view(const ModelIndex& index, Orientation or ScrollableWidget::scroll_into_view(rect, orientation); } +void AbstractTableView::scroll_into_view(const ModelIndex& index, bool scroll_horizontally, bool scroll_vertically) +{ + auto rect = row_rect(index.row()).translated(0, -header_height()); + ScrollableWidget::scroll_into_view(rect, scroll_horizontally, scroll_vertically); +} + void AbstractTableView::doubleclick_event(MouseEvent& event) { if (!model()) diff --git a/Libraries/LibGUI/AbstractTableView.h b/Libraries/LibGUI/AbstractTableView.h index e7bfdaac96..c405c64016 100644 --- a/Libraries/LibGUI/AbstractTableView.h +++ b/Libraries/LibGUI/AbstractTableView.h @@ -71,6 +71,7 @@ public: Gfx::IntRect row_rect(int item_index) const; void scroll_into_view(const ModelIndex&, Orientation); + void scroll_into_view(const ModelIndex&, bool scroll_horizontally, bool scroll_vertically); virtual ModelIndex index_at_event_position(const Gfx::IntPoint&, bool& is_toggle) const; virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override;