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

@ -26,7 +26,6 @@
#include <AK/StringBuilder.h>
#include <Kernel/KeyCode.h>
#include <LibGfx/Palette.h>
#include <LibGUI/Action.h>
#include <LibGUI/Menu.h>
#include <LibGUI/Model.h>
@ -35,6 +34,7 @@
#include <LibGUI/TableView.h>
#include <LibGUI/TextBox.h>
#include <LibGUI/Window.h>
#include <LibGfx/Palette.h>
namespace GUI {
@ -119,8 +119,12 @@ void TableView::paint_event(PaintEvent& event)
if (data.is_bitmap()) {
painter.blit(cell_rect.location(), data.as_bitmap(), data.as_bitmap().rect());
} else if (data.is_icon()) {
if (auto bitmap = data.as_icon().bitmap_for_size(16))
painter.blit(cell_rect.location(), *bitmap, bitmap->rect());
if (auto bitmap = data.as_icon().bitmap_for_size(16)) {
if (m_hovered_index.is_valid() && cell_index.row() == m_hovered_index.row())
painter.blit_brightened(cell_rect.location(), *bitmap, bitmap->rect());
else
painter.blit(cell_rect.location(), *bitmap, bitmap->rect());
}
} else {
Color text_color;
if (is_selected_row)