From c18823c0e010d9c065039c18eb36d0f110187727 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 24 Dec 2021 14:13:36 -0700 Subject: [PATCH] triggerbox: change entire UI side to avoid using TriggerPtr Lifetime management of Triggers is unlike anything(?) we've dealt with in Ardour so far. The parent object (Triggerbox) has a normal lifetime pattern, but Triggers can come and go in a way that few other objects do (although Processors and particularly PluginInsert are somewhat similar). We do not want the GUI to hold references to the actual Triggers, because the end of life of a Trigger is not really a signal for the GUI element to go away (the Trigger will be replaced in the slot). Consequently, we do not want TriggerPtr used as a member variable anywhere in the UI. Instead we use a TriggerReference which can "lookup" a Trigger on-demand (by box and slot number). The (G)UI now uses these exclusively. Work still needed to pick up trigger swap signals from the boxen. --- gtk2_ardour/audio_clip_editor.cc | 25 +++---- gtk2_ardour/audio_clip_editor.h | 12 ++-- gtk2_ardour/audio_trigger_properties_box.cc | 27 +++++--- gtk2_ardour/audio_trigger_properties_box.h | 6 +- gtk2_ardour/midi_clip_editor.cc | 2 +- gtk2_ardour/midi_clip_editor.h | 2 +- gtk2_ardour/midi_trigger_properties_box.cc | 7 +- gtk2_ardour/midi_trigger_properties_box.h | 2 +- gtk2_ardour/selection_properties_box.cc | 6 +- gtk2_ardour/slot_properties_box.cc | 4 +- gtk2_ardour/slot_properties_box.h | 2 +- gtk2_ardour/trigger_page.cc | 21 +++--- gtk2_ardour/trigger_ui.cc | 75 +++++++++++---------- gtk2_ardour/trigger_ui.h | 9 +-- gtk2_ardour/triggerbox_ui.cc | 6 +- gtk2_ardour/triggerbox_ui.h | 2 +- 16 files changed, 109 insertions(+), 99 deletions(-) diff --git a/gtk2_ardour/audio_clip_editor.cc b/gtk2_ardour/audio_clip_editor.cc index ab2789bf80..4f7b9621d5 100644 --- a/gtk2_ardour/audio_clip_editor.cc +++ b/gtk2_ardour/audio_clip_editor.cc @@ -86,6 +86,8 @@ ClipEditorBox::register_clip_editor_actions (Bindings* clip_editor_bindings) void AudioClipEditor::ClipBBTMetric::get_marks (std::vector& marks, int64_t lower, int64_t upper, int maxchars) const { + TriggerPtr trigger = tref.trigger(); + if (!trigger) { std::cerr << "No trigger\n"; return; @@ -118,7 +120,8 @@ AudioClipEditor::ClipBBTMetric::get_marks (std::vectorname = "Clip Editor"; ruler->set_font_description (UIConfiguration::instance ().get_SmallerFont ()); ruler->set_fill_color (UIConfiguration::instance().color (X_("theme:bg1"))); @@ -183,6 +180,7 @@ AudioClipEditor::AudioClipEditor () AudioClipEditor::~AudioClipEditor () { drop_waves (); + delete clip_metric; } bool @@ -399,12 +397,13 @@ AudioClipEditor::drop_waves () } void -AudioClipEditor::set_region (boost::shared_ptr r, TriggerPtr t) +AudioClipEditor::set_region (boost::shared_ptr r, TriggerReference tr) { drop_waves (); audio_region = r; - clip_metric->set_trigger (t); + delete clip_metric; + clip_metric = new ClipBBTMetric (tr); uint32_t n_chans = r->n_channels (); samplecnt_t len; @@ -431,6 +430,8 @@ AudioClipEditor::set_region (boost::shared_ptr r, TriggerPtr t) waves.push_back (wv); } + TriggerPtr t (tr.trigger()); + if (t) { if (t->apparent_tempo() == 0.) { /* tempo unknown, hide ruler */ @@ -592,7 +593,7 @@ AudioClipEditorBox::zoom_out_click () } void -AudioClipEditorBox::set_region (boost::shared_ptr r, TriggerPtr t) +AudioClipEditorBox::set_region (boost::shared_ptr r, TriggerReference tref) { boost::shared_ptr ar = boost::dynamic_pointer_cast (r); @@ -605,7 +606,7 @@ AudioClipEditorBox::set_region (boost::shared_ptr r, TriggerPtr t) state_connection.disconnect (); _region = r; - editor->set_region (ar, t); + editor->set_region (ar, tref); PBD::PropertyChange interesting_stuff; region_changed (interesting_stuff); diff --git a/gtk2_ardour/audio_clip_editor.h b/gtk2_ardour/audio_clip_editor.h index eb6cf1288c..6a9356fad5 100644 --- a/gtk2_ardour/audio_clip_editor.h +++ b/gtk2_ardour/audio_clip_editor.h @@ -70,7 +70,7 @@ public: ClipEditorBox () {} ~ClipEditorBox () {} - virtual void set_region (boost::shared_ptr, ARDOUR::TriggerPtr) = 0; + virtual void set_region (boost::shared_ptr, ARDOUR::TriggerReference) = 0; static void init (); static void register_clip_editor_actions (Gtkmm2ext::Bindings*); @@ -92,7 +92,7 @@ public: AudioClipEditor (); ~AudioClipEditor (); - void set_region (boost::shared_ptr, ARDOUR::TriggerPtr); + void set_region (boost::shared_ptr, ARDOUR::TriggerReference); void on_size_allocate (Gtk::Allocation&); double sample_to_pixel (ARDOUR::samplepos_t); @@ -121,16 +121,14 @@ private: class ClipBBTMetric : public ArdourCanvas::Ruler::Metric { public: - ClipBBTMetric() : trigger (0) { + ClipBBTMetric (ARDOUR::TriggerReference tr) : tref (tr) { units_per_pixel = 1; } - void set_trigger (ARDOUR::TriggerPtr t) { trigger = t; } - void get_marks (std::vector& marks, int64_t lower, int64_t upper, int maxchars) const; private: - ARDOUR::TriggerPtr trigger; + ARDOUR::TriggerReference tref; }; @@ -203,7 +201,7 @@ public: AudioClipEditorBox (); ~AudioClipEditorBox (); - void set_region (boost::shared_ptr, ARDOUR::TriggerPtr); + void set_region (boost::shared_ptr, ARDOUR::TriggerReference); void region_changed (const PBD::PropertyChange& what_changed); private: diff --git a/gtk2_ardour/audio_trigger_properties_box.cc b/gtk2_ardour/audio_trigger_properties_box.cc index e273929657..1ad20a968e 100644 --- a/gtk2_ardour/audio_trigger_properties_box.cc +++ b/gtk2_ardour/audio_trigger_properties_box.cc @@ -155,7 +155,10 @@ AudioTriggerPropertiesBox::~AudioTriggerPropertiesBox () void AudioTriggerPropertiesBox::toggle_stretch () { - _trigger->set_stretchable (!_trigger->stretchable ()); + TriggerPtr trigger (tref.trigger()); + if (trigger) { + trigger->set_stretchable (!trigger->stretchable ()); + } } void @@ -168,16 +171,16 @@ AudioTriggerPropertiesBox::set_session (Session* s) } void -AudioTriggerPropertiesBox::set_trigger (ARDOUR::TriggerPtr t) +AudioTriggerPropertiesBox::set_trigger (ARDOUR::TriggerReference tr) { - boost::shared_ptr audio_trigger = boost::dynamic_pointer_cast (t); + boost::shared_ptr audio_trigger = boost::dynamic_pointer_cast (tr.trigger()); if (!audio_trigger) { return; } - _trigger = audio_trigger; - _trigger->PropertyChanged.connect (_state_connection, invalidator (*this), boost::bind (&AudioTriggerPropertiesBox::trigger_changed, this, _1), gui_context ()); + tref = tr; + tref.trigger()->PropertyChanged.connect (_state_connection, invalidator (*this), boost::bind (&AudioTriggerPropertiesBox::trigger_changed, this, _1), gui_context ()); PBD::PropertyChange changed; changed.add (ARDOUR::Properties::name); @@ -188,17 +191,19 @@ AudioTriggerPropertiesBox::set_trigger (ARDOUR::TriggerPtr t) void AudioTriggerPropertiesBox::trigger_changed (const PBD::PropertyChange& what_changed) { - AudioClock::Mode mode = _trigger->box ().data_type () == ARDOUR::DataType::AUDIO ? AudioClock::Samples : AudioClock::BBT; + TriggerPtr trigger (tref.trigger()); + + AudioClock::Mode mode = trigger->box ().data_type () == ARDOUR::DataType::AUDIO ? AudioClock::Samples : AudioClock::BBT; _start_clock.set_mode (mode); _length_clock.set_mode (mode); - _start_clock.set (_trigger->start_offset ()); - _length_clock.set (_trigger->current_length ()); // set_duration() ? + _start_clock.set (tref.trigger()->start_offset ()); + _length_clock.set (tref.trigger()->current_length ()); // set_duration() ? - _bpm_button.set_text (string_compose ("%1", _trigger->apparent_tempo ())); - _abpm_label.set_text (string_compose ("%1", _trigger->apparent_tempo ())); + _bpm_button.set_text (string_compose ("%1", trigger->apparent_tempo ())); + _abpm_label.set_text (string_compose ("%1", trigger->apparent_tempo ())); _metrum_button.set_text ("4/4"); - _stretch_toggle.set_active (_trigger->stretchable () ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off); + _stretch_toggle.set_active (tref.trigger()->stretchable () ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off); } diff --git a/gtk2_ardour/audio_trigger_properties_box.h b/gtk2_ardour/audio_trigger_properties_box.h index b63a336034..11956ac6e4 100644 --- a/gtk2_ardour/audio_trigger_properties_box.h +++ b/gtk2_ardour/audio_trigger_properties_box.h @@ -37,7 +37,7 @@ public: TriggerPropertiesBox () {} ~TriggerPropertiesBox () {} - virtual void set_trigger (ARDOUR::TriggerPtr) = 0; + virtual void set_trigger (ARDOUR::TriggerReference) = 0; }; class AudioTriggerPropertiesBox : public TriggerPropertiesBox @@ -46,7 +46,7 @@ public: AudioTriggerPropertiesBox (); ~AudioTriggerPropertiesBox (); - void set_trigger (ARDOUR::TriggerPtr); + void set_trigger (ARDOUR::TriggerReference); void set_session (ARDOUR::Session*); @@ -58,7 +58,7 @@ protected: Gtk::Label _header_label; private: - boost::shared_ptr _trigger; + ARDOUR::TriggerReference tref; Gtk::Table _table; Gtk::Label _abpm_label; diff --git a/gtk2_ardour/midi_clip_editor.cc b/gtk2_ardour/midi_clip_editor.cc index 896de6d3a4..5292396a7f 100644 --- a/gtk2_ardour/midi_clip_editor.cc +++ b/gtk2_ardour/midi_clip_editor.cc @@ -113,7 +113,7 @@ MidiClipEditorBox::set_session (Session* s) } void -MidiClipEditorBox::set_region (boost::shared_ptr r, TriggerPtr t) +MidiClipEditorBox::set_region (boost::shared_ptr r, TriggerReference /*notused*/) { set_session (&r->session ()); diff --git a/gtk2_ardour/midi_clip_editor.h b/gtk2_ardour/midi_clip_editor.h index 3338783b0e..eec4aeeb55 100644 --- a/gtk2_ardour/midi_clip_editor.h +++ b/gtk2_ardour/midi_clip_editor.h @@ -69,7 +69,7 @@ public: void set_session (ARDOUR::Session*); - void set_region (boost::shared_ptr, ARDOUR::TriggerPtr); + void set_region (boost::shared_ptr, ARDOUR::TriggerReference); void region_changed (const PBD::PropertyChange& what_changed); private: diff --git a/gtk2_ardour/midi_trigger_properties_box.cc b/gtk2_ardour/midi_trigger_properties_box.cc index 3fe3234209..b5122ded74 100644 --- a/gtk2_ardour/midi_trigger_properties_box.cc +++ b/gtk2_ardour/midi_trigger_properties_box.cc @@ -79,16 +79,15 @@ MidiTriggerPropertiesBox::~MidiTriggerPropertiesBox () } void -MidiTriggerPropertiesBox::set_trigger (ARDOUR::TriggerPtr t) +MidiTriggerPropertiesBox::set_trigger (ARDOUR::TriggerReference tref) { - boost::shared_ptr midi_trigger = boost::dynamic_pointer_cast (t); + boost::shared_ptr midi_trigger = boost::dynamic_pointer_cast (tref.trigger()); if (!midi_trigger) { return; } - _trigger = midi_trigger; - _trigger->PropertyChanged.connect (_midi_state_connection, invalidator (*this), boost::bind (&MidiTriggerPropertiesBox::trigger_changed, this, _1), gui_context ()); + tref.trigger()->PropertyChanged.connect (_midi_state_connection, invalidator (*this), boost::bind (&MidiTriggerPropertiesBox::trigger_changed, this, _1), gui_context ()); PBD::PropertyChange changed; changed.add (ARDOUR::Properties::name); diff --git a/gtk2_ardour/midi_trigger_properties_box.h b/gtk2_ardour/midi_trigger_properties_box.h index 375ff76af6..600aaf40c5 100644 --- a/gtk2_ardour/midi_trigger_properties_box.h +++ b/gtk2_ardour/midi_trigger_properties_box.h @@ -32,7 +32,7 @@ public: MidiTriggerPropertiesBox (); ~MidiTriggerPropertiesBox (); - void set_trigger (ARDOUR::TriggerPtr); + void set_trigger (ARDOUR::TriggerReference); private: void trigger_changed (const PBD::PropertyChange& what_changed); diff --git a/gtk2_ardour/selection_properties_box.cc b/gtk2_ardour/selection_properties_box.cc index 49cbe5587c..f5032e97df 100644 --- a/gtk2_ardour/selection_properties_box.cc +++ b/gtk2_ardour/selection_properties_box.cc @@ -209,13 +209,13 @@ SelectionPropertiesBox::selection_changed () if (!selection.triggers.empty()) { TriggerSelection ts = selection.triggers; TriggerEntry* entry = *ts.begin(); - TriggerPtr slot = entry->trigger(); + TriggerReference ref = entry->trigger_reference(); //slot properties incl "Follow Actions" - _slot_prop_box->set_slot(slot); + _slot_prop_box->set_slot(ref); _slot_prop_box->show(); - selected_region = slot->region(); + selected_region = ref.trigger()->region(); } else if (selection.regions.size()==1) { selected_region = (*(selection.regions.begin()))->region(); } diff --git a/gtk2_ardour/slot_properties_box.cc b/gtk2_ardour/slot_properties_box.cc index 6937798414..b05831eda3 100644 --- a/gtk2_ardour/slot_properties_box.cc +++ b/gtk2_ardour/slot_properties_box.cc @@ -74,7 +74,7 @@ SlotPropertiesBox::set_session (Session* s) } void -SlotPropertiesBox::set_slot (TriggerPtr t) +SlotPropertiesBox::set_slot (TriggerReference tref) { - _triggerwidget->set_trigger (t); + _triggerwidget->set_trigger (tref); } diff --git a/gtk2_ardour/slot_properties_box.h b/gtk2_ardour/slot_properties_box.h index 0c6b1df503..eab89fcef7 100644 --- a/gtk2_ardour/slot_properties_box.h +++ b/gtk2_ardour/slot_properties_box.h @@ -48,7 +48,7 @@ public: void set_session (ARDOUR::Session*); - void set_slot (ARDOUR::TriggerPtr); + void set_slot (ARDOUR::TriggerReference); private: Gtk::Table table; diff --git a/gtk2_ardour/trigger_page.cc b/gtk2_ardour/trigger_page.cc index 0e4786beaf..71ce7f2512 100644 --- a/gtk2_ardour/trigger_page.cc +++ b/gtk2_ardour/trigger_page.cc @@ -346,23 +346,24 @@ TriggerPage::selection_changed () _parameter_box.hide (); if (!selection.triggers.empty ()) { - TriggerSelection ts = selection.triggers; - TriggerEntry* entry = *ts.begin (); - TriggerPtr slot = entry->trigger (); + TriggerSelection ts = selection.triggers; + TriggerEntry* entry = *ts.begin (); + TriggerReference ref = entry->trigger_reference (); + TriggerPtr trigger = entry->trigger (); - _slot_prop_box.set_slot (slot); + _slot_prop_box.set_slot (ref); _slot_prop_box.show (); - if (slot->region ()) { - if (slot->region ()->data_type () == DataType::AUDIO) { - _audio_trig_box.set_trigger (slot); - _audio_trim_box.set_region (slot->region (), slot); + if (trigger->region ()) { + if (trigger->region ()->data_type () == DataType::AUDIO) { + _audio_trig_box.set_trigger (ref); + _audio_trim_box.set_region (trigger->region (), ref); _audio_trig_box.show (); _audio_trim_box.show (); _audio_ops_box.show (); } else { - _midi_trig_box.set_trigger (slot); - _midi_trim_box.set_region (slot->region (), slot); + _midi_trig_box.set_trigger (ref); + _midi_trim_box.set_region (trigger->region (), ref); _midi_trig_box.show (); _midi_trim_box.show (); diff --git a/gtk2_ardour/trigger_ui.cc b/gtk2_ardour/trigger_ui.cc index 47face25f9..1929747443 100644 --- a/gtk2_ardour/trigger_ui.cc +++ b/gtk2_ardour/trigger_ui.cc @@ -63,8 +63,8 @@ static std::string longest_quantize; static std::vector launch_strings; static std::string longest_launch; -TriggerUI::TriggerUI () : - _follow_action_button (ArdourButton::led_default_elements) +TriggerUI::TriggerUI () + : _follow_action_button (ArdourButton::led_default_elements) , _velocity_adjustment(1.,0.,1.0,0.01,0.1) , _velocity_slider (&_velocity_adjustment, boost::shared_ptr(), 24/*length*/, 12/*girth*/ ) , _follow_probability_adjustment(0,0,100,2,5) @@ -74,8 +74,6 @@ TriggerUI::TriggerUI () : , _legato_button (ArdourButton::led_default_elements) { - trigger = NULL; - using namespace Gtk::Menu_Helpers; if (follow_strings.empty()) { @@ -228,10 +226,16 @@ TriggerUI::~TriggerUI () { } -void -TriggerUI::set_trigger (ARDOUR::TriggerPtr t) +TriggerPtr +TriggerUI::trigger() const { - trigger = t; + return tref.trigger(); +} + +void +TriggerUI::set_trigger (ARDOUR::TriggerReference tr) +{ + tref = tr; PropertyChange pc; @@ -247,7 +251,7 @@ TriggerUI::set_trigger (ARDOUR::TriggerPtr t) trigger_changed (pc); - trigger->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context()); + trigger()->PropertyChanged.connect (trigger_connections, invalidator (*this), boost::bind (&TriggerUI::trigger_changed, this, _1), gui_context()); } @@ -261,25 +265,25 @@ TriggerUI::set_quantize (BBT_Offset bbo) } #endif - trigger->set_quantization (bbo); + trigger()->set_quantization (bbo); } void TriggerUI::follow_count_event () { - trigger->set_follow_count ((int) _follow_count_adjustment.get_value()); + trigger()->set_follow_count ((int) _follow_count_adjustment.get_value()); } void TriggerUI::velocity_adjusted () { - trigger->set_midi_velocity_effect (_velocity_adjustment.get_value()); + trigger()->set_midi_velocity_effect (_velocity_adjustment.get_value()); } void TriggerUI::probability_adjusted () { - trigger->set_follow_action_probability ((int) _follow_probability_adjustment.get_value()); + trigger()->set_follow_action_probability ((int) _follow_probability_adjustment.get_value()); } bool @@ -287,7 +291,7 @@ TriggerUI::follow_action_button_event (GdkEvent* ev) { switch (ev->type) { case GDK_BUTTON_PRESS: - trigger->set_use_follow (!trigger->use_follow()); + trigger()->set_use_follow (!trigger()->use_follow()); return true; default: @@ -302,7 +306,7 @@ TriggerUI::legato_button_event (GdkEvent* ev) { switch (ev->type) { case GDK_BUTTON_PRESS: - trigger->set_legato (!trigger->legato()); + trigger()->set_legato (!trigger()->legato()); return true; default: @@ -315,7 +319,7 @@ TriggerUI::legato_button_event (GdkEvent* ev) void TriggerUI::set_launch_style (Trigger::LaunchStyle ls) { - trigger->set_launch_style (ls); + trigger()->set_launch_style (ls); } void @@ -398,46 +402,46 @@ void TriggerUI::trigger_changed (PropertyChange pc) { if (pc.contains (Properties::quantization)) { - BBT_Offset bbo (trigger->quantization()); + BBT_Offset bbo (trigger()->quantization()); _quantize_button.set_active (quantize_length_to_string (bbo)); } if (pc.contains (Properties::use_follow)) { - _follow_action_button.set_active_state (trigger->use_follow() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off); + _follow_action_button.set_active_state (trigger()->use_follow() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off); } if (pc.contains (Properties::follow_count)) { - _follow_count_adjustment.set_value (trigger->follow_count()); + _follow_count_adjustment.set_value (trigger()->follow_count()); } if (pc.contains (Properties::legato)) { - _legato_button.set_active_state (trigger->legato() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off); + _legato_button.set_active_state (trigger()->legato() ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off); } if (pc.contains (Properties::launch_style)) { - _launch_style_button.set_active (launch_style_to_string (trigger->launch_style())); + _launch_style_button.set_active (launch_style_to_string (trigger()->launch_style())); } if (pc.contains (Properties::follow_action0)) { - _follow_left.set_text (follow_action_to_string (trigger->follow_action (0))); + _follow_left.set_text (follow_action_to_string (trigger()->follow_action (0))); } if (pc.contains (Properties::follow_action1)) { - _follow_right.set_text (follow_action_to_string (trigger->follow_action (1))); + _follow_right.set_text (follow_action_to_string (trigger()->follow_action (1))); } if (pc.contains (Properties::velocity_effect)) { - _velocity_adjustment.set_value (trigger->midi_velocity_effect()); + _velocity_adjustment.set_value (trigger()->midi_velocity_effect()); } if (pc.contains (Properties::follow_action_probability)) { - int pval = trigger->follow_action_probability(); + int pval = trigger()->follow_action_probability(); _follow_probability_adjustment.set_value (pval); _left_probability_label.set_text (string_compose(_("%1%% Left"), pval)); _right_probability_label.set_text (string_compose(_("%1%% Right"), 100-pval)); } - if (trigger->use_follow()) { + if (trigger()->use_follow()) { _follow_left.set_sensitive(true); _follow_right.set_sensitive(true); _follow_count_spinner.set_sensitive(true); @@ -466,13 +470,14 @@ TriggerWidget::TriggerWidget () /* ------------ */ -TriggerWindow::TriggerWindow (TriggerPtr slot) +TriggerWindow::TriggerWindow (TriggerReference tref) { - set_title (string_compose (_("Trigger: %1"), slot->name())); + TriggerPtr trigger (tref.trigger()); + + set_title (string_compose (_("Trigger: %1"), trigger->name())); SlotPropertiesBox* slot_prop_box = manage (new SlotPropertiesBox ()); - slot_prop_box->set_slot(slot); - + slot_prop_box->set_slot (tref); Gtk::Table* table = manage (new Gtk::Table); table->set_homogeneous (false); @@ -482,23 +487,23 @@ TriggerWindow::TriggerWindow (TriggerPtr slot) int col = 0; table->attach(*slot_prop_box, col, col+1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); col++; - if (slot->region()) { - if (slot->region()->data_type() == DataType::AUDIO) { + if (trigger->region()) { + if (trigger->region()->data_type() == DataType::AUDIO) { _trig_box = manage(new AudioTriggerPropertiesBox ()); _ops_box = manage(new AudioRegionOperationsBox ()); _trim_box = manage(new AudioClipEditorBox ()); - _trig_box->set_trigger(slot); + _trig_box->set_trigger (tref); } else { _trig_box = manage(new MidiTriggerPropertiesBox ()); _ops_box = manage(new MidiRegionOperationsBox ()); _trim_box = manage(new MidiClipEditorBox ()); - _trig_box->set_trigger(slot); + _trig_box->set_trigger (tref); } - _trim_box->set_region(slot->region(), slot); - _ops_box->set_session(&slot->region()->session()); + _trim_box->set_region(trigger->region(), tref); + _ops_box->set_session(&trigger->region()->session()); table->attach(*_trig_box, col, col+1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); col++; table->attach(*_trim_box, col, col+1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); col++; diff --git a/gtk2_ardour/trigger_ui.h b/gtk2_ardour/trigger_ui.h index c87546c3ad..70289d2575 100644 --- a/gtk2_ardour/trigger_ui.h +++ b/gtk2_ardour/trigger_ui.h @@ -39,7 +39,7 @@ class TriggerUI : public Gtk::Table //, public sigc::trackable TriggerUI (); ~TriggerUI (); - void set_trigger (ARDOUR::TriggerPtr); + void set_trigger (ARDOUR::TriggerReference); static std::string follow_action_to_string (ARDOUR::Trigger::FollowAction); static ARDOUR::Trigger::FollowAction string_to_follow_action (std::string const &); @@ -47,7 +47,8 @@ class TriggerUI : public Gtk::Table //, public sigc::trackable static std::string launch_style_to_string (ARDOUR::Trigger::LaunchStyle); private: - ARDOUR::TriggerPtr trigger; + ARDOUR::TriggerReference tref; + ARDOUR::TriggerPtr trigger() const; ArdourWidgets::ArdourButton _follow_action_button; @@ -91,7 +92,7 @@ class TriggerWidget : public Gtk::VBox { public: TriggerWidget (); - void set_trigger (ARDOUR::TriggerPtr t) const {ui->set_trigger(t);} + void set_trigger (ARDOUR::TriggerReference tr) const { ui->set_trigger(tr); } private: TriggerUI* ui; @@ -102,7 +103,7 @@ class TriggerWidget : public Gtk::VBox class TriggerWindow : public Gtk::Window { public: - TriggerWindow (ARDOUR::TriggerPtr); + TriggerWindow (ARDOUR::TriggerReference); bool on_key_press_event (GdkEventKey*); bool on_key_release_event (GdkEventKey*); diff --git a/gtk2_ardour/triggerbox_ui.cc b/gtk2_ardour/triggerbox_ui.cc index c0c6fb508c..8cdfd1e428 100644 --- a/gtk2_ardour/triggerbox_ui.cc +++ b/gtk2_ardour/triggerbox_ui.cc @@ -92,8 +92,8 @@ TriggerEntry::TriggerEntry (Item* item, TriggerReference tr) set_default_colors (); trigger()->PropertyChanged.connect (trigger_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::prop_change, this, _1), gui_context ()); - tref.box.TriggerSwapped.connect (trigger_swap_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::trigger_swap, this, _1), gui_context ()); - dynamic_cast (tref.box.owner ())->presentation_info ().Change.connect (owner_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::owner_prop_change, this, _1), gui_context ()); + tref.box->TriggerSwapped.connect (trigger_swap_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::trigger_swap, this, _1), gui_context ()); + dynamic_cast (tref.box->owner ())->presentation_info ().Change.connect (owner_prop_connection, MISSING_INVALIDATOR, boost::bind (&TriggerEntry::owner_prop_change, this, _1), gui_context ()); PropertyChange changed; changed.add (ARDOUR::Properties::name); @@ -966,7 +966,7 @@ TriggerBoxUI::edit_trigger (uint64_t n) TriggerWindow* tw = static_cast (trigger->ui ()); if (!tw) { - tw = new TriggerWindow (_triggerbox.trigger (n)); + tw = new TriggerWindow (TriggerReference (_triggerbox, n)); trigger->set_ui (tw); } diff --git a/gtk2_ardour/triggerbox_ui.h b/gtk2_ardour/triggerbox_ui.h index fcc954b966..42e2ac9ab7 100644 --- a/gtk2_ardour/triggerbox_ui.h +++ b/gtk2_ardour/triggerbox_ui.h @@ -75,7 +75,7 @@ public: void set_default_colors (); private: - TriggerReference tref; + ARDOUR::TriggerReference tref; double _poly_size; double _poly_margin;