mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 15:54:58 +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:
parent
7c8bbea995
commit
411058b2a3
50 changed files with 525 additions and 178 deletions
|
@ -1,3 +1,4 @@
|
|||
#include <LibDraw/SystemTheme.h>
|
||||
#include <LibGUI/GAction.h>
|
||||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GClipboard.h>
|
||||
|
@ -19,13 +20,27 @@ GWindowServerConnection& GWindowServerConnection::the()
|
|||
return *s_connection;
|
||||
}
|
||||
|
||||
static void set_system_theme_from_shared_buffer_id(int id)
|
||||
{
|
||||
auto system_theme = SharedBuffer::create_from_shared_buffer_id(id);
|
||||
ASSERT(system_theme);
|
||||
set_system_theme(*system_theme);
|
||||
}
|
||||
|
||||
void GWindowServerConnection::handshake()
|
||||
{
|
||||
auto response = send_sync<WindowServer::Greet>();
|
||||
set_my_client_id(response->client_id());
|
||||
set_system_theme_from_shared_buffer_id(response->system_theme_buffer_id());
|
||||
GDesktop::the().did_receive_screen_rect({}, response->screen_rect());
|
||||
}
|
||||
|
||||
void GWindowServerConnection::handle(const WindowClient::UpdateSystemTheme& message)
|
||||
{
|
||||
set_system_theme_from_shared_buffer_id(message.system_theme_buffer_id());
|
||||
GWindow::update_all_windows({});
|
||||
}
|
||||
|
||||
void GWindowServerConnection::handle(const WindowClient::Paint& message)
|
||||
{
|
||||
#ifdef GEVENTLOOP_DEBUG
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue