From fe21003777718efac8743bf99c5388b3d6477be2 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 4 Apr 2025 19:56:43 +0200 Subject: adw: implement basic StyleManager --- adw/include/adwaitamm/enums.hpp | 51 +++++++++++++++++++++ adw/include/adwaitamm/stylemanager.hpp | 81 ++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 adw/include/adwaitamm/enums.hpp create mode 100644 adw/include/adwaitamm/stylemanager.hpp (limited to 'adw/include/adwaitamm') diff --git a/adw/include/adwaitamm/enums.hpp b/adw/include/adwaitamm/enums.hpp new file mode 100644 index 0000000..d19ebc7 --- /dev/null +++ b/adw/include/adwaitamm/enums.hpp @@ -0,0 +1,51 @@ +#ifndef LIBADWAITAMM_ENUMS_HPP +#define LIBADWAITAMM_ENUMS_HPP + +#include + +#include + +namespace Adwaita +{ + enum struct AccentColor + { + Blue, + Teal, + Green, + Yellow, + Orange, + Red, + Pink, + Purple, + Slate, + }; + + enum struct ColorScheme + { + Default, + ForceLight, + PreferLight, + PreferDark, + ForceDark, + }; +} // namespace Adwaita + +namespace Glib +{ + +#define VALUE_SPECIALIZATION(Enum) \ + template<> \ + class Value : public Glib::Value_Enum \ + { \ + public: \ + auto static value_type() -> GType; \ + } + + VALUE_SPECIALIZATION(AccentColor); + VALUE_SPECIALIZATION(ColorScheme); + +#undef VALUE_SPECIALIZATION + +} // namespace Glib + +#endif \ No newline at end of file diff --git a/adw/include/adwaitamm/stylemanager.hpp b/adw/include/adwaitamm/stylemanager.hpp new file mode 100644 index 0000000..8c6fd85 --- /dev/null +++ b/adw/include/adwaitamm/stylemanager.hpp @@ -0,0 +1,81 @@ +#ifndef LIBADWAITAMM_STYLE_MANAGER_HPP +#define LIBADWAITAMM_STYLE_MANAGER_HPP + +#include "adwaitamm/helpers/gobj_mixin.hpp" + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + +#define _ADWAITA_INSIDE +#include +#undef _ADWAITA_INSIDE + +using AdwStyleManager = struct _AdwStyleManager; + +namespace Adwaita +{ + enum struct AccentColor; + enum struct ColorScheme; + + struct StyleManager : Glib::Object, + helpers::gobj_mixin + { + struct Class : Glib::Class + { + using BaseClassParent = GObjectClass; + using BaseClassType = AdwStyleManagerClass; + using BaseObjectType = AdwStyleManager; + using CppClassParent = struct Glib::Object_Class; + using CppObjectType = StyleManager; + + auto init() -> Glib::Class const &; + auto static class_init_function(void * gclass, void * data) -> void; + auto static wrap_new(GObject * object) -> Glib::ObjectBase *; + }; + + using BaseObjectType = Class::BaseObjectType; + using BaseClassType = Class::BaseClassType; + using CppObjectType = Class::CppObjectType; + using CppClassType = Class; + + using helpers::gobj_mixin::gobj; + using helpers::gobj_mixin::gobj_copy; + + StyleManager(StyleManager const & other) = delete; + StyleManager(StyleManager && other) noexcept = delete; + + auto operator=(StyleManager const & other) noexcept -> StyleManager & = delete; + auto operator=(StyleManager && other) noexcept -> StyleManager & = delete; + + auto static get_default() -> StyleManager *; + auto static for_display(Gdk::Display & display) -> StyleManager *; + + auto static get_type() -> GType; + auto static get_base_type() -> GType; + + auto get_accent_color() const -> AccentColor; + auto set_color_scheme(ColorScheme value) -> void; + + protected: + explicit StyleManager(Glib::ConstructParams const & params); + explicit StyleManager(BaseObjectType * gobj); + explicit StyleManager(); + }; +} // namespace Adwaita + +namespace Glib +{ + auto wrap(AdwStyleManager * object) -> Adwaita::StyleManager *; +} // namespace Glib + +#endif \ No newline at end of file -- cgit v1.2.3