diff options
Diffstat (limited to 'adw/src/enums.cpp')
| -rw-r--r-- | adw/src/enums.cpp | 49 |
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 |
