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

LibGUI: Properly wrap multiple lines in IconView search highlighting

This commit is contained in:
Matthew B. Jones 2021-06-03 01:32:31 -06:00 committed by GitHub
parent a870eac0eb
commit e7cfa9bf8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View file

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