diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-12-23 20:24:26 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-12-23 20:33:01 +0100 |
commit | 411058b2a3c5a1058ac5c2e54ec53dba12e198e4 (patch) | |
tree | 6288fb17845f38fd966332b9fd47182e6b75a356 /Servers/WindowServer/WSWindowFrame.cpp | |
parent | 7c8bbea995d9e2a5580c66cca7e8a56f65329fc2 (diff) | |
download | serenity-411058b2a3c5a1058ac5c2e54ec53dba12e198e4.zip |
WindowServer+LibGUI: Implement basic color theming
Color themes are loaded from .ini files in /res/themes/
The theme can be switched from the "Themes" section in the system menu.
The basic mechanism is that WindowServer broadcasts a SharedBuffer with
all of the color values of the current theme. Clients receive this with
the response to their initial WindowServer::Greet handshake.
When the theme is changed, WindowServer tells everyone by sending out
an UpdateSystemTheme message with a new SharedBuffer to use.
This does feel somewhat bloated somehow, but I'm sure we can iterate on
it over time and improve things.
To get one of the theme colors, use the Color(SystemColor) constructor:
painter.fill_rect(rect, SystemColor::HoverHighlight);
Some things don't work 100% right without a reboot. Specifically, when
constructing a GWidget, it will set its own background and foreground
colors based on the current SystemColor::Window and SystemColor::Text.
The widget is then stuck with these values, and they don't update on
system theme change, only on app restart.
All in all though, this is pretty cool. Merry Christmas! :^)
Diffstat (limited to 'Servers/WindowServer/WSWindowFrame.cpp')
-rw-r--r-- | Servers/WindowServer/WSWindowFrame.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Servers/WindowServer/WSWindowFrame.cpp b/Servers/WindowServer/WSWindowFrame.cpp index 3b4801a26c..44853d3ec1 100644 --- a/Servers/WindowServer/WSWindowFrame.cpp +++ b/Servers/WindowServer/WSWindowFrame.cpp @@ -170,21 +170,21 @@ void WSWindowFrame::paint(Painter& painter) auto& wm = WSWindowManager::the(); if (&window == wm.m_highlight_window) { - border_color = wm.m_highlight_window_border_color; - border_color2 = wm.m_highlight_window_border_color2; - title_color = wm.m_highlight_window_title_color; + border_color = SystemColor::HighlightWindowBorder1; + border_color2 = SystemColor::HighlightWindowBorder2; + title_color = SystemColor::HighlightWindowTitle; } else if (&window == wm.m_move_window) { - border_color = wm.m_moving_window_border_color; - border_color2 = wm.m_moving_window_border_color2; - title_color = wm.m_moving_window_title_color; + border_color = SystemColor::MovingWindowBorder1; + border_color2 = SystemColor::MovingWindowBorder2; + title_color = SystemColor::MovingWindowTitle; } else if (&window == wm.m_active_window) { - border_color = wm.m_active_window_border_color; - border_color2 = wm.m_active_window_border_color2; - title_color = wm.m_active_window_title_color; + border_color = SystemColor::ActiveWindowBorder1; + border_color2 = SystemColor::ActiveWindowBorder2; + title_color = SystemColor::ActiveWindowTitle; } else { - border_color = wm.m_inactive_window_border_color; - border_color2 = wm.m_inactive_window_border_color2; - title_color = wm.m_inactive_window_title_color; + border_color = SystemColor::InactiveWindowBorder1; + border_color2 = SystemColor::InactiveWindowBorder2; + title_color = SystemColor::InactiveWindowTitle; } StylePainter::paint_window_frame(painter, outer_rect); |