From 4d951634009a3a996ea5eed1e3bac2a7505882dd Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Sat, 15 Feb 2020 16:24:20 +0100 Subject: [PATCH] LibGUI: Use inactive selection colors from palette instead of hardcoding them --- Libraries/LibGUI/ColumnsView.cpp | 6 ++++-- Libraries/LibGUI/ItemView.cpp | 4 ++-- Libraries/LibGUI/ListView.cpp | 4 ++-- Libraries/LibGUI/TableView.cpp | 6 +++--- Libraries/LibGUI/TreeView.cpp | 6 +++--- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Libraries/LibGUI/ColumnsView.cpp b/Libraries/LibGUI/ColumnsView.cpp index 85c30a575a..7f95469449 100644 --- a/Libraries/LibGUI/ColumnsView.cpp +++ b/Libraries/LibGUI/ColumnsView.cpp @@ -94,8 +94,10 @@ void ColumnsView::paint_event(PaintEvent& event) Color background_color = palette().color(background_role()); Color text_color = palette().color(foreground_role()); - if (next_column != nullptr && next_column->parent_index == index) - background_color = background_color.blend(palette().selection().with_alpha(100)); + if (next_column != nullptr && next_column->parent_index == index) { + background_color = palette().inactive_selection(); + text_color = palette().inactive_selection_text(); + } if (is_selected_row) { background_color = palette().selection(); diff --git a/Libraries/LibGUI/ItemView.cpp b/Libraries/LibGUI/ItemView.cpp index 55d7f94e2e..bbd2db5cd2 100644 --- a/Libraries/LibGUI/ItemView.cpp +++ b/Libraries/LibGUI/ItemView.cpp @@ -269,7 +269,7 @@ void ItemView::paint_event(PaintEvent& event) bool is_selected_item = selection().contains(model_index); Color background_color; if (is_selected_item) { - background_color = is_focused() ? palette().selection() : Color::from_rgb(0x606060); + background_color = is_focused() ? palette().selection() : palette().inactive_selection(); } else { background_color = widget_background_color; } @@ -289,7 +289,7 @@ void ItemView::paint_event(PaintEvent& event) Color text_color; if (is_selected_item) - text_color = palette().selection_text(); + text_color = is_focused() ? palette().selection_text() : palette().inactive_selection_text(); else text_color = model()->data(model_index, Model::Role::ForegroundColor).to_color(palette().color(foreground_role())); painter.fill_rect(text_rect, background_color); diff --git a/Libraries/LibGUI/ListView.cpp b/Libraries/LibGUI/ListView.cpp index dd7329ed97..c50e8d3b26 100644 --- a/Libraries/LibGUI/ListView.cpp +++ b/Libraries/LibGUI/ListView.cpp @@ -126,7 +126,7 @@ void ListView::paint_event(PaintEvent& event) Color background_color; if (is_selected_row) { - background_color = is_focused() ? palette().selection() : Color::from_rgb(0x606060); + background_color = is_focused() ? palette().selection() : palette().inactive_selection(); } else { Color row_fill_color = palette().color(background_role()); if (alternating_row_colors() && (painted_item_index % 2)) { @@ -151,7 +151,7 @@ void ListView::paint_event(PaintEvent& event) } else { Color text_color; if (is_selected_row) - text_color = palette().selection_text(); + text_color = is_focused() ? palette().selection_text() : palette().inactive_selection_text(); else text_color = model()->data(index, Model::Role::ForegroundColor).to_color(palette().color(foreground_role())); auto text_rect = row_rect; diff --git a/Libraries/LibGUI/TableView.cpp b/Libraries/LibGUI/TableView.cpp index 7cb853178e..4eb8ca9c3b 100644 --- a/Libraries/LibGUI/TableView.cpp +++ b/Libraries/LibGUI/TableView.cpp @@ -85,8 +85,8 @@ void TableView::paint_event(PaintEvent& event) Color background_color; Color key_column_background_color; if (is_selected_row) { - background_color = is_focused() ? palette().selection() : Color::from_rgb(0x606060); - key_column_background_color = is_focused() ? palette().selection() : Color::from_rgb(0x606060); + background_color = is_focused() ? palette().selection() : palette().inactive_selection(); + key_column_background_color = is_focused() ? palette().selection() : palette().inactive_selection(); } else { if (alternating_row_colors() && (painted_item_index % 2)) { background_color = widget_background_color.darkened(0.8f); @@ -125,7 +125,7 @@ void TableView::paint_event(PaintEvent& event) } else { Color text_color; if (is_selected_row) - text_color = palette().selection_text(); + text_color = is_focused() ? palette().selection_text() : palette().inactive_selection_text(); else text_color = model()->data(cell_index, Model::Role::ForegroundColor).to_color(palette().color(foreground_role())); painter.draw_text(cell_rect, data.to_string(), font, column_metadata.text_alignment, text_color, Gfx::TextElision::Right); diff --git a/Libraries/LibGUI/TreeView.cpp b/Libraries/LibGUI/TreeView.cpp index 10ccbc6815..220df877b9 100644 --- a/Libraries/LibGUI/TreeView.cpp +++ b/Libraries/LibGUI/TreeView.cpp @@ -213,13 +213,13 @@ void TreeView::paint_event(PaintEvent& event) Color text_color = palette().color(foreground_role()); if (is_selected_row) - text_color = Color::White; + text_color = is_focused() ? palette().selection_text() : palette().inactive_selection_text(); Color background_color; Color key_column_background_color; if (is_selected_row) { - background_color = is_focused() ? palette().selection() : Color::from_rgb(0x606060); - key_column_background_color = is_focused() ? palette().selection() : Color::from_rgb(0x606060); + background_color = is_focused() ? palette().selection() : palette().inactive_selection(); + key_column_background_color = is_focused() ? palette().selection() : palette().inactive_selection(); } else { if (alternating_row_colors() && (painted_row_index % 2)) { background_color = Color(220, 220, 220);