From 4d0a7d99ebf55ad2d0e583759699b8b4d77a7907 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Wed, 24 Jul 2024 13:23:55 +0200 Subject: app: move ui code to ui library --- app/include/turns/app/application.hpp | 2 +- app/include/turns/app/widgets/participant_row.hpp | 49 ----------------- app/include/turns/app/widgets/template_widget.hpp | 64 ---------------------- app/include/turns/app/widgets/turn_order_view.hpp | 36 ------------ .../turns/app/windows/participant_editor.hpp | 54 ------------------ app/include/turns/app/windows/tracker.hpp | 48 ---------------- 6 files changed, 1 insertion(+), 252 deletions(-) delete mode 100644 app/include/turns/app/widgets/participant_row.hpp delete mode 100644 app/include/turns/app/widgets/template_widget.hpp delete mode 100644 app/include/turns/app/widgets/turn_order_view.hpp delete mode 100644 app/include/turns/app/windows/participant_editor.hpp delete mode 100644 app/include/turns/app/windows/tracker.hpp (limited to 'app/include') diff --git a/app/include/turns/app/application.hpp b/app/include/turns/app/application.hpp index 67217f0..c8bc862 100644 --- a/app/include/turns/app/application.hpp +++ b/app/include/turns/app/application.hpp @@ -1,7 +1,7 @@ #ifndef TURNS_APP_APPLICATION_HPP #define TURNS_APP_APPLICATION_HPP -#include "turns/app/windows/tracker.hpp" +#include "turns/ui/windows/fwd.hpp" #include diff --git a/app/include/turns/app/widgets/participant_row.hpp b/app/include/turns/app/widgets/participant_row.hpp deleted file mode 100644 index 88360db..0000000 --- a/app/include/turns/app/widgets/participant_row.hpp +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef TURNS_APP_WIDGETS_PARTICIPANT_ROW_HPP -#define TURNS_APP_WIDGETS_PARTICIPANT_ROW_HPP - -#include "turns/app/widgets/template_widget.hpp" -#include "turns/core/fwd.hpp" - -#include -#include - -#include -#include -#include -#include - -#include - -namespace turns::app::widgets -{ - struct participant_row : template_widget - { - auto constexpr inline static children = std::array{ - "delete", - "edit", - "subtitle", - "title", - "toggle_defeated", - }; - - participant_row(Glib::RefPtr participant); - - auto property_delete_enabled() -> Glib::PropertyProxy; - auto property_edit_enabled() -> Glib::PropertyProxy; - - private: - auto handle_delete() -> void; - auto handle_edit() -> void; - - Gtk::Button * m_delete; - Gtk::Button * m_edit; - Gtk::Label * m_subtitle; - Gtk::Label * m_title; - Gtk::ToggleButton * m_toggle_defeated; - - Glib::Property m_delete_enabled; - Glib::Property m_edit_enabled; - }; -} // namespace turns::app::widgets - -#endif \ No newline at end of file diff --git a/app/include/turns/app/widgets/template_widget.hpp b/app/include/turns/app/widgets/template_widget.hpp deleted file mode 100644 index 5643cb4..0000000 --- a/app/include/turns/app/widgets/template_widget.hpp +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef TURNS_APP_WIDGETS_TEMPLATE_WIDGET_HPP -#define TURNS_APP_WIDGETS_TEMPLATE_WIDGET_HPP - -#include -#include - -#include - -#include - -#include -#include - -namespace turns::app::widgets -{ - - template - struct template_widget : Glib::ExtraClassInit, - BaseWidgetType - { - template - template_widget(Glib::ustring && resource_path, BaseWidgetCtorArgTypes &&... base_widget_ctor_args) - : Glib::ExtraClassInit{class_init, &resource_path, instance_init} - , BaseWidgetType{std::forward(base_widget_ctor_args)...} - { - } - - protected: - template - auto get_widget(char const * name) -> WidgetType * - { - auto self = static_cast(this); - auto widget = GTK_WIDGET(self->gobj()); - auto type = G_OBJECT_TYPE(self->gobj()); - auto child = GTK_WIDGET(gtk_widget_get_template_child(widget, type, name)); - g_assert_nonnull(child); - return dynamic_cast(Glib::wrap(child)); - } - - private: - auto static class_init(void * g_class, void * g_class_data) -> void - { - g_return_if_fail(GTK_IS_WIDGET_CLASS(g_class)); - - auto resource_path = static_cast(g_class_data); - - gtk_widget_class_set_template_from_resource(GTK_WIDGET_CLASS(g_class), resource_path->c_str()); - - std::ranges::for_each(CustomWidgetType::children, [g_class](auto const & child) { - gtk_widget_class_bind_template_child_full(GTK_WIDGET_CLASS(g_class), child, false, 0); - }); - } - - auto static instance_init(GTypeInstance * instance, void * /* type_class */) -> void - { - g_return_if_fail(GTK_IS_WIDGET(instance)); - - gtk_widget_init_template(GTK_WIDGET(instance)); - } - }; - -} // namespace turns::app::widgets - -#endif \ No newline at end of file diff --git a/app/include/turns/app/widgets/turn_order_view.hpp b/app/include/turns/app/widgets/turn_order_view.hpp deleted file mode 100644 index 88dcde1..0000000 --- a/app/include/turns/app/widgets/turn_order_view.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef TURNS_APP_WIDGETS_TURN_ORDER_VIEW_HPP -#define TURNS_APP_WIDGETS_TURN_ORDER_VIEW_HPP - -#include "turns/app/widgets/template_widget.hpp" -#include "turns/core/fwd.hpp" - -#include -#include - -#include -#include -#include - -#include - -namespace turns::app::widgets -{ - struct turn_order_view : template_widget - { - using model_type = core::turn_order; - - auto constexpr inline static children = std::array{ - "view", - }; - - explicit turn_order_view(Glib::RefPtr model = {}); - - private: - auto handle_create_row(Glib::RefPtr const item) -> Gtk::Widget *; - - Glib::RefPtr m_model; - Gtk::ListBox * m_view; - }; -} // namespace turns::app::widgets - -#endif \ No newline at end of file diff --git a/app/include/turns/app/windows/participant_editor.hpp b/app/include/turns/app/windows/participant_editor.hpp deleted file mode 100644 index 1fa42bb..0000000 --- a/app/include/turns/app/windows/participant_editor.hpp +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef TURNS_APP_WINDOWS_PARTICIPANT_EDITOR_HPP -#define TURNS_APP_WINDOWS_PARTICIPANT_EDITOR_HPP - -#include "turns/core/fwd.hpp" - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -namespace turns::app::windows -{ - - struct participant_editor : Gtk::Widget - { - using signal_finished_type = sigc::signal; - - participant_editor(BaseObjectType * base, Glib::RefPtr const builder, Glib::RefPtr obj = {}); - - auto present(Gtk::Widget * parent) -> void; - - auto signal_finished() -> signal_finished_type; - - private: - auto handle_finish_clicked() -> void; - auto handle_item_bind(Glib::RefPtr item) -> void; - auto handle_item_setup(Glib::RefPtr item) -> void; - - AdwDialog * m_adw; - AdwComboRow * m_disposition; - Gtk::Button * m_finish; - AdwEntryRow * m_name; - AdwSpinRow * m_priority; - - Glib::RefPtr m_disposition_factory; - Glib::RefPtr m_disposition_model; - - Glib::RefPtr m_participant; - - signal_finished_type m_signal_finished{}; - }; - -} // namespace turns::app::windows - -#endif \ No newline at end of file diff --git a/app/include/turns/app/windows/tracker.hpp b/app/include/turns/app/windows/tracker.hpp deleted file mode 100644 index bf3531a..0000000 --- a/app/include/turns/app/windows/tracker.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef TURNS_APP_WINDOWS_TRACKER_HPP -#define TURNS_APP_WINDOWS_TRACKER_HPP - -#include "turns/app/widgets/turn_order_view.hpp" -#include "turns/core/turn_order.hpp" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -namespace turns::app::windows -{ - - struct tracker : Gtk::ApplicationWindow - { - tracker(BaseObjectType * base, Glib::RefPtr const builder); - - private: - auto handle_add_participant() -> void; - auto handle_delete_participant(Glib::VariantBase param) -> void; - auto handle_edit_participant(Glib::VariantBase param) -> void; - auto handle_stop() -> void; - - auto setup_actions() -> void; - - AdwApplicationWindow * m_adw; - Gtk::Revealer * m_controls; - Gtk::Widget * m_empty; - Gtk::Stack * m_stack; - Gtk::Button * m_start; - AdwWindowTitle * m_title; - Glib::RefPtr m_turn_order; - widgets::turn_order_view * m_turn_order_view; - Glib::PropertyProxy m_subtitle; - }; - -} // namespace turns::app::windows - -#endif \ No newline at end of file -- cgit v1.2.3