diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index 4e43c3c544..b89f8ae894 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -590,6 +590,9 @@ class LIBARDOUR_API TriggerBox : public Processor bool can_support_io_configuration (const ChanCount& in, ChanCount& out); bool configure_io (ChanCount in, ChanCount out); + bool empty() const { return _active_slots == 0; } + PBD::Signal0 EmptyStatusChanged; + int32_t order() const { return _order; } void set_order(int32_t n); @@ -690,6 +693,7 @@ class LIBARDOUR_API TriggerBox : public Processor Requests _requests; bool _stop_all; int32_t _active_scene; + int32_t _active_slots; boost::shared_ptr _sidechain; diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 68e0d16c54..cf358c2485 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -2124,6 +2124,7 @@ TriggerBox::TriggerBox (Session& s, DataType dt) , _currently_playing (0) , _stop_all (false) , _active_scene (-1) + , _active_slots (0) , requests (1024) { set_display_to_user (false); @@ -2220,14 +2221,29 @@ TriggerBox::maybe_swap_pending (uint32_t slot) */ Trigger* p = 0; + bool empty_changed = false; p = all_triggers[slot]->swap_pending (p); if (p) { if (p == Trigger::MagicClearPointerValue) { + if (all_triggers[slot]->region()) { + if (_active_slots) { + _active_slots--; + } + if (_active_slots == 0) { + empty_changed = true; + } + } all_triggers[slot]->clear_region (); } else { + if (!all_triggers[slot]->region()) { + if (_active_slots == 0) { + empty_changed = true; + } + _active_slots++; + } /* Note use of a custom delete function. We cannot delete the old trigger from the RT context where the trigger swap will happen, so we will ask the trigger @@ -2237,6 +2253,10 @@ TriggerBox::maybe_swap_pending (uint32_t slot) TriggerSwapped (slot); /* EMIT SIGNAL */ } } + + if (empty_changed) { + EmptyStatusChanged (); /* EMIT SIGNAL */ + } } void @@ -3157,6 +3177,7 @@ TriggerBox::set_state (const XMLNode& node, int version) all_triggers.push_back (trig); trig->set_state (**t, version); } + _active_slots++; } } @@ -3172,6 +3193,11 @@ TriggerBox::set_state (const XMLNode& node, int version) } } + /* Since _active_slots may have changed, we could consider sending + * EmptyStatusChanged, but for now we don't consider ::set_state() to + * be used except at session load. + */ + return 0; }