MidiView: adjust API to use when brushing multiple notes

This commit is contained in:
Paul Davis
2025-10-31 13:23:37 -06:00
parent deafaa904f
commit dcb482e74d
2 changed files with 24 additions and 8 deletions

View File

@@ -841,7 +841,7 @@ MidiView::show_list_editor ()
* \param snap_t true to snap t to the grid, otherwise false.
*/
void
MidiView::create_note_at (timepos_t const & source_relative_start, double y, Temporal::Beats length, uint32_t state, bool shift_snap)
MidiView::create_note_at (timepos_t const & source_relative_start, double y, Temporal::Beats length, uint32_t state, bool shift_snap, bool control_reversible_command)
{
if (!_model) {
return;
@@ -865,16 +865,18 @@ MidiView::create_note_at (timepos_t const & source_relative_start, double y, Tem
return;
}
start_note_diff_command(_("add note"));
start_note_diff_command(_("add note"), control_reversible_command);
note_diff_add_note (new_note, true, false);
apply_note_diff();
apply_note_diff (!control_reversible_command);
// XXX _editing_context.set_selected_midi_region_view (*this);
list<Evoral::event_id_t> to_be_selected;
to_be_selected.push_back (new_note->id());
select_notes (to_be_selected, true);
play_midi_note (new_note);
if (do_commit) {
play_midi_note (new_note);
}
}
void
@@ -906,20 +908,33 @@ MidiView::display_model (std::shared_ptr<MidiModel> model)
}
void
MidiView::start_note_diff_command (string name)
MidiView::start_note_diff_command (string name, bool with_reversible_command)
{
if (!_model) {
return;
}
if (!_note_diff_command) {
_editing_context.begin_reversible_command (name);
if (with_reversible_command) {
_editing_context.begin_reversible_command (name);
}
_note_diff_command = _model->new_note_diff_command (name);
} else {
std::cerr << "ERROR: start_note_diff_command command called, but a note_diff_command was already underway" << std::endl;
}
}
void
MidiView::end_note_diff_command ()
{
if (!_model) {
return;
}
_editing_context.commit_reversible_command ();
_note_diff_command = nullptr;
}
void
MidiView::note_diff_add_note (const std::shared_ptr<NoteType> note, bool selected, bool show_velocity)
{

View File

@@ -193,7 +193,8 @@ class MidiView : public virtual sigc::trackable, public LineMerger
std::shared_ptr<ARDOUR::MidiModel> model() const { return _model; }
/* note_diff commands should start here; this initiates an undo record */
void start_note_diff_command (std::string name = "midi edit");
void start_note_diff_command (std::string name = "midi edit", bool with_reversible_command = true);
void end_note_diff_command ();
void note_diff_add_change (NoteBase* ev, ARDOUR::MidiModel::NoteDiffCommand::Property, uint8_t val);
void note_diff_add_change (NoteBase* ev, ARDOUR::MidiModel::NoteDiffCommand::Property, Temporal::Beats val);
@@ -328,7 +329,7 @@ class MidiView : public virtual sigc::trackable, public LineMerger
* \param state the keyboard modifier mask for the canvas event (click).
* \param shift_snap true alters snap behavior to round down always (false if the gui has already done that).
*/
void create_note_at (Temporal::timepos_t const & t, double y, Temporal::Beats length, uint32_t state, bool shift_snap);
void create_note_at (Temporal::timepos_t const & t, double y, Temporal::Beats length, uint32_t state, bool shift_snap, bool control_reversible_command = true);
/** An external request to clear the note selection, remove MRV from editor
* selection.