mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
LibGUI: Properly wrap multiple lines in IconView search highlighting
This commit is contained in:
parent
a870eac0eb
commit
e7cfa9bf8e
3 changed files with 15 additions and 7 deletions
|
@ -543,6 +543,7 @@ void IconView::paint_event(PaintEvent& event)
|
|||
|
||||
const auto& lines = item_data.wrapped_text_lines;
|
||||
size_t number_of_text_lines = min((size_t)text_rect.height() / font->glyph_height(), lines.size());
|
||||
size_t previous_line_lengths = 0;
|
||||
for (size_t line_index = 0; line_index < number_of_text_lines; ++line_index) {
|
||||
Gfx::IntRect line_rect;
|
||||
line_rect.set_width(text_rect.width());
|
||||
|
@ -555,7 +556,8 @@ void IconView::paint_event(PaintEvent& event)
|
|||
if (number_of_text_lines - 1 == line_index && lines.size() > number_of_text_lines)
|
||||
line_rect.inflate(-(6 + 2 * font->max_glyph_width()), 0);
|
||||
|
||||
draw_item_text(painter, item_data.index, item_data.selected, line_rect, lines[line_index], font, Gfx::TextAlignment::Center, Gfx::TextElision::Right);
|
||||
draw_item_text(painter, item_data.index, item_data.selected, line_rect, lines[line_index], font, Gfx::TextAlignment::Center, Gfx::TextElision::Right, previous_line_lengths);
|
||||
previous_line_lengths += lines[line_index].length();
|
||||
}
|
||||
} else {
|
||||
draw_item_text(painter, item_data.index, item_data.selected, item_data.text_rect, item_data.text, font, Gfx::TextAlignment::Center, Gfx::TextElision::Right);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue