1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:17:44 +00:00

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.
This commit is contained in:
Andreas Kling 2020-10-27 16:10:30 +01:00
parent 7112031bfb
commit 272af7685b
4 changed files with 78 additions and 43 deletions

View file

@ -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