diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-12-24 20:57:54 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-12-24 21:27:16 +0100 |
commit | a79bac428b7857b9db2d0641daf3b7f2e3deb91f (patch) | |
tree | 7fee3f0764147238e218b79aa1f526c36deeecb0 /Servers/WindowServer/WSMenuManager.cpp | |
parent | cb4e51a7a58d1c536d51484f83239d8cd9009616 (diff) | |
download | serenity-a79bac428b7857b9db2d0641daf3b7f2e3deb91f.zip |
LibGUI+LibDraw: Add "Palette" concept for scoped color theming
GApplication now has a palette. This palette contains all the system
theme colors by default, and is inherited by a new top-level GWidget.
New child widgets inherit their parents palette.
It is possible to override the GApplication palette, and the palette
of any GWidget.
The Palette object contains a bunch of colors, each corresponding to
a ColorRole. Each role has a convenience getter as well.
Each GWidget now has a background_role() and foreground_role(), which
are then looked up in their current palette when painting. This means
that you no longer alter the background color of a widget by setting
it directly, rather you alter either its background role, or the
widget's palette.
Diffstat (limited to 'Servers/WindowServer/WSMenuManager.cpp')
-rw-r--r-- | Servers/WindowServer/WSMenuManager.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Servers/WindowServer/WSMenuManager.cpp b/Servers/WindowServer/WSMenuManager.cpp index 5db49f1f34..67139e8171 100644 --- a/Servers/WindowServer/WSMenuManager.cpp +++ b/Servers/WindowServer/WSMenuManager.cpp @@ -44,6 +44,7 @@ bool WSMenuManager::is_open(const WSMenu& menu) const void WSMenuManager::draw() { auto& wm = WSWindowManager::the(); + auto& palette = wm.palette(); auto menubar_rect = this->menubar_rect(); if (m_needs_window_resize) { @@ -83,14 +84,14 @@ void WSMenuManager::draw() Painter painter(*window().backing_store()); - painter.fill_rect(menubar_rect, SystemColor::Window); - painter.draw_line({ 0, menubar_rect.bottom() }, { menubar_rect.right(), menubar_rect.bottom() }, SystemColor::ThreedShadow1); + painter.fill_rect(menubar_rect, palette.window()); + painter.draw_line({ 0, menubar_rect.bottom() }, { menubar_rect.right(), menubar_rect.bottom() }, palette.threed_shadow1()); int index = 0; wm.for_each_active_menubar_menu([&](WSMenu& menu) { - Color text_color = SystemColor::WindowText; + Color text_color = palette.window_text(); if (is_open(menu)) { - painter.fill_rect(menu.rect_in_menubar(), SystemColor::MenuSelection); - painter.draw_rect(menu.rect_in_menubar(), Color(SystemColor::MenuSelection).darkened()); + painter.fill_rect(menu.rect_in_menubar(), palette.menu_selection()); + painter.draw_rect(menu.rect_in_menubar(), palette.menu_selection().darkened()); text_color = Color::White; } painter.draw_text( @@ -103,7 +104,7 @@ void WSMenuManager::draw() return IterationDecision::Continue; }); - painter.draw_text(m_username_rect, m_username, Font::default_bold_font(), TextAlignment::CenterRight, SystemColor::WindowText); + painter.draw_text(m_username_rect, m_username, Font::default_bold_font(), TextAlignment::CenterRight, palette.window_text()); time_t now = time(nullptr); auto* tm = localtime(&now); @@ -115,7 +116,7 @@ void WSMenuManager::draw() tm->tm_min, tm->tm_sec); - painter.draw_text(m_time_rect, time_text, wm.font(), TextAlignment::CenterRight, SystemColor::WindowText); + painter.draw_text(m_time_rect, time_text, wm.font(), TextAlignment::CenterRight, palette.window_text()); for (auto& applet : m_applets) { if (!applet) |