summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-07-10 16:50:24 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-10 18:30:46 +0200
commit148e72bfa0a93e7ec5467b4dae7701f4ab9201f5 (patch)
tree1dd48757ff21821eff9d270851485cf663d6fa93
parent6c67de8186e22d9c39c2fa1eec92de784669336f (diff)
downloadserenity-148e72bfa0a93e7ec5467b4dae7701f4ab9201f5.zip
LibGUI: Add AbstractView::editing_rect() to allow custom editing rects
This allows view classes to customize the editing rect for an index.
-rw-r--r--Userland/Libraries/LibGUI/AbstractView.cpp2
-rw-r--r--Userland/Libraries/LibGUI/AbstractView.h2
2 files changed, 3 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/AbstractView.cpp b/Userland/Libraries/LibGUI/AbstractView.cpp
index 21007ec846..e3c704eefb 100644
--- a/Userland/Libraries/LibGUI/AbstractView.cpp
+++ b/Userland/Libraries/LibGUI/AbstractView.cpp
@@ -147,7 +147,7 @@ void AbstractView::begin_editing(const ModelIndex& index)
m_edit_widget = m_editing_delegate->widget();
add_child(*m_edit_widget);
m_edit_widget->move_to_back();
- m_edit_widget_content_rect = content_rect(index).translated(frame_thickness(), frame_thickness());
+ m_edit_widget_content_rect = editing_rect(index).translated(frame_thickness(), frame_thickness());
update_edit_widget_position();
m_edit_widget->set_focus(true);
m_editing_delegate->will_begin_editing();
diff --git a/Userland/Libraries/LibGUI/AbstractView.h b/Userland/Libraries/LibGUI/AbstractView.h
index 306d70344d..b2b1293d97 100644
--- a/Userland/Libraries/LibGUI/AbstractView.h
+++ b/Userland/Libraries/LibGUI/AbstractView.h
@@ -89,6 +89,8 @@ public:
virtual void did_update_selection();
virtual Gfx::IntRect content_rect(const ModelIndex&) const { return {}; }
+ virtual Gfx::IntRect editing_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&);
void stop_editing();