From e9de8a445f6f242bf5c9c50b0b44bfc7fa50cd59 Mon Sep 17 00:00:00 2001 From: VAN BOSSUYT Nicolas Date: Tue, 7 Apr 2020 20:18:30 +0200 Subject: [PATCH] LibGUI: Center the icon in ItemView when smaller than 32px. --- Libraries/LibGUI/ItemView.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Libraries/LibGUI/ItemView.cpp b/Libraries/LibGUI/ItemView.cpp index f3b33fd5615..d11397d78f3 100644 --- a/Libraries/LibGUI/ItemView.cpp +++ b/Libraries/LibGUI/ItemView.cpp @@ -26,12 +26,12 @@ #include #include -#include #include #include #include #include #include +#include //#define DRAGDROP_DEBUG @@ -300,10 +300,13 @@ void ItemView::paint_event(PaintEvent& event) if (icon.is_icon()) { if (auto bitmap = icon.as_icon().bitmap_for_size(icon_rect.width())) { + Gfx::Rect destination = bitmap->rect(); + destination.center_within(icon_rect); + if (m_hovered_index.is_valid() && m_hovered_index == model_index) { - painter.blit_brightened(icon_rect.location(), *bitmap, bitmap->rect()); + painter.blit_brightened(destination.location(), *bitmap, bitmap->rect()); } else { - painter.blit(icon_rect.location(), *bitmap, bitmap->rect()); + painter.blit(destination.location(), *bitmap, bitmap->rect()); } } }