diff --git a/Userland/Libraries/LibGUI/AbstractTableView.cpp b/Userland/Libraries/LibGUI/AbstractTableView.cpp index f1fe3c25ceb..5a328969e63 100644 --- a/Userland/Libraries/LibGUI/AbstractTableView.cpp +++ b/Userland/Libraries/LibGUI/AbstractTableView.cpp @@ -293,6 +293,13 @@ void AbstractTableView::context_menu_event(ContextMenuEvent& event) on_context_menu_request(index, event); } +Gfx::IntRect AbstractTableView::paint_invalidation_rect(ModelIndex const& index) const +{ + if (!index.is_valid()) + return {}; + return row_rect(index.row()); +} + Gfx::IntRect AbstractTableView::content_rect(int row, int column) const { auto row_rect = this->row_rect(row); diff --git a/Userland/Libraries/LibGUI/AbstractTableView.h b/Userland/Libraries/LibGUI/AbstractTableView.h index 1644ee01cc0..cf5000be8de 100644 --- a/Userland/Libraries/LibGUI/AbstractTableView.h +++ b/Userland/Libraries/LibGUI/AbstractTableView.h @@ -51,6 +51,8 @@ public: Gfx::IntRect content_rect(int row, int column) const; Gfx::IntRect row_rect(int item_index) const; + virtual Gfx::IntRect paint_invalidation_rect(ModelIndex const& index) const override; + virtual void scroll_into_view(const ModelIndex&, bool scroll_horizontally = true, bool scroll_vertically = true) override; void scroll_into_view(const ModelIndex& index, Orientation orientation) { diff --git a/Userland/Libraries/LibGUI/AbstractView.h b/Userland/Libraries/LibGUI/AbstractView.h index b2b1293d978..69f734c87f9 100644 --- a/Userland/Libraries/LibGUI/AbstractView.h +++ b/Userland/Libraries/LibGUI/AbstractView.h @@ -90,6 +90,7 @@ public: virtual Gfx::IntRect content_rect(const ModelIndex&) const { return {}; } virtual Gfx::IntRect editing_rect(ModelIndex const& index) const { return content_rect(index); } + virtual Gfx::IntRect paint_invalidation_rect(ModelIndex const& index) const { return content_rect(index); } virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const { return {}; } void begin_editing(const ModelIndex&); diff --git a/Userland/Libraries/LibGUI/ColumnsView.cpp b/Userland/Libraries/LibGUI/ColumnsView.cpp index 4262feb0a26..7e0c7e8e7da 100644 --- a/Userland/Libraries/LibGUI/ColumnsView.cpp +++ b/Userland/Libraries/LibGUI/ColumnsView.cpp @@ -323,4 +323,12 @@ Gfx::IntRect ColumnsView::content_rect(const ModelIndex& index) const return {}; } +Gfx::IntRect ColumnsView::paint_invalidation_rect(ModelIndex const& index) const +{ + auto rect = content_rect(index); + rect.translate_by(-icon_size(), 0); + rect.set_width(rect.width() + icon_size()); + return rect; +} + } diff --git a/Userland/Libraries/LibGUI/ColumnsView.h b/Userland/Libraries/LibGUI/ColumnsView.h index d143e633ac8..d0c7a29dee5 100644 --- a/Userland/Libraries/LibGUI/ColumnsView.h +++ b/Userland/Libraries/LibGUI/ColumnsView.h @@ -19,6 +19,7 @@ public: virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override; virtual Gfx::IntRect content_rect(const ModelIndex&) const override; + virtual Gfx::IntRect paint_invalidation_rect(ModelIndex const&) const override; private: ColumnsView(); diff --git a/Userland/Libraries/LibGUI/IconView.cpp b/Userland/Libraries/LibGUI/IconView.cpp index 703b512b68f..6c0c532ee11 100644 --- a/Userland/Libraries/LibGUI/IconView.cpp +++ b/Userland/Libraries/LibGUI/IconView.cpp @@ -388,7 +388,15 @@ void IconView::update_item_rects(int item_index, ItemData& item_data) const item_data.text_rect.set_top(item_rect.y() + item_data.text_offset_y); } -Gfx::IntRect IconView::content_rect(const ModelIndex& index) const +Gfx::IntRect IconView::content_rect(ModelIndex const& index) const +{ + if (!index.is_valid()) + return {}; + auto& item_data = get_item_data(index.row()); + return item_data.rect(); +} + +Gfx::IntRect IconView::editing_rect(ModelIndex const& index) const { if (!index.is_valid()) return {}; diff --git a/Userland/Libraries/LibGUI/IconView.h b/Userland/Libraries/LibGUI/IconView.h index 402200d5fa6..ecc3d2fdea8 100644 --- a/Userland/Libraries/LibGUI/IconView.h +++ b/Userland/Libraries/LibGUI/IconView.h @@ -40,6 +40,7 @@ public: virtual ModelIndex index_at_event_position(const Gfx::IntPoint&) const override; virtual Gfx::IntRect content_rect(const ModelIndex&) const override; + virtual Gfx::IntRect editing_rect(ModelIndex const&) const override; virtual void select_all() override; diff --git a/Userland/Libraries/LibGUI/TreeView.cpp b/Userland/Libraries/LibGUI/TreeView.cpp index 1a9fa59b433..0d2929373ae 100644 --- a/Userland/Libraries/LibGUI/TreeView.cpp +++ b/Userland/Libraries/LibGUI/TreeView.cpp @@ -717,4 +717,20 @@ int TreeView::tree_column_x_offset() const return offset; } +Gfx::IntRect TreeView::content_rect(ModelIndex const& index) const +{ + if (!index.is_valid()) + return {}; + + Gfx::IntRect found_rect; + traverse_in_paint_order([&](ModelIndex const& current_index, Gfx::IntRect const& rect, Gfx::IntRect const&, int) { + if (index == current_index) { + found_rect = rect; + return IterationDecision::Break; + } + return IterationDecision::Continue; + }); + return found_rect; +} + } diff --git a/Userland/Libraries/LibGUI/TreeView.h b/Userland/Libraries/LibGUI/TreeView.h index 63eb2570cf6..1cddb0f4e02 100644 --- a/Userland/Libraries/LibGUI/TreeView.h +++ b/Userland/Libraries/LibGUI/TreeView.h @@ -33,6 +33,9 @@ public: virtual int vertical_padding() const override { return m_vertical_padding; } + virtual Gfx::IntRect content_rect(ModelIndex const&) const override; + virtual Gfx::IntRect paint_invalidation_rect(ModelIndex const& index) const override { return content_rect(index); } + protected: TreeView();