1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:38:10 +00:00

LibGUI: Dynamically resize editing content rect in IconView

This makes IconView aware of the text width of the
ModelEditingDelegate widget when editing an index and allows us to
resize the content rect as needed.

This also removes the border from the textbox since it could collide
with the icon in ColumnsView. While editing we also skip painting the
inactive selection rect since it would otherwise show when the content
rect gets smaller.
This commit is contained in:
Marcus Nilsson 2021-09-05 13:32:23 +02:00 committed by Andreas Kling
parent 207319ecf1
commit 0583f75926
6 changed files with 42 additions and 4 deletions

View file

@ -160,6 +160,9 @@ void AbstractView::begin_editing(const ModelIndex& index)
VERIFY(model());
stop_editing();
};
m_editing_delegate->on_change = [this, index] {
editing_widget_did_change(index);
};
}
void AbstractView::stop_editing()
@ -670,6 +673,9 @@ bool AbstractView::is_highlighting_searching(const ModelIndex& index) const
void AbstractView::draw_item_text(Gfx::Painter& painter, const ModelIndex& index, bool is_selected, const Gfx::IntRect& text_rect, const StringView& item_text, const Gfx::Font& font, Gfx::TextAlignment alignment, Gfx::TextElision elision, size_t search_highlighting_offset)
{
if (m_edit_index == index)
return;
Color text_color;
if (is_selected)
text_color = is_focused() ? palette().selection_text() : palette().inactive_selection_text();