mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
LibGfx: Add 'IsDark' flag to SystemTheme and Palette
This explicitly states whether a given theme is a dark theme, so that applications not using the system palette colors can still attempt to match the overall theme.
This commit is contained in:
parent
2eaed880b1
commit
4f42e4ba90
4 changed files with 48 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -40,6 +41,11 @@ Core::AnonymousBuffer load_system_theme(Core::ConfigFile const& file)
|
|||
return color.value();
|
||||
};
|
||||
|
||||
auto get_flag = [&](auto& name) {
|
||||
auto flag_string = file.read_entry("Flags", name);
|
||||
return flag_string.equals_ignoring_case("true");
|
||||
};
|
||||
|
||||
auto get_metric = [&](auto& name, auto role) {
|
||||
int metric = file.read_num_entry("Metrics", name, -1);
|
||||
if (metric == -1) {
|
||||
|
@ -77,6 +83,12 @@ Core::AnonymousBuffer load_system_theme(Core::ConfigFile const& file)
|
|||
ENUMERATE_COLOR_ROLES(__ENUMERATE_COLOR_ROLE)
|
||||
#undef __ENUMERATE_COLOR_ROLE
|
||||
|
||||
#undef __ENUMERATE_FLAG_ROLE
|
||||
#define __ENUMERATE_FLAG_ROLE(role) \
|
||||
data->flag[(int)FlagRole::role] = get_flag(#role);
|
||||
ENUMERATE_FLAG_ROLES(__ENUMERATE_FLAG_ROLE)
|
||||
#undef __ENUMERATE_FLAG_ROLE
|
||||
|
||||
#undef __ENUMERATE_METRIC_ROLE
|
||||
#define __ENUMERATE_METRIC_ROLE(role) \
|
||||
data->metric[(int)MetricRole::role] = get_metric(#role, (int)MetricRole::role);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue