LibGUI: Brighten icons when hovering items in item views

View classes now track their hovered item and paint them in a slightly
brighter shade to liven up the user interface. :^)
This commit is contained in:
Andreas Kling 2020-03-30 19:57:44 +02:00
parent add93bf593
commit b4fde72013
Notes: sideshowbarker 2024-07-19 08:02:45 +09:00
6 changed files with 40 additions and 11 deletions

View file

@ -128,9 +128,14 @@ void ColumnsView::paint_event(PaintEvent& event)
auto icon = model()->data(index, Model::Role::Icon);
Gfx::Rect icon_rect = { column_x + icon_spacing(), 0, icon_size(), icon_size() };
icon_rect.center_vertically_within(row_rect);
if (icon.is_icon())
if (auto* bitmap = icon.as_icon().bitmap_for_size(icon_size()))
painter.blit(icon_rect.location(), *bitmap, bitmap->rect());
if (icon.is_icon()) {
if (auto* bitmap = icon.as_icon().bitmap_for_size(icon_size())) {
if (m_hovered_index.is_valid() && m_hovered_index.parent() == index.parent() && m_hovered_index.row() == index.row())
painter.blit_brightened(icon_rect.location(), *bitmap, bitmap->rect());
else
painter.blit(icon_rect.location(), *bitmap, bitmap->rect());
}
}
Gfx::Rect text_rect = {
icon_rect.right() + 1 + icon_spacing(), row * item_height(),