Allow to send immediate PC messages without closing the dialog.
authorRobin Gareus <robin@gareus.org>
Thu, 24 Aug 2017 21:41:21 +0000 (23:41 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 24 Aug 2017 21:41:21 +0000 (23:41 +0200)
Perhaps every change should trigger a PC (without "Apply") button?!

gtk2_ardour/midi_time_axis.cc
gtk2_ardour/midi_time_axis.h
gtk2_ardour/patch_change_dialog.cc
gtk2_ardour/patch_change_dialog.h

index ffff6a96981a7b0e2aea69c6a7eaba673c1b0f43..33160f8da3e185fb2c07167563d351b393434f2a 100644 (file)
@@ -122,6 +122,7 @@ 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();
@@ -345,6 +346,9 @@ MidiTimeAxisView::~MidiTimeAxisView ()
 
        delete controller_menu;
        delete _step_editor;
+
+       delete  _patch_change_dialog;
+       _patch_change_dialog = 0;
 }
 
 void
@@ -1078,19 +1082,14 @@ MidiTimeAxisView::build_color_mode_menu()
 }
 
 void
-MidiTimeAxisView::send_patch_change ()
+MidiTimeAxisView::immediate_patch_chnage_response (int response)
 {
-       if (!_route) {
-               return;
-       }
-
-       Evoral::PatchChange<Evoral::Beats> empty (Evoral::Beats(), 0, 0, 0);
-       PatchChangeDialog d (0, 0, empty, _route->instrument_info(), Gtk::Stock::OK);
-
-       if (d.run() == RESPONSE_CANCEL) {
+       if (response != RESPONSE_ACCEPT || !_route) {
+               delete  _patch_change_dialog;
+               _patch_change_dialog = 0;
                return;
        }
-       Evoral::PatchChange<Evoral::Beats> p (d.patch ());
+       Evoral::PatchChange<Evoral::Beats> p (_patch_change_dialog->patch ());
 
        uint8_t chn = p.channel();
 
@@ -1099,12 +1098,32 @@ MidiTimeAxisView::send_patch_change ()
        boost::shared_ptr<AutomationControl> program = _route->automation_control(Evoral::Parameter (MidiPgmChangeAutomation, chn), true);
 
        if (!bank_msb || ! bank_lsb || !program) {
+               _patch_change_dialog->show ();
                return;
        }
 
        bank_msb->set_value (p.bank_msb (), Controllable::NoGroup);
        bank_lsb->set_value (p.bank_lsb (), Controllable::NoGroup);
        program->set_value  (p.program () , Controllable::NoGroup);
+       _patch_change_dialog->show ();
+}
+
+void
+MidiTimeAxisView::send_patch_change ()
+{
+       if (!_route) {
+               return;
+       }
+       if (_patch_change_dialog) {
+               _patch_change_dialog->present ();
+               return;
+       }
+
+       Evoral::PatchChange<Evoral::Beats> empty (Evoral::Beats(), 0, 0, 0);
+       PatchChangeDialog* d = new PatchChangeDialog (0, 0, empty, _route->instrument_info(), Gtk::Stock::APPLY, false, false);
+       d->signal_response().connect (sigc::mem_fun (*this, &MidiTimeAxisView::immediate_patch_chnage_response));
+       _patch_change_dialog = d;
+       _patch_change_dialog->present ();
 }
 
 void
index 8a899aece1e75849c1f02396f953e9e040ae0280..6bbb3594581cb515156ebd241ae0a555ac0378c8 100644 (file)
@@ -67,6 +67,7 @@ class PianoRollHeader;
 class StepEntry;
 class StepEditor;
 class MidiChannelSelectorWindow;
+class PatchChangeDialog;
 
 #define NO_MIDI_NOTE 0xff
 
@@ -196,6 +197,10 @@ private:
        ParameterMenuMap _controller_menu_map;
 
        StepEditor* _step_editor;
+
+       void immediate_patch_chnage_response (int response);
+       PatchChangeDialog* _patch_change_dialog;
+
 };
 
 #endif /* __ardour_midi_time_axis_h__ */
index 780323b9bbffaab60a852bcb981117f2230eff4f..32a102af1f692ebf86eac4103cf7e9f1ef583654 100644 (file)
@@ -46,8 +46,9 @@ PatchChangeDialog::PatchChangeDialog (
        Evoral::PatchChange<Evoral::Beats> const & patch,
        ARDOUR::InstrumentInfo&                    info,
        const Gtk::BuiltinStockID&                 ok,
-       bool                                       allow_delete)
-       : ArdourDialog (_("Patch Change"), true)
+       bool                                       allow_delete,
+       bool                                       modal)
+       : ArdourDialog (_("Patch Change"), modal)
        , _time_converter (tc)
        , _info (info)
        , _time (X_("patchchangetime"), true, "", true, false)
@@ -56,6 +57,7 @@ PatchChangeDialog::PatchChangeDialog (
        , _bank_msb (*manage (new Adjustment (0, 0, 127, 1, 16)))
        , _bank_lsb (*manage (new Adjustment (0, 0, 127, 1, 16)))
        , _ignore_signals (false)
+       , _keep_open (!modal)
 {
        Table* t = manage (new Table (4, 2));
        Label* l;
@@ -122,7 +124,9 @@ PatchChangeDialog::PatchChangeDialog (
 
        get_vbox()->add (*t);
 
-       add_button (Stock::CANCEL, RESPONSE_CANCEL);
+       if (modal) {
+               add_button (Stock::CANCEL, RESPONSE_CANCEL);
+       }
        add_button (ok, RESPONSE_ACCEPT);
        if (allow_delete) {
                add_button (Gtk::StockID(GTK_STOCK_DELETE), RESPONSE_REJECT);
@@ -139,6 +143,16 @@ PatchChangeDialog::PatchChangeDialog (
        show_all ();
 }
 
+void
+PatchChangeDialog::on_response (int response_id)
+{
+       if (_keep_open) {
+               Gtk::Dialog::on_response (response_id);
+       } else {
+               ArdourDialog::on_response (response_id);
+       }
+}
+
 int
 PatchChangeDialog::get_14bit_bank () const
 {
index 65b107c8a517d9519d0daa54d8f242cb9a37ed81..0390ecfffacb03028f2803c5efef67689a3b72b8 100644 (file)
@@ -46,11 +46,15 @@ public:
                Evoral::PatchChange<Evoral::Beats> const &,
                ARDOUR::InstrumentInfo&,
                const Gtk::BuiltinStockID &,
-               bool allow_delete = false
+               bool allow_delete = false,
+               bool modal = true
                );
 
        Evoral::PatchChange<Evoral::Beats> patch () const;
 
+protected:
+       void on_response (int);
+
 private:
        void fill_bank_combo ();
        void set_active_bank_combo ();
@@ -76,6 +80,7 @@ private:
 
        boost::shared_ptr<MIDI::Name::PatchBank> _current_patch_bank;
        bool _ignore_signals;
+       bool _keep_open;
 
        void instrument_info_changed ();
        PBD::ScopedConnection _info_changed_connection;