From b5c0f55831a113cdd335634b00a302d68454f33e Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 28 Sep 2021 17:45:58 -0600 Subject: [PATCH] triggerboxui: start connecting more widgets to trigger API --- gtk2_ardour/trigger_ui.cc | 30 ++++++++++++++++++++++++++++-- gtk2_ardour/trigger_ui.h | 8 ++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/trigger_ui.cc b/gtk2_ardour/trigger_ui.cc index 2a194393c4..b224af7a29 100644 --- a/gtk2_ardour/trigger_ui.cc +++ b/gtk2_ardour/trigger_ui.cc @@ -83,6 +83,7 @@ TriggerUI::TriggerUI (Item* parent, Trigger& t) follow_action_button = new ArdourCanvas::Widget (canvas(), *_follow_action_button); follow_action_button->name = "FollowAction"; + _follow_action_button->signal_event().connect (sigc::mem_fun (*this, (&TriggerUI::follow_action_button_event))); _follow_left = new ArdourDropdown; _follow_left->append_text_item (_("None")); @@ -114,13 +115,35 @@ TriggerUI::TriggerUI (Item* parent, Trigger& t) set_fill_color (UIConfiguration::instance().color (X_("theme:bg"))); name = "triggerUI-table"; - trigger_changed (); + PropertyChange pc; + + pc.add (Properties::use_follow); + pc.add (Properties::legato); + + trigger_changed (pc); + + trigger.PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context()); } TriggerUI::~TriggerUI () { } +bool +TriggerUI::follow_action_button_event (GdkEvent* ev) +{ + switch (ev->type) { + case GDK_BUTTON_PRESS: + trigger.set_use_follow (!trigger.use_follow()); + return true; + + default: + break; + } + + return false; +} + std::string TriggerUI::follow_action_to_string (Trigger::FollowAction fa) { @@ -149,8 +172,11 @@ TriggerUI::follow_action_to_string (Trigger::FollowAction fa) } void -TriggerUI::trigger_changed () +TriggerUI::trigger_changed (PropertyChange pc) { + if (pc.contains (Properties::use_follow)) { + _follow_action_button->set_active_state (trigger.use_follow() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off); + } _follow_right->set_text (follow_action_to_string (trigger.follow_action (0))); _follow_left->set_text (follow_action_to_string (trigger.follow_action (1))); } diff --git a/gtk2_ardour/trigger_ui.h b/gtk2_ardour/trigger_ui.h index 60c49aa4c5..30d4fbe631 100644 --- a/gtk2_ardour/trigger_ui.h +++ b/gtk2_ardour/trigger_ui.h @@ -36,7 +36,7 @@ namespace ArdourCanvas { class Rectangle; }; -class TriggerUI : public ArdourCanvas::Table +class TriggerUI : public ArdourCanvas::Table, public sigc::trackable { public: TriggerUI (ArdourCanvas::Item* parent, ARDOUR::Trigger&); @@ -73,7 +73,11 @@ class TriggerUI : public ArdourCanvas::Table ArdourCanvas::Rectangle* velocity; ArdourCanvas::Rectangle* velocity_text; - void trigger_changed (); + void trigger_changed (PBD::PropertyChange); + + bool follow_action_button_event (GdkEvent*); + + PBD::ScopedConnectionList trigger_connections; static std::string follow_action_to_string (ARDOUR::Trigger::FollowAction); static ARDOUR::Trigger::FollowAction string_to_follow_action (std::string const &);