1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:47:35 +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

View file

@ -0,0 +1,32 @@
[Colors]
DesktopBackground=#404040
ActiveWindowBorder1=#6e2209
ActiveWindowBorder2=#f4ca9e
ActiveWindowTitle=white
InactiveWindowBorder1=#808080
InactiveWindowBorder2=#c0c0c0
InactiveWindowTitle=#d5d0c7
MovingWindowBorder1=#a1320d
MovingWindowBorder2=#fadcbb
MovingWindowTitle=white
HighlightWindowBorder1=#a10d0d
HighlightWindowBorder2=#fabbbb
HighlightWindowTitle=white
MenuBase=white
MenuStripe=#bbb7b0
MenuSelection=#ad714f
Window=#d4d0c8
Text=black
Base=white
ThreedHighlight=white
ThreedShadow1=#808080
ThreedShadow2=#404040
HoverHighlight=#e3dfdb

33
Base/res/themes/Xmas.ini Normal file
View file

@ -0,0 +1,33 @@
[Colors]
DesktopBackground=#313819
ActiveWindowBorder1=#731013
ActiveWindowBorder2=#ee3532
ActiveWindowTitle=white
InactiveWindowBorder1=#734546
InactiveWindowBorder2=#ee908f
InactiveWindowTitle=white
MovingWindowBorder1=#a76f24
MovingWindowBorder2=#eec666
MovingWindowTitle=white
HighlightWindowBorder1=#a76f24
HighlightWindowBorder2=#eec666
HighlightWindowTitle=white
MenuBase=#57691f
MenuStripe=#2b3018
MenuSelection=#ff8742
Window=#d46c64
Text=black
Base=#d3d7c4
ThreedHighlight=#e69e99
ThreedShadow1=#a24841
ThreedShadow2=#882d26
HoverHighlight=#e6e5e2