summaryrefslogtreecommitdiff
path: root/adw/src/enums.cpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2025-04-04 19:56:43 +0200
committerFelix Morgner <felix.morgner@gmail.com>2025-04-04 19:56:43 +0200
commitfe21003777718efac8743bf99c5388b3d6477be2 (patch)
treeaffc835c977b2703ceefd0b8db9109050433c5a6 /adw/src/enums.cpp
parent61eb53baaa69bdd860c26a79ddf1e53592a6d149 (diff)
downloadturns-fe21003777718efac8743bf99c5388b3d6477be2.tar.xz
turns-fe21003777718efac8743bf99c5388b3d6477be2.zip
adw: implement basic StyleManager
Diffstat (limited to 'adw/src/enums.cpp')
-rw-r--r--adw/src/enums.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/adw/src/enums.cpp b/adw/src/enums.cpp
new file mode 100644
index 0000000..02dd74a
--- /dev/null
+++ b/adw/src/enums.cpp
@@ -0,0 +1,49 @@
+#include "adwaitamm/enums.hpp"
+
+#include <adwaitamm/stylemanager.hpp>
+
+#include <glib-object.h>
+
+#include <type_traits>
+
+namespace
+{
+ template<auto Wrapped, auto Unwrapped>
+ auto constexpr matches =
+ static_cast<std::underlying_type_t<decltype(Wrapped)>>(Wrapped) == static_cast<std::underlying_type_t<decltype(Unwrapped)>>(Unwrapped);
+} // namespace
+
+namespace Adwaita
+{
+
+ static_assert(matches<AccentColor::Blue, ADW_ACCENT_COLOR_BLUE>);
+ static_assert(matches<AccentColor::Teal, ADW_ACCENT_COLOR_TEAL>);
+ static_assert(matches<AccentColor::Green, ADW_ACCENT_COLOR_GREEN>);
+ static_assert(matches<AccentColor::Yellow, ADW_ACCENT_COLOR_YELLOW>);
+ static_assert(matches<AccentColor::Orange, ADW_ACCENT_COLOR_ORANGE>);
+ static_assert(matches<AccentColor::Red, ADW_ACCENT_COLOR_RED>);
+ static_assert(matches<AccentColor::Pink, ADW_ACCENT_COLOR_PINK>);
+ static_assert(matches<AccentColor::Purple, ADW_ACCENT_COLOR_PURPLE>);
+ static_assert(matches<AccentColor::Slate, ADW_ACCENT_COLOR_SLATE>);
+
+ static_assert(matches<ColorScheme::Default, ADW_COLOR_SCHEME_DEFAULT>);
+ static_assert(matches<ColorScheme::ForceLight, ADW_COLOR_SCHEME_FORCE_LIGHT>);
+ static_assert(matches<ColorScheme::PreferLight, ADW_COLOR_SCHEME_PREFER_LIGHT>);
+ static_assert(matches<ColorScheme::PreferDark, ADW_COLOR_SCHEME_PREFER_DARK>);
+ static_assert(matches<ColorScheme::ForceDark, ADW_COLOR_SCHEME_FORCE_DARK>);
+
+} // namespace Adwaita
+
+namespace Glib
+{
+#define VALUE_SPECIALIZATION(Enum, AdwEnumName) \
+ auto Value<Adwaita::Enum>::value_type() -> GType \
+ { \
+ return adw_##AdwEnumName##_get_type(); \
+ }
+
+ VALUE_SPECIALIZATION(AccentColor, accent_color)
+ VALUE_SPECIALIZATION(ColorScheme, color_scheme)
+
+#undef VALUE_SPECIALIZATION
+} // namespace Glib \ No newline at end of file