diff --git a/gtk2_ardour/midi_cue_view.cc b/gtk2_ardour/midi_cue_view.cc index 89011d35fa..062bfa9413 100644 --- a/gtk2_ardour/midi_cue_view.cc +++ b/gtk2_ardour/midi_cue_view.cc @@ -118,3 +118,16 @@ MidiCueView::set_samples_per_pixel (double spp) reset_width_dependent_items (_editing_context.duration_to_pixels (duration)); } + + +std::shared_ptr +MidiCueView::model_to_edit() const +{ + return std::shared_ptr (new ARDOUR::MidiModel (*_model, *(midi_region()->midi_source()))); +} + +void +MidiCueView::post_edit (std::shared_ptr edited_model, ARDOUR::MidiModel::NoteDiffCommand const & diff_command) +{ + _model = edited_model; +} diff --git a/gtk2_ardour/midi_cue_view.h b/gtk2_ardour/midi_cue_view.h index c1e49a7135..6ca8f2e8e9 100644 --- a/gtk2_ardour/midi_cue_view.h +++ b/gtk2_ardour/midi_cue_view.h @@ -51,6 +51,9 @@ class MidiCueView : public MidiView std::shared_ptr tempo_map; ArdourCanvas::Rectangle* event_rect; + + std::shared_ptr model_to_edit() const; + void post_edit (std::shared_ptr, ARDOUR::MidiModel::NoteDiffCommand const &); }; diff --git a/gtk2_ardour/midi_view.cc b/gtk2_ardour/midi_view.cc index 6290c692d2..703a20d7d3 100644 --- a/gtk2_ardour/midi_view.cc +++ b/gtk2_ardour/midi_view.cc @@ -907,10 +907,13 @@ MidiView::apply_note_diff (bool as_subcommand, bool was_copy) } } + std::shared_ptr op_model = model_to_edit (); + { PBD::Unwinder puw (_select_all_notes_after_add, true); /*note that we don't use as_commit here, because that would BEGIN a new undo record; we already have one underway*/ - _model->apply_diff_command_as_subcommand (*_editing_context.session(), _note_diff_command); + op_model->apply_diff_command_as_subcommand (*_editing_context.session(), _note_diff_command); + post_edit (op_model, *_note_diff_command); } if (!as_subcommand) { @@ -924,6 +927,7 @@ MidiView::apply_note_diff (bool as_subcommand, bool was_copy) } _marked_for_velocity.clear(); + } void diff --git a/gtk2_ardour/midi_view.h b/gtk2_ardour/midi_view.h index dcbc22d0cd..288c9bb9e2 100644 --- a/gtk2_ardour/midi_view.h +++ b/gtk2_ardour/midi_view.h @@ -640,6 +640,9 @@ class MidiView : public virtual sigc::trackable void join_notes_on_channel (int channel); void add_split_notes (); + + virtual std::shared_ptr model_to_edit() const { return _model; } + virtual void post_edit (std::shared_ptr, ARDOUR::MidiModel::NoteDiffCommand const &) {} };