mirror of
https://github.com/RGBCube/serenity
synced 2025-07-05 10:47:36 +00:00
LibGUI+FileManager: Add a GIcon class to support multi-size icons.
A GIcon can contain any number of bitmaps internally, and will give you the best fitting icon when you call bitmap_for_size().
This commit is contained in:
parent
7e54fdce99
commit
86413a6f5a
12 changed files with 165 additions and 23 deletions
|
@ -110,8 +110,9 @@ void GItemView::paint_event(GPaintEvent& event)
|
|||
icon_rect.center_within(item_rect);
|
||||
icon_rect.move_by(0, -font.glyph_height() - 6);
|
||||
|
||||
if (icon.is_bitmap()) {
|
||||
painter.draw_scaled_bitmap(icon_rect, icon.as_bitmap(), icon.as_bitmap().rect());
|
||||
if (icon.is_icon()) {
|
||||
if (auto bitmap = icon.as_icon().bitmap_for_size(icon_rect.width()))
|
||||
painter.draw_scaled_bitmap(icon_rect, *bitmap, bitmap->rect());
|
||||
}
|
||||
|
||||
Rect text_rect { 0, icon_rect.bottom() + 6 + 1, font.width(item_text.to_string()), font.glyph_height() };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue