Migrate PC dialog to RouteUI, midnam handing to RTAV.
authorRobin Gareus <robin@gareus.org>
Sat, 9 Sep 2017 16:25:36 +0000 (18:25 +0200)
committerRobin Gareus <robin@gareus.org>
Sat, 9 Sep 2017 16:25:36 +0000 (18:25 +0200)
This allows to to bring up the PC dialog from Editor/Editor-Mixer & Mixer
for both MIDI Tracks as well as MIDI Busses.

gtk2_ardour/midi_time_axis.cc
gtk2_ardour/midi_time_axis.h
gtk2_ardour/mixer_strip.cc
gtk2_ardour/route_time_axis.cc
gtk2_ardour/route_time_axis.h
gtk2_ardour/route_ui.cc
gtk2_ardour/route_ui.h

index c8476dc83e5ea0dc0014e77299168924bcac8b0e..91cf2b954446a179b663cf836a1315e891e6372a 100644 (file)
@@ -123,7 +123,6 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session* sess, ArdourCanva
        , controller_menu (0)
        , poly_pressure_menu (0)
        , _step_editor (0)
-       , _patch_change_dialog (0)
 {
        _midnam_model_selector.disable_scrolling();
        _midnam_custom_device_mode_selector.disable_scrolling();
@@ -193,10 +192,6 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
        update_control_names();
        processors_changed (RouteProcessorChange ());
 
-       _route->processors_changed.connect (*this, invalidator (*this),
-                                           boost::bind (&MidiTimeAxisView::processors_changed, this, _1),
-                                           gui_context());
-
        if (is_track()) {
                _piano_roll_header->SetNoteSelection.connect (
                        sigc::mem_fun (*this, &MidiTimeAxisView::set_note_selection));
@@ -347,9 +342,6 @@ MidiTimeAxisView::~MidiTimeAxisView ()
 
        delete controller_menu;
        delete _step_editor;
-
-       delete  _patch_change_dialog;
-       _patch_change_dialog = 0;
 }
 
 void
@@ -391,11 +383,6 @@ MidiTimeAxisView::setup_midnam_patches ()
        }
 }
 
-void
-MidiTimeAxisView::drop_instrument_ref ()
-{
-       midnam_connection.drop_connections ();
-}
 void
 MidiTimeAxisView::start_scroomer_update ()
 {
@@ -417,18 +404,8 @@ MidiTimeAxisView::update_patch_selector ()
 
        bool pluginprovided = false;
        if (_route) {
-               boost::shared_ptr<Processor> the_instrument (_route->the_instrument());
-               boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(the_instrument);
+               boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_route->the_instrument ());
                if (pi && pi->plugin ()->has_midnam ()) {
-                       midnam_connection.drop_connections ();
-                       the_instrument->DropReferences.connect (midnam_connection, invalidator (*this),
-                                       boost::bind (&MidiTimeAxisView::drop_instrument_ref, this),
-                                       gui_context());
-                       pi->plugin()->UpdateMidnam.connect (midnam_connection, invalidator (*this),
-                                       boost::bind (&MidiTimeAxisView::reread_midnam, this),
-                                       gui_context());
-                       reread_midnam ();
-
                        pluginprovided = true;
                        std::string model_name = pi->plugin ()->midnam_model ();
                        if (gui_property (X_("midnam-model-name")) != model_name) {
@@ -446,17 +423,7 @@ MidiTimeAxisView::update_patch_selector ()
        }
 }
 
-void
-MidiTimeAxisView::reread_midnam ()
-{
-       boost::shared_ptr<Processor> the_instrument (_route->the_instrument());
-       boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(the_instrument);
-       bool rv = pi->plugin ()->read_midnam();
 
-       if (rv && _patch_change_dialog) {
-               _patch_change_dialog->refresh ();
-       }
-}
 void
 MidiTimeAxisView::model_changed(const std::string& model)
 {
@@ -499,8 +466,8 @@ MidiTimeAxisView::model_changed(const std::string& model)
        controller_menu = 0;
        build_automation_action_menu(false);
 
-       if (_patch_change_dialog) {
-               _patch_change_dialog->refresh ();
+       if (patch_change_dialog ()) {
+               patch_change_dialog ()->refresh ();
        }
 }
 
@@ -581,7 +548,7 @@ MidiTimeAxisView::append_extra_display_menu_items ()
                                   sigc::mem_fun(*this, &MidiTimeAxisView::toggle_channel_selector)));
 
        items.push_back (MenuElem (_("Patch Selector..."),
-                               sigc::mem_fun(*this, &MidiTimeAxisView::send_patch_change)));
+                               sigc::mem_fun(*this, &RouteUI::select_midi_patch)));
 
        color_mode_menu = build_color_mode_menu();
        if (color_mode_menu) {
@@ -1098,22 +1065,6 @@ MidiTimeAxisView::build_color_mode_menu()
        return mode_menu;
 }
 
-void
-MidiTimeAxisView::send_patch_change ()
-{
-       if (!_route) {
-               return;
-       }
-       if (_patch_change_dialog) {
-               _patch_change_dialog->present ();
-               return;
-       }
-
-       PatchChangeGridDialog* d = new PatchChangeGridDialog (_route);
-       _patch_change_dialog = d;
-       d->present ();
-}
-
 void
 MidiTimeAxisView::set_note_mode(NoteMode mode, bool apply_to_selection)
 {
index faa0e723e8902513477b0131f19b899fcb8f4774..cbfc816c27e539c317e64e7c07a9cb7dc84b6d91 100644 (file)
@@ -67,7 +67,6 @@ class PianoRollHeader;
 class StepEntry;
 class StepEditor;
 class MidiChannelSelectorWindow;
-class PatchChangeGridDialog;
 
 #define NO_MIDI_NOTE 0xff
 
@@ -121,9 +120,6 @@ private:
 
        void setup_midnam_patches ();
        void update_patch_selector ();
-       void drop_instrument_ref ();
-       void reread_midnam ();
-       PBD::ScopedConnectionList midnam_connection;
 
        void start_scroomer_update ();
        void stop_scroomer_update ();
@@ -140,8 +136,6 @@ private:
        void set_note_mode (ARDOUR::NoteMode mode, bool apply_to_selection = false);
        void set_color_mode (ARDOUR::ColorMode, bool force = false, bool redisplay = true, bool apply_to_selection = false);
        void set_note_range (MidiStreamView::VisibleNoteRange range, bool apply_to_selection = false);
-       void send_patch_change ();
-
        void route_active_changed ();
        void note_range_changed ();
        void contents_height_changed ();
@@ -200,8 +194,6 @@ private:
        StepEditor* _step_editor;
 
        void immediate_patch_chnage_response (int response);
-       PatchChangeGridDialog* _patch_change_dialog;
-
 };
 
 #endif /* __ardour_midi_time_axis_h__ */
index 21d6a5007fdc0bcac2aafa356172db4d3371f15d..6d127262b3a14a4e76daeca8dc7ad0a1bea6c340 100644 (file)
@@ -1738,6 +1738,11 @@ MixerStrip::build_route_ops_menu ()
                items.push_back (MenuElem (_("Pin Connections..."), sigc::mem_fun (*this, &RouteUI::manage_pins)));
        }
 
+       if (boost::dynamic_pointer_cast<MidiTrack>(_route) || _route->the_instrument ()) {
+               items.push_back (MenuElem (_("Patch Selector..."),
+                                       sigc::mem_fun(*this, &RouteUI::select_midi_patch)));
+       }
+
        if (_route->the_instrument () && _route->the_instrument ()->output_streams().n_audio() > 2) {
                // TODO ..->n_audio() > 1 && separate_output_groups) hard to check here every time.
                items.push_back (MenuElem (_("Fan out to Busses"), sigc::bind (sigc::mem_fun (*this, &RouteUI::fan_out), true, true)));
index 0f7ef1b8f79ff72d904032fb781d6030a73814ea..e1a7fb9f0322de1466957eec7da3d2b251ff1c0e 100644 (file)
@@ -46,6 +46,7 @@
 #include "ardour/event_type_map.h"
 #include "ardour/pannable.h"
 #include "ardour/panner.h"
+#include "ardour/plugin_insert.h"
 #include "ardour/processor.h"
 #include "ardour/profile.h"
 #include "ardour/route_group.h"
@@ -73,6 +74,7 @@
 #include "item_counts.h"
 #include "keyboard.h"
 #include "paste_context.h"
+#include "patch_change_widget.h"
 #include "playlist_selector.h"
 #include "point_selection.h"
 #include "public_editor.h"
@@ -795,6 +797,13 @@ RouteTimeAxisView::build_display_menu ()
                items.back().set_sensitive (_editor.get_selection().tracks.size() <= 1);
        }
 
+       if (!is_midi_track () && _route->the_instrument ()) {
+               /* MIDI Bus */
+               items.push_back (MenuElem (_("Patch Selector..."),
+                                       sigc::mem_fun(*this, &RouteUI::select_midi_patch)));
+               items.push_back (SeparatorElem());
+       }
+
        route_group_menu->detach ();
 
        WeakRouteList r;
@@ -2189,9 +2198,43 @@ RouteTimeAxisView::processor_menu_item_toggled (RouteTimeAxisView::ProcessorAuto
        }
 }
 
