summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/IconView.cpp
diff options
context:
space:
mode:
authorMatthew B. Jones <matthewbjones85@gmail.com>2021-06-03 01:32:31 -0600
committerGitHub <noreply@github.com>2021-06-03 08:32:31 +0100
commite7cfa9bf8e115baeacf82aed93405c790073fd97 (patch)
tree26c9abc7ab020ebedb4650cabf892edb8926935f /Userland/Libraries/LibGUI/IconView.cpp
parenta870eac0eb5b9ae2261554f5b40f1711c867cc1d (diff)
downloadserenity-e7cfa9bf8e115baeacf82aed93405c790073fd97.zip
LibGUI: Properly wrap multiple lines in IconView search highlighting
Diffstat (limited to 'Userland/Libraries/LibGUI/IconView.cpp')
-rw-r--r--Userland/Libraries/LibGUI/IconView.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/IconView.cpp b/Userland/Libraries/LibGUI/IconView.cpp
index dac7d2ddb8..703b512b68 100644
--- a/Userland/Libraries/LibGUI/IconView.cpp
+++ b/Userland/Libraries/LibGUI/IconView.cpp
@@ -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);