13
0

basics of MIDI clip editing notification via model swap

This commit is contained in:
Paul Davis 2024-06-21 22:19:28 -06:00
parent 7dee98279a
commit 044aec6563
4 changed files with 24 additions and 1 deletions

View File

@ -118,3 +118,16 @@ MidiCueView::set_samples_per_pixel (double spp)
reset_width_dependent_items (_editing_context.duration_to_pixels (duration));
}
std::shared_ptr<ARDOUR::MidiModel>
MidiCueView::model_to_edit() const
{
return std::shared_ptr<ARDOUR::MidiModel> (new ARDOUR::MidiModel (*_model, *(midi_region()->midi_source())));
}
void
MidiCueView::post_edit (std::shared_ptr<ARDOUR::MidiModel> edited_model, ARDOUR::MidiModel::NoteDiffCommand const & diff_command)
{
_model = edited_model;
}

View File

@ -51,6 +51,9 @@ class MidiCueView : public MidiView
std::shared_ptr<Temporal::TempoMap const> tempo_map;
ArdourCanvas::Rectangle* event_rect;
std::shared_ptr<ARDOUR::MidiModel> model_to_edit() const;
void post_edit (std::shared_ptr<ARDOUR::MidiModel>, ARDOUR::MidiModel::NoteDiffCommand const &);
};

View File

@ -907,10 +907,13 @@ MidiView::apply_note_diff (bool as_subcommand, bool was_copy)
}
}
std::shared_ptr<MidiModel> op_model = model_to_edit ();
{
PBD::Unwinder<bool> 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

View File

@ -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<ARDOUR::MidiModel> model_to_edit() const { return _model; }
virtual void post_edit (std::shared_ptr<ARDOUR::MidiModel>, ARDOUR::MidiModel::NoteDiffCommand const &) {}
};