From d933af6c81163166642f88aa7b8d31dbf994b4cb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 16 Dec 2021 15:15:14 -0700 Subject: [PATCH] attach triggerbox to triggerbox widget after construction --- gtk2_ardour/mixer_strip.cc | 3 ++- gtk2_ardour/trigger_strip.cc | 4 +++- gtk2_ardour/triggerbox_ui.cc | 26 +++++++++++++++----------- gtk2_ardour/triggerbox_ui.h | 4 +++- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 4bbb1f752d..9f21de02ce 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -2152,7 +2152,8 @@ void MixerStrip::create_trigger_display (boost::shared_ptr tb) { if (!trigger_display) { - trigger_display = new TriggerBoxWidget (*(tb.get()), -1., 8*16.); /* XXX fix to use shared ptr */ + trigger_display = new TriggerBoxWidget (-1., 8*16.); /* XXX fix to use shared ptr */ + trigger_display->set_triggerbox (tb.get()); } } diff --git a/gtk2_ardour/trigger_strip.cc b/gtk2_ardour/trigger_strip.cc index ac44795258..848749af13 100644 --- a/gtk2_ardour/trigger_strip.cc +++ b/gtk2_ardour/trigger_strip.cc @@ -63,13 +63,15 @@ TriggerStrip::TriggerStrip (Session* s, boost::shared_ptr rt) , _pb_selection () , _tmaster_widget (-1, 16) , _processor_box (s, boost::bind (&TriggerStrip::plugin_selector, this), _pb_selection, 0) - , _trigger_display (*rt->triggerbox (), -1., TriggerBox::default_triggers_per_box * 16.) + , _trigger_display (-1., TriggerBox::default_triggers_per_box * 16.) , _panners (s) , _level_meter (s) { init (); set_route (rt); + _trigger_display.set_triggerbox (rt->triggerbox ().get()); + io_changed (); name_changed (); map_frozen (); diff --git a/gtk2_ardour/triggerbox_ui.cc b/gtk2_ardour/triggerbox_ui.cc index f5c1ef9eb1..e4a266d292 100644 --- a/gtk2_ardour/triggerbox_ui.cc +++ b/gtk2_ardour/triggerbox_ui.cc @@ -944,24 +944,28 @@ TriggerBoxUI::rapid_update () } } -TriggerBoxWidget::TriggerBoxWidget (TriggerBox& tb, float w, float h) : FittedCanvasWidget(w,h) +TriggerBoxWidget::TriggerBoxWidget (float w, float h) : FittedCanvasWidget(w,h), ui (0) { - ui = new TriggerBoxUI (root(), tb); set_background_color (UIConfiguration::instance().color (X_("theme:bg"))); } void -TriggerBoxWidget::on_map () +TriggerBoxWidget::set_triggerbox (TriggerBox* tb) { - FittedCanvasWidget::on_map (); - ui->start_updating (); -} + if (ui) { + delete ui; + ui = 0; + } -void -TriggerBoxWidget::on_unmap () -{ - FittedCanvasWidget::on_unmap (); - ui->stop_updating (); + if (!tb) { + return; + } + + ui = new TriggerBoxUI (root(), *tb); + + if (is_mapped()) { + ui->start_updating (); + } } void diff --git a/gtk2_ardour/triggerbox_ui.h b/gtk2_ardour/triggerbox_ui.h index d6c257323b..9012203869 100644 --- a/gtk2_ardour/triggerbox_ui.h +++ b/gtk2_ardour/triggerbox_ui.h @@ -144,7 +144,9 @@ private: class TriggerBoxWidget : public FittedCanvasWidget { public: - TriggerBoxWidget (ARDOUR::TriggerBox& tb, float w, float h); + TriggerBoxWidget (float w, float h); + + void set_triggerbox (ARDOUR::TriggerBox* tb); void on_map (); void on_unmap ();