triggerboxui: start connecting more widgets to trigger API

This commit is contained in:
Paul Davis 2021-09-28 17:45:58 -06:00
parent 542424e27d
commit b5c0f55831
2 changed files with 34 additions and 4 deletions

View File

@ -83,6 +83,7 @@ TriggerUI::TriggerUI (Item* parent, Trigger& t)
follow_action_button = new ArdourCanvas::Widget (canvas(), *_follow_action_button); follow_action_button = new ArdourCanvas::Widget (canvas(), *_follow_action_button);
follow_action_button->name = "FollowAction"; 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 = new ArdourDropdown;
_follow_left->append_text_item (_("None")); _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"))); set_fill_color (UIConfiguration::instance().color (X_("theme:bg")));
name = "triggerUI-table"; 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 () 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 std::string
TriggerUI::follow_action_to_string (Trigger::FollowAction fa) TriggerUI::follow_action_to_string (Trigger::FollowAction fa)
{ {
@ -149,8 +172,11 @@ TriggerUI::follow_action_to_string (Trigger::FollowAction fa)
} }
void 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_right->set_text (follow_action_to_string (trigger.follow_action (0)));
_follow_left->set_text (follow_action_to_string (trigger.follow_action (1))); _follow_left->set_text (follow_action_to_string (trigger.follow_action (1)));
} }

View File

@ -36,7 +36,7 @@ namespace ArdourCanvas {
class Rectangle; class Rectangle;
}; };
class TriggerUI : public ArdourCanvas::Table class TriggerUI : public ArdourCanvas::Table, public sigc::trackable
{ {
public: public:
TriggerUI (ArdourCanvas::Item* parent, ARDOUR::Trigger&); TriggerUI (ArdourCanvas::Item* parent, ARDOUR::Trigger&);
@ -73,7 +73,11 @@ class TriggerUI : public ArdourCanvas::Table
ArdourCanvas::Rectangle* velocity; ArdourCanvas::Rectangle* velocity;
ArdourCanvas::Rectangle* velocity_text; 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 std::string follow_action_to_string (ARDOUR::Trigger::FollowAction);
static ARDOUR::Trigger::FollowAction string_to_follow_action (std::string const &); static ARDOUR::Trigger::FollowAction string_to_follow_action (std::string const &);