From 306aff80d03d25df185dee5a37b89d1af30daee4 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 2 Jan 2021 23:05:27 +0100 Subject: [PATCH] LibGUI: Remove Widget's unused m_{foreground,background}_color ...as well as the few remaining references to set_foreground_color(). These properties are not being used for rendering anymore, presumably because they completely mess up theming - assigning random white and gray backgrounds just doesn't work with dark themes. I've chosen to not replace most of the few remaining uses of this broken functionality with custom palette colors (the closest replacement is background_role) for now (except for Minesweeper where squares with mines are painted red again now), as no one has actually complained about them being broken, so it must look somewhat decent (some just look right anyway). :^) Examples of this are the taskbar buttons, which apparently had a DarkGray foreground color for minimized windows once - this has since been replaced with bold/regular font. Another one is the Profiler's ProfileTimelineWidget, which is supposed to have a white background - which it didn't have for quite some time, it's grey now (with the default theme, that is). Doesn't look bad either. --- Demos/DynamicObject/main.cpp | 1 - Demos/HelloWorld/main.cpp | 1 - DevTools/HackStudio/FormEditorWidget.cpp | 1 - DevTools/Profiler/ProfileTimelineWidget.cpp | 1 - Games/Minesweeper/Field.cpp | 6 +++++- Libraries/LibGUI/Widget.h | 8 -------- Services/Taskbar/TaskbarWindow.cpp | 6 ------ 7 files changed, 5 insertions(+), 19 deletions(-) diff --git a/Demos/DynamicObject/main.cpp b/Demos/DynamicObject/main.cpp index dac2bb96172..541aa6ea0d0 100644 --- a/Demos/DynamicObject/main.cpp +++ b/Demos/DynamicObject/main.cpp @@ -59,7 +59,6 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv, [[maybe_unused auto& main_widget = window->set_main_widget(); main_widget.set_fill_with_background_color(true); - main_widget.set_background_color(Color::White); auto& layout = main_widget.set_layout(); layout.set_margins({ 4, 4, 4, 4 }); diff --git a/Demos/HelloWorld/main.cpp b/Demos/HelloWorld/main.cpp index 0413c0bedde..4c39b30b66d 100644 --- a/Demos/HelloWorld/main.cpp +++ b/Demos/HelloWorld/main.cpp @@ -59,7 +59,6 @@ int main(int argc, char** argv) auto& main_widget = window->set_main_widget(); main_widget.set_fill_with_background_color(true); - main_widget.set_background_color(Color::White); auto& layout = main_widget.set_layout(); layout.set_margins({ 4, 4, 4, 4 }); diff --git a/DevTools/HackStudio/FormEditorWidget.cpp b/DevTools/HackStudio/FormEditorWidget.cpp index efc0d494ec9..9e9773d2c77 100644 --- a/DevTools/HackStudio/FormEditorWidget.cpp +++ b/DevTools/HackStudio/FormEditorWidget.cpp @@ -36,7 +36,6 @@ FormEditorWidget::FormEditorWidget() : m_tool(make(*this)) { set_fill_with_background_color(true); - set_background_color(Color::MidGray); m_form_widget = add(); m_widget_tree_model = WidgetTreeModel::create(*m_form_widget); diff --git a/DevTools/Profiler/ProfileTimelineWidget.cpp b/DevTools/Profiler/ProfileTimelineWidget.cpp index bbaf38973f0..7d4552d3004 100644 --- a/DevTools/Profiler/ProfileTimelineWidget.cpp +++ b/DevTools/Profiler/ProfileTimelineWidget.cpp @@ -31,7 +31,6 @@ ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile) : m_profile(profile) { - set_background_color(Color::White); set_fill_with_background_color(true); set_fixed_height(80); } diff --git a/Games/Minesweeper/Field.cpp b/Games/Minesweeper/Field.cpp index bfe1bddd4a9..75183d1963c 100644 --- a/Games/Minesweeper/Field.cpp +++ b/Games/Minesweeper/Field.cpp @@ -252,7 +252,11 @@ void Field::reset() square.is_swept = false; if (!square.label) { square.label = add(square); - square.label->set_background_color(Color::from_rgb(0xff4040)); + // Square with mine will be filled with background color later, i.e. red + auto palette = square.label->palette(); + palette.set_color(Gfx::ColorRole::Base, Color::from_rgb(0xff4040)); + square.label->set_palette(palette); + square.label->set_background_role(Gfx::ColorRole::Base); } square.label->set_fill_with_background_color(false); square.label->set_relative_rect(rect); diff --git a/Libraries/LibGUI/Widget.h b/Libraries/LibGUI/Widget.h index 5735d7326fa..cde61ef20ec 100644 --- a/Libraries/LibGUI/Widget.h +++ b/Libraries/LibGUI/Widget.h @@ -214,12 +214,6 @@ public: Gfx::ColorRole foreground_role() const { return m_foreground_role; } void set_foreground_role(Gfx::ColorRole); - Color background_color() const { return m_background_color; } - Color foreground_color() const { return m_foreground_color; } - - void set_background_color(Color color) { m_background_color = color; } - void set_foreground_color(Color color) { m_foreground_color = color; } - void set_autofill(bool b) { set_fill_with_background_color(b); } Window* window() @@ -359,8 +353,6 @@ private: Gfx::IntRect m_relative_rect; Gfx::ColorRole m_background_role; Gfx::ColorRole m_foreground_role; - Color m_background_color; - Color m_foreground_color; NonnullRefPtr m_font; String m_tooltip; diff --git a/Services/Taskbar/TaskbarWindow.cpp b/Services/Taskbar/TaskbarWindow.cpp index 9ad590c4951..a68dedc4c96 100644 --- a/Services/Taskbar/TaskbarWindow.cpp +++ b/Services/Taskbar/TaskbarWindow.cpp @@ -206,12 +206,6 @@ void TaskbarWindow::update_window_button(::Window& window, bool show_as_active) auto* button = window.button(); if (!button) return; - - if (window.is_minimized()) { - button->set_foreground_color(Color::DarkGray); - } else { - button->set_foreground_color(Color::Black); - } button->set_text(window.title()); button->set_checked(show_as_active); }