+void
+RouteTimeAxisView::reread_midnam ()
+{
+       boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_route->the_instrument ());
+       assert (pi);
+       bool rv = pi->plugin ()->read_midnam();
+
+       if (rv && patch_change_dialog ()) {
+               patch_change_dialog ()->refresh ();
+       }
+}
+
+void
+RouteTimeAxisView::drop_instrument_ref ()
+{
+       midnam_connection.drop_connections ();
+}
+
 void
 RouteTimeAxisView::processors_changed (RouteProcessorChange c)
 {
+       if (_route) {
+               boost::shared_ptr<Processor> the_instrument (_route->the_instrument());
+               boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (the_instrument);
+               if (pi && pi->plugin ()->has_midnam ()) {
+                       midnam_connection.drop_connections ();
+                       the_instrument->DropReferences.connect (midnam_connection, invalidator (*this),
+                                       boost::bind (&RouteTimeAxisView::drop_instrument_ref, this),
+                                       gui_context());
+                       pi->plugin()->UpdateMidnam.connect (midnam_connection, invalidator (*this),
+                                       boost::bind (&RouteTimeAxisView::reread_midnam, this),
+                                       gui_context());
+
+                       reread_midnam ();
+               }
+       }
+
        if (c.type == RouteProcessorChange::MeterPointChange) {
                /* nothing to do if only the meter point has changed */
                return;
index 84c5469d9390684cc6f8bcb8bfdf45b36a18a620..3868dfebd18f9a878e7bfd387be5298d2d422ecb 100644 (file)
@@ -176,7 +176,7 @@ protected:
 
        bool route_group_click  (GdkEventButton *);
 
-       void processors_changed (ARDOUR::RouteProcessorChange);
+       virtual void processors_changed (ARDOUR::RouteProcessorChange);
 
        virtual void add_processor_to_subplugin_menu (boost::weak_ptr<ARDOUR::Processor>);
        void remove_processor_automation_node (ProcessorAutomationNode* pan);
@@ -306,6 +306,10 @@ private:
        void update_playlist_tip ();
        void parameter_changed (std::string const & p);
        void update_track_number_visibility();
+
+       void drop_instrument_ref ();
+       void reread_midnam ();
+       PBD::ScopedConnectionList midnam_connection;
 };
 
 #endif /* __ardour_route_time_axis_h__ */
index 9d6a295578a00012f38733f65d328d910b9811f8..6eca450f17bff5296794303b3459985723e76538 100644 (file)
@@ -66,6 +66,7 @@
 #include "keyboard.h"
 #include "latency_gui.h"
 #include "mixer_strip.h"
+#include "patch_change_widget.h"
 #include "plugin_pin_dialog.h"
 #include "rgb_macros.h"
 #include "route_time_axis.h"
@@ -121,6 +122,8 @@ RouteUI::~RouteUI()
                ARDOUR_UI::instance()->gui_object_state->remove_node (route_state_id());
        }
 
+       delete_patch_change_dialog ();
+
        _route.reset (); /* drop reference to route, so that it can be cleaned up */
        route_connections.drop_connections ();
 
@@ -246,6 +249,7 @@ RouteUI::reset ()
        delete mute_menu;
        mute_menu = 0;
 
+       delete_patch_change_dialog ();
        _color_picker.reset ();
 
        denormal_menu_item = 0;
@@ -1613,6 +1617,39 @@ RouteUI::toggle_solo_safe (Gtk::CheckMenuItem* check)
        _route->solo_safe_control()->set_value (check->get_active() ? 1.0 : 0.0, Controllable::UseGroup);
 }
 
+void
+RouteUI::delete_patch_change_dialog ()
+{
+       if (!_route) {
+               return;
+       }
+       delete _route->patch_selector_dialog ();
+       _route->set_patch_selector_dialog (0);
+}
+
+PatchChangeGridDialog*
+RouteUI::patch_change_dialog () const
+{
+       return _route->patch_selector_dialog ();
+}
+
+void
+RouteUI::select_midi_patch ()
+{
+       if (patch_change_dialog ()) {
+               patch_change_dialog()->present ();
+               return;
+       }
+
+       /* note: RouteTimeAxisView is resoponsible to updating
+        * the Dialog (PatchChangeGridDialog::refresh())
+        * when the midnam model changes.
+        */
+       PatchChangeGridDialog* d = new PatchChangeGridDialog (_route);
+       _route->set_patch_selector_dialog (d);
+       d->present ();
+}
+
 /** Ask the user to choose a colour, and then apply that color to my route */
 void
 RouteUI::choose_color ()
index 4550abd4c2e218a863b2df39d094bba794ba8e80..d39e8deabf3271d608daa592e0d193072a2b24fa 100644 (file)
@@ -63,6 +63,7 @@ namespace ArdourWidgets {
 class ArdourWindow;
 class IOSelectorWindow;
 class ControlSlaveUI;
+class PatchChangeGridDialog;
 class SaveTemplateDialog;
 
 class RoutePinWindowProxy : public WM::ProxyBase
@@ -113,6 +114,8 @@ public:
        Gdk::Color route_color () const;
        void choose_color ();
 
+       void select_midi_patch ();
+
        bool ignore_toggle;
        bool wait_for_release;
        bool multiple_mute_change;
@@ -299,10 +302,13 @@ protected:
 
        bool mark_hidden (bool yn);
 
+       PatchChangeGridDialog* patch_change_dialog () const;
+
 private:
        void parameter_changed (std::string const&);
        void relabel_solo_button ();
        void track_mode_changed ();
+       void delete_patch_change_dialog ();
 
        std::string route_state_id () const;