1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

LibGfx: Add Paths to themes

Paths allows themes to specify directories/files where custom
resources are located.
This commit is contained in:
thankyouverycool 2020-07-29 16:09:04 -04:00 committed by Andreas Kling
parent 044b4cc090
commit 41aacdf815
4 changed files with 45 additions and 0 deletions

View file

@ -85,6 +85,19 @@ RefPtr<SharedBuffer> load_system_theme(const String& path)
return metric;
};
auto get_path = [&](auto& name, auto role) {
auto path = file->read_entry("Paths", name);
if (path.is_empty()) {
switch (role) {
case (int)PathRole::TitleButtonIcons:
return "/res/icons/16x16/";
default:
return "/res/";
}
}
return &path[0];
};
#define DO_COLOR(x) \
data->color[(int)ColorRole::x] = get_color(#x)
@ -153,6 +166,11 @@ RefPtr<SharedBuffer> load_system_theme(const String& path)
DO_METRIC(TitleButtonWidth);
DO_METRIC(TitleButtonHeight);
#define DO_PATH(x) \
data->path[(int)PathRole::x] = get_path(#x, (int)PathRole::x)
DO_PATH(TitleButtonIcons);
buffer->seal();
buffer->share_globally();