mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-02 22:55:23 +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:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user