From 411058b2a3c5a1058ac5c2e54ec53dba12e198e4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 23 Dec 2019 20:24:26 +0100 Subject: 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! :^) --- Libraries/LibGUI/GSplitter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Libraries/LibGUI/GSplitter.cpp') diff --git a/Libraries/LibGUI/GSplitter.cpp b/Libraries/LibGUI/GSplitter.cpp index 2f82f5219e..b1dc224462 100644 --- a/Libraries/LibGUI/GSplitter.cpp +++ b/Libraries/LibGUI/GSplitter.cpp @@ -8,7 +8,7 @@ GSplitter::GSplitter(Orientation orientation, GWidget* parent) { set_layout(make(orientation)); set_fill_with_background_color(true); - set_background_color(Color::WarmGray); + set_background_color(SystemColor::Window); layout()->set_spacing(3); } @@ -25,7 +25,7 @@ void GSplitter::enter_event(CEvent&) void GSplitter::leave_event(CEvent&) { - set_background_color(Color::WarmGray); + set_background_color(SystemColor::Window); if (!m_resizing) window()->set_override_cursor(GStandardCursor::None); update(); -- cgit v1.2.3