1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +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

@ -2,6 +2,9 @@
Width=1024
Height=768
[Theme]
Name=Default
[Cursor]
Arrow=/res/cursors/arrow.png
ResizeH=/res/cursors/resize-horizontal.png
@ -14,26 +17,6 @@ Move=/res/cursors/move.png
Hand=/res/cursors/hand.png
Drag=/res/cursors/drag.png
[Colors]
Background=50,50,50
ActiveWindowBorder=110,34,9
ActiveWindowBorder2=244,202,158
ActiveWindowTitle=255,255,255
InactiveWindowBorder=128,128,128
InactiveWindowBorder2=192,192,192
InactiveWindowTitle=213,208,199
MovingWindowBorder=161,50,13
MovingWindowBorder2=250,220,187
MovingWindowTitle=255,255,255
HighlightWindowBorder=161,13,13
HighlightWindowBorder2=250,187,187
HighlightWindowTitle=255,255,255
MenuSelectionColor=132,53,26
[Input]
DoubleClickSpeed=250