LibGUI: Make selected item tint color based on focused state

Use the inactive selection color for item icon tinting when the item
view is not focused.
This commit is contained in:
Andreas Kling 2020-12-28 01:14:01 +01:00
parent 0f1235be25
commit 97c42694db
Notes: sideshowbarker 2024-07-19 00:30:54 +09:00
3 changed files with 14 additions and 8 deletions

View file

@ -517,10 +517,12 @@ void IconView::paint_event(PaintEvent& event)
painter.translate(frame_thickness(), frame_thickness());
painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
auto selection_color = is_focused() ? palette().selection() : palette().inactive_selection();
for_each_item_intersecting_rect(to_content_rect(event.rect()), [&](auto& item_data) -> IterationDecision {
Color background_color;
if (item_data.selected) {
background_color = is_focused() ? palette().selection() : palette().inactive_selection();
background_color = selection_color;
} else {
if (fill_with_background_color())
background_color = widget_background_color;
@ -534,7 +536,7 @@ void IconView::paint_event(PaintEvent& event)
destination.center_within(item_data.icon_rect);
if (item_data.selected) {
auto tint = palette().selection().with_alpha(100);
auto tint = selection_color.with_alpha(100);
painter.blit_filtered(destination.location(), *bitmap, bitmap->rect(), [&](auto src) { return src.blend(tint); });
} else if (m_hovered_index.is_valid() && m_hovered_index == item_data.index) {
painter.blit_brightened(destination.location(), *bitmap, bitmap->rect());