mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 22:08:59 +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
Notes:
sideshowbarker
2024-07-19 10:44:53 +09:00
Author: https://github.com/awesomekling
Commit: 411058b2a3
50 changed files with 525 additions and 178 deletions
|
@ -25,7 +25,7 @@ void GTableView::paint_event(GPaintEvent& event)
|
|||
GPainter painter(*this);
|
||||
painter.add_clip_rect(frame_inner_rect());
|
||||
painter.add_clip_rect(event.rect());
|
||||
painter.fill_rect(event.rect(), Color::White);
|
||||
painter.fill_rect(event.rect(), SystemColor::Base);
|
||||
painter.translate(frame_thickness(), frame_thickness());
|
||||
painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
|
||||
|
||||
|
@ -60,7 +60,7 @@ void GTableView::paint_event(GPaintEvent& event)
|
|||
background_color = Color(220, 220, 220);
|
||||
key_column_background_color = Color(200, 200, 200);
|
||||
} else {
|
||||
background_color = Color::White;
|
||||
background_color = SystemColor::Base;
|
||||
key_column_background_color = Color(220, 220, 220);
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ void GTableView::paint_event(GPaintEvent& event)
|
|||
};
|
||||
|
||||
Rect unpainted_rect(0, header_height() + painted_item_index * item_height(), exposed_width, height());
|
||||
painter.fill_rect(unpainted_rect, Color::White);
|
||||
painter.fill_rect(unpainted_rect, SystemColor::Base);
|
||||
|
||||
// Untranslate the painter vertically and do the column headers.
|
||||
painter.translate(0, vertical_scrollbar().value());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue