mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:48:12 +00:00
WindowServer: New title bar vars for themes
The theming system can now control title bar height, title button size, title stripe color and the title text shadow color. The implemented theme metrics system could be later extended to LibGUI to allow themes to change widget padding, border width, etc.
This commit is contained in:
parent
8e364b9780
commit
51b2b0d5e5
7 changed files with 142 additions and 10 deletions
|
@ -67,6 +67,24 @@ RefPtr<SharedBuffer> load_system_theme(const String& path)
|
|||
return color.value();
|
||||
};
|
||||
|
||||
auto get_metric = [&](auto& name, auto role) {
|
||||
int metric = file->read_num_entry("Metrics", name, -1);
|
||||
if (metric == -1) {
|
||||
switch (role) {
|
||||
case (int)MetricRole::TitleHeight:
|
||||
return 19;
|
||||
case (int)MetricRole::TitleButtonHeight:
|
||||
return 15;
|
||||
case (int)MetricRole::TitleButtonWidth:
|
||||
return 15;
|
||||
default:
|
||||
dbg() << "Metric " << name << " has no fallback value!";
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
return metric;
|
||||
};
|
||||
|
||||
#define DO_COLOR(x) \
|
||||
data->color[(int)ColorRole::x] = get_color(#x)
|
||||
|
||||
|
@ -98,6 +116,8 @@ RefPtr<SharedBuffer> load_system_theme(const String& path)
|
|||
DO_COLOR(HighlightWindowBorder1);
|
||||
DO_COLOR(HighlightWindowBorder2);
|
||||
DO_COLOR(HighlightWindowTitle);
|
||||
DO_COLOR(WindowTitleShadow);
|
||||
DO_COLOR(WindowTitleStripes);
|
||||
DO_COLOR(MenuStripe);
|
||||
DO_COLOR(MenuBase);
|
||||
DO_COLOR(MenuBaseText);
|
||||
|
@ -126,6 +146,13 @@ RefPtr<SharedBuffer> load_system_theme(const String& path)
|
|||
DO_COLOR(SyntaxPreprocessorStatement);
|
||||
DO_COLOR(SyntaxPreprocessorValue);
|
||||
|
||||
#define DO_METRIC(x) \
|
||||
data->metric[(int)MetricRole::x] = get_metric(#x, (int)MetricRole::x)
|
||||
|
||||
DO_METRIC(TitleHeight);
|
||||
DO_METRIC(TitleButtonWidth);
|
||||
DO_METRIC(TitleButtonHeight);
|
||||
|
||||
buffer->seal();
|
||||
buffer->share_globally();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue