From 0840ff9a28e627351a520437ec83902d88310fe5 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 15 Aug 2024 11:25:30 +0200 Subject: adw: add Toast and ToastOverlay classes --- include/turns/adw/helpers/gobj_cast.hpp | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 include/turns/adw/helpers/gobj_cast.hpp (limited to 'include/turns/adw/helpers/gobj_cast.hpp') diff --git a/include/turns/adw/helpers/gobj_cast.hpp b/include/turns/adw/helpers/gobj_cast.hpp new file mode 100644 index 0000000..1ef9089 --- /dev/null +++ b/include/turns/adw/helpers/gobj_cast.hpp @@ -0,0 +1,37 @@ +#ifndef TURNS_ADW_HELPERS_GOBJ_CAST_HPP +#define TURNS_ADW_HELPERS_GOBJ_CAST_HPP + +#include + +#include + +namespace turns::adw::helpers +{ + + template + struct gobj_mixin + { + template + auto gobj(this Self && self) noexcept + { + using clean_type = std::remove_reference_t; + using gobj_type = std::conditional_t, std::add_const_t, Glib::Object>; + using cast_type = std::conditional_t, std::add_const_t, AdwType>; + + return reinterpret_cast(static_cast(self).gobj()); + } + + template + auto gobj_copy(this Self && self) noexcept -> AdwType * + { + using clean_type = std::remove_reference_t; + using gobj_type = std::conditional_t, std::add_const_t, Glib::Object>; + + static_cast(self).reference(); + return self.gobj(); + } + }; + +} // namespace turns::adw::helpers + +#endif \ No newline at end of file -- cgit v1.2.3