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 /Applications/SystemMonitor | |
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 'Applications/SystemMonitor')
-rw-r--r-- | Applications/SystemMonitor/NetworkStatisticsWidget.cpp | 2 | ||||
-rw-r--r-- | Applications/SystemMonitor/main.cpp | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/Applications/SystemMonitor/NetworkStatisticsWidget.cpp b/Applications/SystemMonitor/NetworkStatisticsWidget.cpp index e9001cd6ef..c7eb3c3932 100644 --- a/Applications/SystemMonitor/NetworkStatisticsWidget.cpp +++ b/Applications/SystemMonitor/NetworkStatisticsWidget.cpp @@ -11,7 +11,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GWidget* parent) set_layout(make<GBoxLayout>(Orientation::Vertical)); layout()->set_margins({ 4, 4, 4, 4 }); set_fill_with_background_color(true); - set_background_color(Color::WarmGray); + set_background_color(SystemColor::Window); auto adapters_group_box = GGroupBox::construct("Adapters", this); adapters_group_box->set_layout(make<GBoxLayout>(Orientation::Vertical)); diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index edc690251c..f67bde0f16 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -53,7 +53,7 @@ int main(int argc, char** argv) auto keeper = GWidget::construct(); keeper->set_layout(make<GBoxLayout>(Orientation::Vertical)); keeper->set_fill_with_background_color(true); - keeper->set_background_color(Color::WarmGray); + keeper->set_background_color(SystemColor::Window); keeper->layout()->set_margins({ 4, 4, 4, 4 }); auto tabwidget = GTabWidget::construct(keeper); @@ -355,7 +355,7 @@ NonnullRefPtr<GWidget> build_graphs_tab() graphs_container->on_first_show = [](auto& self) { self.set_fill_with_background_color(true); - self.set_background_color(Color::WarmGray); + self.set_background_color(SystemColor::Window); self.set_layout(make<GBoxLayout>(Orientation::Vertical)); self.layout()->set_margins({ 4, 4, 4, 4 }); |