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/WSWindowFrame.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/WSWindowFrame.cpp')
-rw-r--r-- | Servers/WindowServer/WSWindowFrame.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/Servers/WindowServer/WSWindowFrame.cpp b/Servers/WindowServer/WSWindowFrame.cpp index 2d8755772f..da968a28a1 100644 --- a/Servers/WindowServer/WSWindowFrame.cpp +++ b/Servers/WindowServer/WSWindowFrame.cpp @@ -153,6 +153,7 @@ void WSWindowFrame::paint(Painter& painter) if (m_window.type() != WSWindowType::Normal) return; + auto& palette = WSWindowManager::the().palette(); auto& window = m_window; auto titlebar_rect = title_bar_rect(); @@ -170,29 +171,29 @@ void WSWindowFrame::paint(Painter& painter) auto& wm = WSWindowManager::the(); if (&window == wm.m_highlight_window) { - border_color = SystemColor::HighlightWindowBorder1; - border_color2 = SystemColor::HighlightWindowBorder2; - title_color = SystemColor::HighlightWindowTitle; + border_color = palette.highlight_window_border1(); + border_color2 = palette.highlight_window_border2(); + title_color = palette.highlight_window_title(); } else if (&window == wm.m_move_window) { - border_color = SystemColor::MovingWindowBorder1; - border_color2 = SystemColor::MovingWindowBorder2; - title_color = SystemColor::MovingWindowTitle; + border_color = palette.moving_window_border1(); + border_color2 = palette.moving_window_border2(); + title_color = palette.moving_window_title(); } else if (&window == wm.m_active_window) { - border_color = SystemColor::ActiveWindowBorder1; - border_color2 = SystemColor::ActiveWindowBorder2; - title_color = SystemColor::ActiveWindowTitle; + border_color = palette.active_window_border1(); + border_color2 = palette.active_window_border2(); + title_color = palette.active_window_title(); } else { - border_color = SystemColor::InactiveWindowBorder1; - border_color2 = SystemColor::InactiveWindowBorder2; - title_color = SystemColor::InactiveWindowTitle; + border_color = palette.inactive_window_border1(); + border_color2 = palette.inactive_window_border2(); + title_color = palette.inactive_window_title(); } - StylePainter::paint_window_frame(painter, outer_rect); + StylePainter::paint_window_frame(painter, outer_rect, palette); if (!window.show_titlebar()) return; - painter.draw_line(titlebar_rect.bottom_left().translated(0, 1), titlebar_rect.bottom_right().translated(0, 1), SystemColor::Button); + painter.draw_line(titlebar_rect.bottom_left().translated(0, 1), titlebar_rect.bottom_right().translated(0, 1), palette.button()); auto leftmost_button_rect = m_buttons.is_empty() ? Rect() : m_buttons.last().relative_rect(); |