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 --- src/headerbar.cpp | 231 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 src/headerbar.cpp (limited to 'src/headerbar.cpp') diff --git a/src/headerbar.cpp b/src/headerbar.cpp new file mode 100644 index 0000000..d7eec35 --- /dev/null +++ b/src/headerbar.cpp @@ -0,0 +1,231 @@ +/** + * @author Felix Morgner (felix.morgner@gmail.com) + * @copyright Copyright (c) 2025 + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include "adwaitamm/headerbar.hpp" + +#include "adwaitamm/enums.hpp" +#include "adwaitamm/private/headerbar_p.hpp" + +#include +#include +#include +#include +#include + +#include + +#include +#include + +namespace Adwaita +{ + + namespace + { + auto constinit _class = HeaderBar_Class{}; + + namespace property_name + { + auto constexpr centering_policy = "centering-policy"; + auto constexpr decoration_layout = "decoration-layout"; + auto constexpr show_back_button = "show-back-button"; + auto constexpr show_end_title_buttons = "show-end-title-buttons"; + auto constexpr show_start_title_buttons = "show-start-title-buttons"; + auto constexpr show_title = "show-title"; + auto constexpr title_widget = "title-widget"; + } // namespace property_name + } // namespace + + HeaderBar::HeaderBar() + : Glib::ObjectBase{nullptr} + , Gtk::Widget{Glib::ConstructParams{_class.init()}} + { + } + + auto HeaderBar::get_type() -> GType + { + return _class.init().get_type(); + } + + auto HeaderBar::get_base_type() -> GType + { + return adw_header_bar_get_type(); + } + + auto HeaderBar::pack_end(Gtk::Widget & widget) -> void + { + adw_header_bar_pack_end(unwrap(this), unwrap(&widget)); + } + + auto HeaderBar::pack_start(Gtk::Widget & widget) -> void + { + adw_header_bar_pack_start(unwrap(this), unwrap(&widget)); + } + + auto HeaderBar::remove(Gtk::Widget & widget) -> void + { + adw_header_bar_remove(unwrap(this), unwrap(&widget)); + } + + auto HeaderBar::get_centering_policy() -> CenteringPolicy + { + return static_cast(adw_header_bar_get_centering_policy(const_cast(unwrap(this)))); + } + + auto HeaderBar::get_decoration_layout() -> Glib::ustring + { + return adw_header_bar_get_decoration_layout(const_cast(unwrap(this))); + } + + auto HeaderBar::get_show_back_button() -> bool + { + return adw_header_bar_get_show_back_button(const_cast(unwrap(this))); + } + + auto HeaderBar::get_show_end_title_buttons() -> bool + { + return adw_header_bar_get_show_end_title_buttons(const_cast(unwrap(this))); + } + + auto HeaderBar::get_show_start_title_buttons() -> bool + { + return adw_header_bar_get_show_start_title_buttons(const_cast(unwrap(this))); + } + + auto HeaderBar::get_show_title() -> bool + { + return adw_header_bar_get_show_title(const_cast(unwrap(this))); + } + + auto HeaderBar::get_title_widget() -> Gtk::Widget * + { + return Glib::wrap(adw_header_bar_get_title_widget(const_cast(unwrap(this)))); + } + + auto HeaderBar::set_centering_policy(CenteringPolicy value) -> void + { + return adw_header_bar_set_centering_policy(unwrap(this), static_cast(value)); + } + + auto HeaderBar::set_decoration_layout(Glib::ustring const & value) -> void + { + return adw_header_bar_set_decoration_layout(unwrap(this), value.c_str()); + } + + auto HeaderBar::set_show_back_button(bool value) -> void + { + return adw_header_bar_set_show_back_button(unwrap(this), value); + } + + auto HeaderBar::set_show_end_title_buttons(bool value) -> void + { + return adw_header_bar_set_show_end_title_buttons(unwrap(this), value); + } + + auto HeaderBar::set_show_start_title_buttons(bool value) -> void + { + return adw_header_bar_set_show_start_title_buttons(unwrap(this), value); + } + + auto HeaderBar::set_show_title(bool value) -> void + { + return adw_header_bar_set_show_title(unwrap(this), value); + } + + auto HeaderBar::set_title_widget(Gtk::Widget & value) -> void + { + return adw_header_bar_set_title_widget(unwrap(this), unwrap(&value)); + } + + auto HeaderBar::property_centering_policy() -> Glib::PropertyProxy + { + return {this, property_name::centering_policy}; + } + + auto HeaderBar::property_centering_policy() const -> Glib::PropertyProxy_ReadOnly + { + return {this, property_name::centering_policy}; + } + + auto HeaderBar::property_decoration_layout() -> Glib::PropertyProxy + { + return {this, property_name::decoration_layout}; + } + + auto HeaderBar::property_decoration_layout() const -> Glib::PropertyProxy_ReadOnly + { + return {this, property_name::decoration_layout}; + } + + auto HeaderBar::property_show_back_button() -> Glib::PropertyProxy + { + return {this, property_name::show_back_button}; + } + + auto HeaderBar::property_show_back_button() const -> Glib::PropertyProxy_ReadOnly + { + return {this, property_name::show_back_button}; + } + + auto HeaderBar::property_show_end_title_buttons() -> Glib::PropertyProxy + { + return {this, property_name::show_end_title_buttons}; + } + + auto HeaderBar::property_show_end_title_buttons() const -> Glib::PropertyProxy_ReadOnly + { + return {this, property_name::show_end_title_buttons}; + } + + auto HeaderBar::property_show_start_title_buttons() -> Glib::PropertyProxy + { + return {this, property_name::show_start_title_buttons}; + } + + auto HeaderBar::property_show_start_title_buttons() const -> Glib::PropertyProxy_ReadOnly + { + return {this, property_name::show_start_title_buttons}; + } + + auto HeaderBar::property_show_title() -> Glib::PropertyProxy + { + return {this, property_name::show_title}; + } + + auto HeaderBar::property_show_title() const -> Glib::PropertyProxy_ReadOnly + { + return {this, property_name::show_title}; + } + + auto HeaderBar::property_title_widget() -> Glib::PropertyProxy + { + return {this, property_name::title_widget}; + } + + auto HeaderBar::property_title_widget() const -> Glib::PropertyProxy_ReadOnly + { + return {this, property_name::title_widget}; + } + + HeaderBar::HeaderBar(Glib::ConstructParams const & params) + : Gtk::Widget{params} + { + } + + HeaderBar::HeaderBar(BaseObjectType * gobj) + : Gtk::Widget(GTK_WIDGET(gobj)) + { + } + +} // namespace Adwaita + +namespace Glib +{ + auto wrap(AdwHeaderBar * object, bool copy) -> Adwaita::HeaderBar * + { + return dynamic_cast(Glib::wrap_auto(G_OBJECT(object), copy)); + } +} // namespace Glib \ No newline at end of file -- cgit v1.2.3