summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/SystemTheme.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibGfx/SystemTheme.cpp')
-rw-r--r--Userland/Libraries/LibGfx/SystemTheme.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/SystemTheme.cpp b/Userland/Libraries/LibGfx/SystemTheme.cpp
index e4e9666d41..d6e7d16846 100644
--- a/Userland/Libraries/LibGfx/SystemTheme.cpp
+++ b/Userland/Libraries/LibGfx/SystemTheme.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
+ * Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -45,6 +46,29 @@ Core::AnonymousBuffer load_system_theme(Core::ConfigFile const& file)
return file.read_bool_entry("Flags", name, false);
};
+ auto get_alignment = [&](auto& name, auto role) {
+ auto alignment = file.read_entry("Alignments", name).to_lowercase();
+ if (alignment.is_empty()) {
+ switch (role) {
+ case (int)AlignmentRole::TitleAlignment:
+ return Gfx::TextAlignment::CenterLeft;
+ default:
+ dbgln("Alignment {} has no fallback value!", name);
+ return Gfx::TextAlignment::CenterLeft;
+ }
+ }
+
+ if (alignment == "left" || alignment == "centerleft")
+ return Gfx::TextAlignment::CenterLeft;
+ else if (alignment == "right" || alignment == "centerright")
+ return Gfx::TextAlignment::CenterRight;
+ else if (alignment == "center")
+ return Gfx::TextAlignment::Center;
+
+ dbgln("Alignment {} has an invalid value!", name);
+ return Gfx::TextAlignment::CenterLeft;
+ };
+
auto get_metric = [&](auto& name, auto role) {
int metric = file.read_num_entry("Metrics", name, -1);
if (metric == -1) {
@@ -86,6 +110,12 @@ Core::AnonymousBuffer load_system_theme(Core::ConfigFile const& file)
ENUMERATE_COLOR_ROLES(__ENUMERATE_COLOR_ROLE)
#undef __ENUMERATE_COLOR_ROLE
+#undef __ENUMERATE_ALIGNMENT_ROLE
+#define __ENUMERATE_ALIGNMENT_ROLE(role) \
+ data->alignment[(int)AlignmentRole::role] = get_alignment(#role, (int)AlignmentRole::role);
+ ENUMERATE_ALIGNMENT_ROLES(__ENUMERATE_ALIGNMENT_ROLE)
+#undef __ENUMERATE_ALIGNMENT_ROLE
+
#undef __ENUMERATE_FLAG_ROLE
#define __ENUMERATE_FLAG_ROLE(role) \
data->flag[(int)FlagRole::role] = get_flag(#role);