From ce93a783ee6228f54f5bd24da88becc913c5c85c Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Tue, 29 Apr 2025 12:52:32 +0200 Subject: adw: implement HeaderBar --- include/adwaitamm/adwaitamm.hpp | 3 +- include/adwaitamm/enums.hpp | 7 +++ include/adwaitamm/headerbar.hpp | 97 +++++++++++++++++++++++++++++++ include/adwaitamm/private/headerbar_p.hpp | 39 +++++++++++++ 4 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 include/adwaitamm/headerbar.hpp create mode 100644 include/adwaitamm/private/headerbar_p.hpp (limited to 'include/adwaitamm') diff --git a/include/adwaitamm/adwaitamm.hpp b/include/adwaitamm/adwaitamm.hpp index 1bee898..6f4e73a 100644 --- a/include/adwaitamm/adwaitamm.hpp +++ b/include/adwaitamm/adwaitamm.hpp @@ -11,6 +11,7 @@ #include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export +#include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export @@ -19,7 +20,7 @@ #include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export -#include // IWYU pragma: export +#include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export diff --git a/include/adwaitamm/enums.hpp b/include/adwaitamm/enums.hpp index 159b20d..0809a49 100644 --- a/include/adwaitamm/enums.hpp +++ b/include/adwaitamm/enums.hpp @@ -26,6 +26,12 @@ namespace Adwaita Slate, }; + enum struct CenteringPolicy + { + Loose, + Strict, + }; + enum struct ColorScheme { Default, @@ -90,6 +96,7 @@ namespace Glib } VALUE_SPECIALIZATION(AccentColor); + VALUE_SPECIALIZATION(CenteringPolicy); VALUE_SPECIALIZATION(ColorScheme); VALUE_SPECIALIZATION(LengthType); VALUE_SPECIALIZATION(PresentationMode); diff --git a/include/adwaitamm/headerbar.hpp b/include/adwaitamm/headerbar.hpp new file mode 100644 index 0000000..338b189 --- /dev/null +++ b/include/adwaitamm/headerbar.hpp @@ -0,0 +1,97 @@ +/** + * @author Felix Morgner (felix.morgner@gmail.com) + * @copyright Copyright (c) 2025 + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef LIBADWAITAMM_HEADER_BAR_HPP +#define LIBADWAITAMM_HEADER_BAR_HPP + +#include "adwaitamm/enums.hpp" +#include "helpers/gobj_mixin.hpp" + +#include +#include +#include + +#include + +#include + +#define _ADWAITA_INSIDE +#include +#undef _ADWAITA_INSIDE + +namespace Adwaita +{ + struct HeaderBar final : Gtk::Widget, + helpers::gobj_mixin + { + + using BaseObjectType = AdwHeaderBar; + using BaseClassType = AdwHeaderBarClass; + using CppObjectType = HeaderBar; + using CppClassType = struct HeaderBar_Class; + + using helpers::gobj_mixin::gobj; + using helpers::gobj_mixin::gobj_copy; + + HeaderBar(); + HeaderBar(HeaderBar const & other) = delete; + HeaderBar(HeaderBar && other) noexcept = default; + + auto operator=(HeaderBar const & other) noexcept -> HeaderBar & = delete; + auto operator=(HeaderBar && other) noexcept -> HeaderBar & = default; + + auto static get_type() -> GType; + auto static get_base_type() -> GType; + + auto pack_end(Gtk::Widget & widget) -> void; + auto pack_start(Gtk::Widget & widget) -> void; + auto remove(Gtk::Widget & widget) -> void; + + [[nodiscard]] auto get_centering_policy() -> CenteringPolicy; + [[nodiscard]] auto get_decoration_layout() -> Glib::ustring; + [[nodiscard]] auto get_show_back_button() -> bool; + [[nodiscard]] auto get_show_end_title_buttons() -> bool; + [[nodiscard]] auto get_show_start_title_buttons() -> bool; + [[nodiscard]] auto get_show_title() -> bool; + [[nodiscard]] auto get_title_widget() -> Gtk::Widget *; + + auto set_centering_policy(CenteringPolicy value) -> void; + auto set_decoration_layout(Glib::ustring const & value) -> void; + auto set_show_back_button(bool value) -> void; + auto set_show_end_title_buttons(bool value) -> void; + auto set_show_start_title_buttons(bool value) -> void; + auto set_show_title(bool value) -> void; + auto set_title_widget(Gtk::Widget & value) -> void; + + auto property_centering_policy() -> Glib::PropertyProxy; + auto property_centering_policy() const -> Glib::PropertyProxy_ReadOnly; + auto property_decoration_layout() -> Glib::PropertyProxy; + auto property_decoration_layout() const -> Glib::PropertyProxy_ReadOnly; + auto property_show_back_button() -> Glib::PropertyProxy; + auto property_show_back_button() const -> Glib::PropertyProxy_ReadOnly; + auto property_show_end_title_buttons() -> Glib::PropertyProxy; + auto property_show_end_title_buttons() const -> Glib::PropertyProxy_ReadOnly; + auto property_show_start_title_buttons() -> Glib::PropertyProxy; + auto property_show_start_title_buttons() const -> Glib::PropertyProxy_ReadOnly; + auto property_show_title() -> Glib::PropertyProxy; + auto property_show_title() const -> Glib::PropertyProxy_ReadOnly; + auto property_title_widget() -> Glib::PropertyProxy; + auto property_title_widget() const -> Glib::PropertyProxy_ReadOnly; + + protected: + friend HeaderBar_Class; + + explicit HeaderBar(Glib::ConstructParams const & params); + explicit HeaderBar(BaseObjectType * gobj); + }; +} // namespace Adwaita + +namespace Glib +{ + auto wrap(AdwHeaderBar * object, bool copy = false) -> Adwaita::HeaderBar *; +} // namespace Glib + +#endif \ No newline at end of file diff --git a/include/adwaitamm/private/headerbar_p.hpp b/include/adwaitamm/private/headerbar_p.hpp new file mode 100644 index 0000000..dac73ef --- /dev/null +++ b/include/adwaitamm/private/headerbar_p.hpp @@ -0,0 +1,39 @@ +/** + * @author Felix Morgner (felix.morgner@gmail.com) + * @copyright Copyright (c) 2025 + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#ifndef LIBADWAITAMM_PRIVATE_HEADER_BAR_P_HPP +#define LIBADWAITAMM_PRIVATE_HEADER_BAR_P_HPP + +#include +#include + +#include + +#define _ADWAITA_INSIDE +#include +#undef _ADWAITA_INSIDE + +namespace Adwaita +{ + struct HeaderBar_Class : Glib::Class + { + using BaseClassParent = GtkWidgetClass; + using BaseClassType = AdwHeaderBarClass; + using BaseObjectType = AdwHeaderBar; + using CppClassParent = Gtk::Widget_Class; + using CppObjectType = struct HeaderBar; + + auto init() -> Glib::Class const &; + auto static class_init_function(void * gclass, void * data) -> void; + auto static wrap_new(GObject * object) -> Glib::ObjectBase *; + + protected: + auto static close_attempt(BaseObjectType * self) -> void; + auto static closed(BaseObjectType * self) -> void; + }; +} // namespace Adwaita + +#endif \ No newline at end of file -- cgit v1.2.3