Allow to send immediate PC messages without closing the dialog.

Perhaps every change should trigger a PC (without "Apply") button?!
This commit is contained in:
Robin Gareus 2017-08-24 23:41:21 +02:00
parent 18cf003aa9
commit 0e9dab6aab
4 changed files with 57 additions and 14 deletions

View 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) {
if (response != RESPONSE_ACCEPT || !_route) {
delete _patch_change_dialog;
_patch_change_dialog = 0;
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) {
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

View 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__ */

View 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
{

View 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;