1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:07:34 +00:00

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! :^)
This commit is contained in:
Andreas Kling 2019-12-23 20:24:26 +01:00
parent 7c8bbea995
commit 411058b2a3
50 changed files with 525 additions and 178 deletions

View file

@ -0,0 +1,44 @@
#pragma once
#include <AK/Types.h>
#include <LibC/SharedBuffer.h>
#include <LibDraw/Color.h>
struct SystemTheme {
Color desktop_background;
Color active_window_border1;
Color active_window_border2;
Color active_window_title;
Color inactive_window_border1;
Color inactive_window_border2;
Color inactive_window_title;
Color moving_window_border1;
Color moving_window_border2;
Color moving_window_title;
Color highlight_window_border1;
Color highlight_window_border2;
Color highlight_window_title;
Color menu_stripe;
Color menu_base;
Color menu_selection;
Color window;
Color text;
Color base;
Color threed_highlight;
Color threed_shadow1;
Color threed_shadow2;
Color hover_highlight;
};
const SystemTheme& current_system_theme();
int current_system_theme_buffer_id();
void set_system_theme(SharedBuffer&);
RefPtr<SharedBuffer> load_system_theme(const String& path);