summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/IconView.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-10-27 16:10:30 +0100
committerAndreas Kling <kling@serenityos.org>2020-10-27 16:10:30 +0100
commit272af7685bd20ebab35af9bf4024b48ff80da011 (patch)
treed9c26a77dd79d86cce2136e7dbe819434e8c74ed /Libraries/LibGUI/IconView.h
parent7112031bfbb0a7214f9fed1f424c3ee5e7a8c470 (diff)
downloadserenity-272af7685bd20ebab35af9bf4024b48ff80da011.zip
LibGUI: Improve and simplify IconView item name wrapping
Move the wrapping logic to get_item_rects(). This makes mouse events able to hit the wrapped labels, and various other little things stop glitching out as well. Also, instead of having a per-line width when wrapping icon names, make the text rect wide enough to fit every line.
Diffstat (limited to 'Libraries/LibGUI/IconView.h')
-rw-r--r--Libraries/LibGUI/IconView.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/Libraries/LibGUI/IconView.h b/Libraries/LibGUI/IconView.h
index 3772f930a4..62f4cbd5ca 100644
--- a/Libraries/LibGUI/IconView.h
+++ b/Libraries/LibGUI/IconView.h
@@ -64,6 +64,8 @@ private:
virtual void mousemove_event(MouseEvent&) override;
virtual void mouseup_event(MouseEvent&) override;
virtual void drag_move_event(DragEvent&) override;
+ virtual void did_change_hovered_index(const ModelIndex& old_index, const ModelIndex& new_index) override;
+ virtual void did_change_cursor_index(const ModelIndex& old_index, const ModelIndex& new_index) override;
virtual void move_cursor(CursorMovement, SelectionUpdate) override;
@@ -72,7 +74,8 @@ private:
Gfx::IntRect icon_rect;
int icon_offset_y;
int text_offset_y;
- Variant data;
+ String text;
+ Vector<StringView> wrapped_text_lines;
ModelIndex index;
bool valid { false };
bool selected { false }; // always valid
@@ -82,7 +85,7 @@ private:
void invalidate()
{
valid = false;
- data.clear();
+ text = {};
}
bool is_intersecting(const Gfx::IntRect& rect) const