From 40b483e71e1e087f361fc989147e06fb4c00e06e Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Fri, 11 Feb 2022 10:39:53 -0600 Subject: [PATCH] trigger_ui: move the patch-dialog to the properties area. * patch-dialog is now launched from a button and stays open * patch-dialog now tracks the current selection --- gtk2_ardour/slot_properties_box.cc | 34 +++++++++++++++++++++++++++++- gtk2_ardour/slot_properties_box.h | 9 ++++++++ gtk2_ardour/trigger_page.cc | 16 -------------- gtk2_ardour/trigger_page.h | 2 -- 4 files changed, 42 insertions(+), 19 deletions(-) diff --git a/gtk2_ardour/slot_properties_box.cc b/gtk2_ardour/slot_properties_box.cc index 8393aef03b..7a07db54f4 100644 --- a/gtk2_ardour/slot_properties_box.cc +++ b/gtk2_ardour/slot_properties_box.cc @@ -244,6 +244,10 @@ SlotPropertyTable::SlotPropertyTable () _follow_size_group->add_widget(_velocity_slider); _follow_size_group->add_widget(_follow_count_spinner); + _patch_button.set_text (_("MIDI Patches")); + _patch_button.set_name("FollowAction"); + _patch_button.signal_clicked.connect (sigc::mem_fun (*this, (&SlotPropertyTable::patch_button_event))); + set_spacings (8); //match to TriggerPage:: table->set_spacings set_border_width (0); //change TriggerPage:: table->set_border_width instead set_homogeneous (false); @@ -260,7 +264,8 @@ SlotPropertyTable::SlotPropertyTable () _trigger_table.attach(_color_label, 1, 2, row, row + 1, Gtk::FILL, Gtk::SHRINK); _trigger_table.attach(_color_button, 2, 3, row, row+1, Gtk::SHRINK, Gtk::SHRINK ); _trigger_table.attach(_gain_label, 3, 4, row, row + 1, Gtk::FILL, Gtk::SHRINK); - _trigger_table.attach(_gain_spinner, 4, 5, row, row + 1, Gtk::FILL, Gtk::SHRINK); + _trigger_table.attach(_gain_spinner, 4, 5, row, row + 1, Gtk::FILL, Gtk::SHRINK); row++; + _trigger_table.attach(_patch_button, 0, 5, row, row + 1, Gtk::FILL, Gtk::SHRINK); /* ---- Launch settings ----- */ @@ -373,6 +378,19 @@ SlotPropertyTable::set_quantize (BBT_Offset bbo) trigger()->set_quantization (bbo); } +void +SlotPropertyTable::patch_button_event () +{ + boost::shared_ptr trigr = trigger(); + if (boost::dynamic_pointer_cast (trigr)) { + SessionObject* obj = trigr->box ().owner (); + boost::shared_ptr stripable = obj->session().stripable_by_id (obj->id ()); + _patch_change_window.reset (boost::dynamic_pointer_cast (stripable), boost::dynamic_pointer_cast (trigr)); + _patch_change_window.present (); + } +} + + void SlotPropertyTable::follow_length_event () { @@ -515,6 +533,20 @@ SlotPropertyTable::set_follow_action (FollowAction const & fa, uint64_t idx) } } +void +SlotPropertyTable::on_trigger_set () +{ + boost::shared_ptr trigr = trigger(); + if (boost::dynamic_pointer_cast (trigr)) { + SessionObject* obj = triggerbox ().owner (); + boost::shared_ptr stripable = obj->session().stripable_by_id (obj->id ()); + _patch_change_window.reset (boost::dynamic_pointer_cast (stripable), boost::dynamic_pointer_cast (trigr)); + _patch_button.show(); + } else { + _patch_button.hide(); + } +} + void SlotPropertyTable::on_trigger_changed (PropertyChange const& pc) { diff --git a/gtk2_ardour/slot_properties_box.h b/gtk2_ardour/slot_properties_box.h index d2b1028d12..d8b8dfbbe3 100644 --- a/gtk2_ardour/slot_properties_box.h +++ b/gtk2_ardour/slot_properties_box.h @@ -36,6 +36,7 @@ #include "gtkmm2ext/cairo_packer.h" +#include "patch_change_widget.h" #include "trigger_ui.h" namespace ARDOUR { @@ -59,6 +60,8 @@ class SlotPropertyTable : public TriggerUI, public Gtk::Table SlotPropertyTable (); ~SlotPropertyTable (); + virtual void on_trigger_set (); + Glib::RefPtr _follow_size_group; ArdourWidgets::ArdourButton _color_button; @@ -77,6 +80,8 @@ class SlotPropertyTable : public TriggerUI, public Gtk::Table Gtk::SpinButton _gain_spinner; Gtk::Label _gain_label; + ArdourWidgets::ArdourButton _patch_button; + Gtk::Label _beat_label; Gtk::Label _follow_length_label; Gtk::Label _follow_count_label; @@ -129,8 +134,12 @@ class SlotPropertyTable : public TriggerUI, public Gtk::Table void probability_adjusted (); void velocity_adjusted (); + void patch_button_event (); + private: bool _ignore_changes; + + PatchChangeTriggerWindow _patch_change_window; }; class SlotPropertyWidget : public Gtk::VBox diff --git a/gtk2_ardour/trigger_page.cc b/gtk2_ardour/trigger_page.cc index ee8845fff3..aa220d5dbb 100644 --- a/gtk2_ardour/trigger_page.cc +++ b/gtk2_ardour/trigger_page.cc @@ -390,8 +390,6 @@ TriggerPage::selection_changed () _parameter_box.hide (); - bool hide_patch_selector = true; - if (!selection.triggers.empty ()) { TriggerSelection ts = selection.triggers; TriggerEntry* entry = *ts.begin (); @@ -410,20 +408,6 @@ TriggerPage::selection_changed () } } _parameter_box.show (); - - if (boost::dynamic_pointer_cast (trigger)) { - /* TODO @ben: only show optionally. checkbox? */ - hide_patch_selector = false; - SessionObject* obj = trigger->box ().owner (); - boost::shared_ptr stripable = _session->stripable_by_id (obj->id ()); - _patch_change_window.reset (boost::dynamic_pointer_cast (stripable), boost::dynamic_pointer_cast (trigger)); - _patch_change_window.present (); - } - } - - if (hide_patch_selector) { - _patch_change_window.hide (); - _patch_change_window.clear (); /* drop route/trigger ref */ } } diff --git a/gtk2_ardour/trigger_page.h b/gtk2_ardour/trigger_page.h index 1a0c66af51..8be4904dbc 100644 --- a/gtk2_ardour/trigger_page.h +++ b/gtk2_ardour/trigger_page.h @@ -38,7 +38,6 @@ #include "midi_region_operations_box.h" #include "midi_region_properties_box.h" #include "midi_trigger_properties_box.h" -#include "patch_change_widget.h" #include "route_processor_selection.h" #include "slot_properties_box.h" #include "trigger_clip_picker.h" @@ -138,7 +137,6 @@ private: MidiClipEditorBox _midi_trim_box; #endif - PatchChangeTriggerWindow _patch_change_window; RouteProcessorSelection _selection; std::list _strips; sigc::connection _fast_screen_update_connection;