mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17: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:
parent
7c8bbea995
commit
411058b2a3
50 changed files with 525 additions and 178 deletions
|
@ -159,6 +159,8 @@ public:
|
|||
|
||||
WSMenu* find_internal_menu_by_id(int);
|
||||
|
||||
int theme_index() const { return m_theme_index; }
|
||||
|
||||
private:
|
||||
NonnullRefPtr<WSCursor> get_cursor(const String& name);
|
||||
NonnullRefPtr<WSCursor> get_cursor(const String& name, const Point& hotspot);
|
||||
|
@ -266,6 +268,8 @@ private:
|
|||
Color m_menu_selection_color;
|
||||
WeakPtr<WSMenuBar> m_current_menubar;
|
||||
|
||||
int m_theme_index { 0 };
|
||||
|
||||
WSWindowSwitcher m_switcher;
|
||||
WSMenuManager m_menu_manager;
|
||||
|
||||
|
@ -283,6 +287,13 @@ private:
|
|||
Vector<AppMetadata> m_apps;
|
||||
HashMap<String, NonnullRefPtr<WSMenu>> m_app_category_menus;
|
||||
|
||||
struct ThemeMetadata {
|
||||
String name;
|
||||
String path;
|
||||
};
|
||||
Vector<ThemeMetadata> m_themes;
|
||||
RefPtr<WSMenu> m_themes_menu;
|
||||
|
||||
WeakPtr<WSClientConnection> m_dnd_client;
|
||||
String m_dnd_text;
|
||||
String m_dnd_data_type;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue