summaryrefslogtreecommitdiff
path: root/app/src/windows/tracker.cpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2024-07-17 01:07:22 +0200
committerFelix Morgner <felix.morgner@gmail.com>2024-07-17 01:07:22 +0200
commit1435da0c878b705035fda0dfbdb31013645ce2f9 (patch)
tree09cc77f78544b6f21c6bc635722e6fdcf8b26c67 /app/src/windows/tracker.cpp
parent225bfa26409243db96a0d36100561c257d0488f9 (diff)
downloadturns-1435da0c878b705035fda0dfbdb31013645ce2f9.tar.xz
turns-1435da0c878b705035fda0dfbdb31013645ce2f9.zip
app/ui: implement basic turn tracking
Diffstat (limited to 'app/src/windows/tracker.cpp')
-rw-r--r--app/src/windows/tracker.cpp102
1 files changed, 85 insertions, 17 deletions
diff --git a/app/src/windows/tracker.cpp b/app/src/windows/tracker.cpp
index 5af405b..7712539 100644
--- a/app/src/windows/tracker.cpp
+++ b/app/src/windows/tracker.cpp
@@ -30,34 +30,23 @@ namespace turns::app::windows
, m_controls{builder->get_widget<Gtk::Revealer>("controls")}
, m_empty(builder->get_widget<Gtk::Widget>("empty"))
, m_stack{builder->get_widget<Gtk::Stack>("stack")}
+ , m_start{builder->get_widget<Gtk::Button>("start")}
, m_title(ADW_WINDOW_TITLE(builder->get_widget<Gtk::Widget>("title")->gobj()))
, m_turn_order{Gtk::make_managed<widgets::turn_order_view>()}
, m_subtitle{Glib::wrap(GTK_WIDGET(m_title)), "subtitle"}
{
- m_stack->add(*m_turn_order);
-
- auto clear_action = add_action("clear", sigc::mem_fun(*m_turn_order->get_model(), &domain::turn_order::clear));
- add_action("add_participant", sigc::mem_fun(*this, &tracker::handle_add_participant));
- add_action_with_parameter("delete", Glib::VARIANT_TYPE_INT32, sigc::mem_fun(*this, &tracker::handle_delete_participant));
- add_action_with_parameter("edit", Glib::VARIANT_TYPE_INT32, sigc::mem_fun(*this, &tracker::handle_edit_participant));
- auto start_action = add_action("start", sigc::mem_fun(*m_turn_order->get_model(), &domain::turn_order::start));
-
- Glib::Binding::bind_property(m_turn_order->get_model()->property_empty(),
- clear_action->property_enabled(),
- Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN);
+ setup_actions();
- Glib::Binding::bind_property(m_turn_order->get_model()->property_empty(),
- m_controls->property_reveal_child(),
- Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN);
+ m_stack->add(*m_turn_order);
Glib::Binding::bind_property(m_turn_order->get_model()->property_empty(),
m_stack->property_visible_child(),
Glib::Binding::Flags::SYNC_CREATE,
[this](auto empty) { return empty ? m_empty : m_turn_order; });
- Glib::Binding::bind_property(m_turn_order->get_model()->property_empty(),
- start_action->property_enabled(),
- Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN);
+ Glib::Binding::bind_property(m_turn_order->get_model()->property_running(),
+ m_controls->property_reveal_child(),
+ Glib::Binding::Flags::SYNC_CREATE);
// clang-format off
Glib::Binding::bind_property(m_turn_order->get_model()->property_empty(),
@@ -91,4 +80,83 @@ namespace turns::app::windows
dialog->present(this);
}
+ auto tracker::handle_stop() -> void
+ {
+ m_turn_order->get_model()->stop();
+ }
+
+ auto tracker::setup_actions() -> void
+ {
+ // win.add_participant
+ // depends-on: turn_order:state == stopped
+ {
+ auto action = add_action("add_participant", sigc::mem_fun(*this, &tracker::handle_add_participant));
+
+ Glib::Binding::bind_property(m_turn_order->get_model()->property_running(),
+ action->property_enabled(),
+ Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN);
+ }
+
+ // win.clear
+ // depends-on: turn_order:empty == false
+ {
+ auto action = add_action("clear", sigc::mem_fun(*m_turn_order->get_model(), &domain::turn_order::clear));
+
+ Glib::Binding::bind_property(m_turn_order->get_model()->property_empty(),
+ action->property_enabled(),
+ Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN);
+ }
+
+ // win.next
+ // depends-on: turn_order:state == running
+ {
+ auto action = add_action("next", sigc::mem_fun(*m_turn_order->get_model(), &domain::turn_order::next));
+
+ Glib::Binding::bind_property(m_turn_order->get_model()->property_running(),
+ action->property_enabled(),
+ Glib::Binding::Flags::SYNC_CREATE);
+ }
+
+ // win.previous
+ // depends-on: turn_order:has_previous == true
+ {
+ auto action = add_action("previous", sigc::mem_fun(*m_turn_order->get_model(), &domain::turn_order::previous));
+
+ Glib::Binding::bind_property(m_turn_order->get_model()->property_has_previous(),
+ action->property_enabled(),
+ Glib::Binding::Flags::SYNC_CREATE);
+ }
+
+ // win.start
+ // depends-on: turn_order:empty == false
+ {
+ auto action = add_action("start", sigc::mem_fun(*m_turn_order->get_model(), &domain::turn_order::start));
+
+ Glib::Binding::bind_property(m_turn_order->get_model()->property_empty(),
+ action->property_enabled(),
+ Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN);
+
+ Glib::Binding::bind_property(m_turn_order->get_model()->property_running(),
+ m_start->property_visible(),
+ Glib::Binding::Flags::SYNC_CREATE | Glib::Binding::Flags::INVERT_BOOLEAN);
+ }
+
+ // win.stop
+ // depends-on: turn_order:running == true
+ {
+ auto action = add_action("stop", sigc::mem_fun(*this, &tracker::handle_stop));
+
+ Glib::Binding::bind_property(m_turn_order->get_model()->property_running(),
+ action->property_enabled(),
+ Glib::Binding::Flags::SYNC_CREATE);
+ }
+
+ // win.delete
+ // win.edit
+ {
+ add_action_with_parameter("delete", Glib::VARIANT_TYPE_INT32, sigc::mem_fun(*this, &tracker::handle_delete_participant));
+ add_action_with_parameter("edit", Glib::VARIANT_TYPE_INT32, sigc::mem_fun(*this, &tracker::handle_edit_participant));
+ }
+ }
+
} // namespace turns::app::windows