more improvements to velocity drawing (including straight line)

This commit is contained in:
Paul Davis 2023-10-27 11:49:36 -06:00
parent 91fbb1c65b
commit ef0938a16d
7 changed files with 59 additions and 71 deletions

View file

@ -3402,54 +3402,18 @@ MidiRegionView::begin_drag_edit (std::string const & why)
if (!_selected) {
trackview.editor().get_selection().set (this, true);
}
start_note_diff_command (why);
}
void
MidiRegionView::drag_apply ()
MidiRegionView::end_drag_edit ()
{
if (!_note_diff_command) {
return;
}
bool add_or_remove = _note_diff_command->adds_or_removes();
if (add_or_remove) {
// Mark all selected notes for selection when model reloads
for (auto const & sel : _selection) {
_marked_for_selection.insert (sel->note());
}
}
{
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 (*trackview.session(), _note_diff_command);
}
}
void
MidiRegionView::mid_drag_edit ()
{
drag_apply ();
_note_diff_command = _model->new_note_diff_command ();
}
void
MidiRegionView::end_drag_edit (bool apply)
{
if (apply) {
drag_apply ();
trackview.editor().commit_reversible_command ();
_note_diff_command = nullptr;
} else {
abort_note_diff ();
}
}
bool
MidiRegionView::set_velocities_for_notes (std::vector<NoteBase*> notes, std::vector<int> velocities)
{
start_note_diff_command (_("draw velocities"));
assert (notes.size() == velocities.size());
/* Does not use selection, used when drawing/dragging in velocity lane */
@ -3472,6 +3436,11 @@ MidiRegionView::set_velocities_for_notes (std::vector<NoteBase*> notes, std::vec
++veloi;
}
apply_note_diff (true /*subcommand, we don't want this to start a new commit*/, false);
trackview.editor().commit_reversible_command ();
delete _note_diff_command;
_note_diff_command = nullptr;
return changed;
}