summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-10-26 21:32:27 +0100
committerAndreas Kling <kling@serenityos.org>2020-10-26 21:32:27 +0100
commit4bc87687374e5308ed2cdfa907edccfc4675af51 (patch)
treef42589b496a7c27ed199403a49fa2d8a462b9ca1
parentd172783d339db6b3ba128c0a65286d82bf1ebcaa (diff)
downloadserenity-4bc87687374e5308ed2cdfa907edccfc4675af51.zip
LibGUI: Tint selected icons in {Icon,Table,Columns}View
Add a gentle tint to selected icons based on the selection color. :^)
-rw-r--r--Libraries/LibGUI/ColumnsView.cpp8
-rw-r--r--Libraries/LibGUI/IconView.cpp5
-rw-r--r--Libraries/LibGUI/TableView.cpp8
3 files changed, 16 insertions, 5 deletions
diff --git a/Libraries/LibGUI/ColumnsView.cpp b/Libraries/LibGUI/ColumnsView.cpp
index f1951d0a8a..4f26b35b6c 100644
--- a/Libraries/LibGUI/ColumnsView.cpp
+++ b/Libraries/LibGUI/ColumnsView.cpp
@@ -130,10 +130,14 @@ void ColumnsView::paint_event(PaintEvent& event)
icon_rect.center_vertically_within(row_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())
+ if (is_selected_row) {
+ auto tint = palette().selection().with_alpha(100);
+ painter.blit_filtered(icon_rect.location(), *bitmap, bitmap->rect(), [&](auto src) { return src.blend(tint); });
+ } else 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
+ } else {
painter.blit(icon_rect.location(), *bitmap, bitmap->rect());
+ }
}
}
diff --git a/Libraries/LibGUI/IconView.cpp b/Libraries/LibGUI/IconView.cpp
index e40bd9135b..5243ac678d 100644
--- a/Libraries/LibGUI/IconView.cpp
+++ b/Libraries/LibGUI/IconView.cpp
@@ -457,7 +457,10 @@ void IconView::paint_event(PaintEvent& event)
Gfx::IntRect destination = bitmap->rect();
destination.center_within(item_data.icon_rect);
- if (m_hovered_index.is_valid() && m_hovered_index == item_data.index) {
+ if (item_data.selected) {
+ auto tint = palette().selection().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());
} else {
painter.blit(destination.location(), *bitmap, bitmap->rect());
diff --git a/Libraries/LibGUI/TableView.cpp b/Libraries/LibGUI/TableView.cpp
index 3f7cef5073..501da53af1 100644
--- a/Libraries/LibGUI/TableView.cpp
+++ b/Libraries/LibGUI/TableView.cpp
@@ -121,10 +121,14 @@ void TableView::paint_event(PaintEvent& event)
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)) {
- if (m_hovered_index.is_valid() && cell_index.row() == m_hovered_index.row())
+ if (is_selected_row) {
+ auto tint = palette().selection().with_alpha(100);
+ painter.blit_filtered(cell_rect.location(), *bitmap, bitmap->rect(), [&](auto src) { return src.blend(tint); });
+ } else if (m_hovered_index.is_valid() && cell_index.row() == m_hovered_index.row()) {
painter.blit_brightened(cell_rect.location(), *bitmap, bitmap->rect());
- else
+ } else {
painter.blit(cell_rect.location(), *bitmap, bitmap->rect());
+ }
}
} else {
if (!is_selected_row) {