diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2025-04-03 18:41:43 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2025-04-03 18:41:43 +0200 |
| commit | ee599d7d62c16bb59603bedb62f03c01504a1893 (patch) | |
| tree | 8e371a4d211d56ea42b648c7cd1758568b27858b /adw/include/adwaitamm/breakpoint.hpp | |
| parent | 6ff0bb23a71f334fe0ca86581cc86aaab2882003 (diff) | |
| download | turns-ee599d7d62c16bb59603bedb62f03c01504a1893.tar.xz turns-ee599d7d62c16bb59603bedb62f03c01504a1893.zip | |
adw: prepare files for extraction
Diffstat (limited to 'adw/include/adwaitamm/breakpoint.hpp')
| -rw-r--r-- | adw/include/adwaitamm/breakpoint.hpp | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/adw/include/adwaitamm/breakpoint.hpp b/adw/include/adwaitamm/breakpoint.hpp new file mode 100644 index 0000000..8a78abb --- /dev/null +++ b/adw/include/adwaitamm/breakpoint.hpp @@ -0,0 +1,113 @@ +#ifndef LIBADWAITAMM_BREAKPOINT_HPP +#define LIBADWAITAMM_BREAKPOINT_HPP + +#include "adwaitamm/helpers/gobj_mixin.hpp" + +#include <glibmm/object.h> +#include <glibmm/objectbase.h> +#include <glibmm/propertyproxy.h> +#include <glibmm/refptr.h> +#include <glibmm/ustring.h> + +#include <gtkmm/buildable.h> + +#include <glib-object.h> + +#include <optional> + +#define _ADWAITA_INSIDE +#include <adw-breakpoint.h> +#undef _ADWAITA_INSIDE + +namespace turns::adw +{ + struct BreakpointCondition + { + enum struct LengthType : int + { + min_width, + max_width, + min_height, + max_height, + }; + + enum struct RatioType : int + { + min_aspect_ratio, + max_aspect_ratio + }; + + BreakpointCondition(BreakpointCondition const & other); + BreakpointCondition(BreakpointCondition && other); + BreakpointCondition(LengthType type, double value, int unit); // FIXME: replace unit type with actual enum. + BreakpointCondition(RatioType type, int width, int height); + + ~BreakpointCondition() noexcept; + + auto operator&&(BreakpointCondition & rhs) & -> BreakpointCondition; + auto operator||(BreakpointCondition & lhs) & -> BreakpointCondition; + + explicit operator Glib::ustring() const; + + auto static parse(Glib::ustring str) -> std::optional<BreakpointCondition>; + + private: + friend struct Breakpoint; + + explicit BreakpointCondition(AdwBreakpointCondition * object); + + AdwBreakpointCondition * m_object{nullptr}; + }; + + struct Breakpoint final : Glib::Object, + Gtk::Buildable, + helpers::gobj_mixin<Breakpoint, AdwBreakpoint> + { + struct Class : Glib::Class + { + using BaseClassParent = GObjectClass; + using BaseClassType = AdwBreakpointClass; + using BaseObjectType = AdwBreakpoint; + using CppClassParent = struct Glib::Object_Class; + using CppObjectType = Breakpoint; + + 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<CppObjectType, BaseObjectType>::gobj; + using helpers::gobj_mixin<CppObjectType, BaseObjectType>::gobj_copy; + + Breakpoint(Breakpoint const & other) = delete; + Breakpoint(Breakpoint && other) noexcept = default; + + auto operator=(Breakpoint const & other) noexcept -> Breakpoint & = delete; + auto operator=(Breakpoint && other) noexcept -> Breakpoint & = default; + + auto static create(BreakpointCondition & condition) -> Glib::RefPtr<Breakpoint>; + auto static get_type() -> GType; + auto static get_base_type() -> GType; + + auto property_condition() -> Glib::PropertyProxy<BreakpointCondition *>; + + protected: + explicit Breakpoint(BreakpointCondition & condition); + explicit Breakpoint(Glib::ConstructParams const & params); + explicit Breakpoint(BaseObjectType * gobj); + }; + +} // namespace turns::adw + +namespace Glib +{ + auto wrap(AdwBreakpoint * object, bool copy = false) -> Glib::RefPtr<turns::adw::Breakpoint>; +} // namespace Glib + + +#endif
\ No newline at end of file |
