summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/GItemView.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-15 15:47:26 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-15 15:47:26 +0200
commit77d6dbc236d6143ef44d3379c96a5db79de3eadc (patch)
tree7777ae1c16d7199fc83fdd8db321929054a7b63e /Libraries/LibGUI/GItemView.cpp
parent9f99e285d15a212e74dbf5204df1911134db9741 (diff)
downloadserenity-77d6dbc236d6143ef44d3379c96a5db79de3eadc.zip
GItemView: Elide item names that won't fit
This isn't perfect since now you will just see "Long name..." instead of the whole name, but at least it doesn't look totally wrong either.
Diffstat (limited to 'Libraries/LibGUI/GItemView.cpp')
-rw-r--r--Libraries/LibGUI/GItemView.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Libraries/LibGUI/GItemView.cpp b/Libraries/LibGUI/GItemView.cpp
index 14498d071d..f6e83ed845 100644
--- a/Libraries/LibGUI/GItemView.cpp
+++ b/Libraries/LibGUI/GItemView.cpp
@@ -167,6 +167,7 @@ void GItemView::paint_event(GPaintEvent& event)
Rect text_rect { 0, icon_rect.bottom() + 6 + 1, font.width(item_text.to_string()), font.glyph_height() };
text_rect.center_horizontally_within(item_rect);
text_rect.inflate(6, 4);
+ text_rect.intersect(item_rect);
Color text_color;
if (is_selected_item)
@@ -174,7 +175,7 @@ void GItemView::paint_event(GPaintEvent& event)
else
text_color = model()->data(model_index, GModel::Role::ForegroundColor).to_color(Color::Black);
painter.fill_rect(text_rect, background_color);
- painter.draw_text(text_rect, item_text.to_string(), font, TextAlignment::Center, text_color);
+ painter.draw_text(text_rect, item_text.to_string(), font, TextAlignment::Center, text_color, TextElision::Right);
};
}