midi_model: rename some midi diff functions, to (try to) avoid confusion
syntax for beginning and ending a diff command is: "new_diff_command" -> "apply_diff_command" syntax for applying a diff_command is: "_as_commit" : Begins and Commits a standalone undo Command "_as_subcommand" : adds to undo but does not Begin or Commit a Command "_only" : (new) applies the note_diff but does not have any effect on undo
This commit is contained in:
parent
c44d692390
commit
f50d5507c3
@ -256,7 +256,7 @@ public:
|
||||
*
|
||||
* This has no side-effects on the model or Session, the returned command
|
||||
* can be held on to for as long as the caller wishes, or discarded without
|
||||
* formality, until apply_command is called and ownership is taken.
|
||||
* formality, until apply_diff_command_* is called and ownership is taken.
|
||||
*/
|
||||
MidiModel::NoteDiffCommand* new_note_diff_command (const std::string& name = "midi edit");
|
||||
/** Start a new SysExDiff command */
|
||||
@ -268,18 +268,25 @@ public:
|
||||
/** Apply a command.
|
||||
*
|
||||
* Ownership of cmd is taken, it must not be deleted by the caller.
|
||||
* This STARTS and COMMITS an undo command.
|
||||
* The command will constitute one item on the undo stack.
|
||||
*/
|
||||
void apply_command (Session& session, Command* cmd);
|
||||
void apply_diff_command_as_commit (Session& session, Command* cmd);
|
||||
|
||||
void apply_command (Session* session, Command* cmd) { if (session) { apply_command (*session, cmd); } }
|
||||
void apply_diff_command_as_commit (Session* session, Command* cmd) { if (session) { apply_diff_command_as_commit (*session, cmd); } }
|
||||
|
||||
/** Apply a command as part of a larger reversible transaction
|
||||
/** Add a command as part of a larger reversible transaction
|
||||
*
|
||||
* Ownership of cmd is taken, it must not be deleted by the caller.
|
||||
* The command will constitute one item on the undo stack.
|
||||
* The command will be incorporated into the current command.
|
||||
*/
|
||||
void apply_command_as_subcommand (Session& session, Command* cmd);
|
||||
void apply_diff_command_as_subcommand (Session& session, Command* cmd);
|
||||
|
||||
/** Apply the midi diff, but without any effect on undo
|
||||
*
|
||||
* Ownership of cmd is not changed.
|
||||
*/
|
||||
void apply_diff_command_only (Session& session, Command* cmd);
|
||||
|
||||
bool sync_to_source (const Source::WriterLock& source_lock);
|
||||
|
||||
|
@ -461,7 +461,7 @@ no_audio_tracks:
|
||||
/* PT C-2 = 0, Ardour C-1 = 0, subtract twelve to convert ? */
|
||||
midicmd->add (boost::shared_ptr<Evoral::Note<Temporal::Beats> > (new Evoral::Note<Temporal::Beats> ((uint8_t)1, start, len, j->note, j->velocity)));
|
||||
}
|
||||
mm->apply_command (this, midicmd);
|
||||
mm->apply_diff_command_only (*this, midicmd);
|
||||
boost::shared_ptr<Region> copy (RegionFactory::create (mr, true));
|
||||
playlist->clear_changes ();
|
||||
playlist->add_region (copy, timepos_t (f));
|
||||
|
@ -1571,7 +1571,8 @@ LuaBindings::common (lua_State* L)
|
||||
.endClass ()
|
||||
|
||||
.deriveWSPtrClass <MidiModel, AutomatableSequence<Temporal::Beats> > ("MidiModel")
|
||||
.addFunction ("apply_command", (void (MidiModel::*)(Session*, Command*))&MidiModel::apply_command)
|
||||
.addFunction ("apply_command", (void (MidiModel::*)(Session*, Command*))&MidiModel::apply_diff_command_as_commit) /* deprecated: left here in case any extant scripts use apply_command */
|
||||
.addFunction ("apply_diff_command_as_commit", (void (MidiModel::*)(Session*, Command*))&MidiModel::apply_diff_command_as_commit)
|
||||
.addFunction ("new_note_diff_command", &MidiModel::new_note_diff_command)
|
||||
.endClass ()
|
||||
|
||||
|
@ -92,7 +92,7 @@ MidiModel::new_patch_change_diff_command (const string& name)
|
||||
|
||||
|
||||
void
|
||||
MidiModel::apply_command(Session& session, Command* cmd)
|
||||
MidiModel::apply_diff_command_as_commit(Session& session, Command* cmd)
|
||||
{
|
||||
session.begin_reversible_command (cmd->name());
|
||||
(*cmd)();
|
||||
@ -101,13 +101,20 @@ MidiModel::apply_command(Session& session, Command* cmd)
|
||||
}
|
||||
|
||||
void
|
||||
MidiModel::apply_command_as_subcommand(Session& session, Command* cmd)
|
||||
MidiModel::apply_diff_command_as_subcommand(Session& session, Command* cmd)
|
||||
{
|
||||
(*cmd)();
|
||||
session.add_command (cmd);
|
||||
set_edited (true);
|
||||
}
|
||||
|
||||
void
|
||||
MidiModel::apply_diff_command_only(Session& session, Command* cmd)
|
||||
{
|
||||
(*cmd)();
|
||||
set_edited (true);
|
||||
}
|
||||
|
||||
/* ************* DIFF COMMAND ********************/
|
||||
|
||||
#define NOTE_DIFF_COMMAND_ELEMENT "NoteDiffCommand"
|
||||
@ -1702,7 +1709,7 @@ MidiModel::insert_silence_at_start (TimeType t)
|
||||
c->change (*i, NoteDiffCommand::StartTime, (*i)->time() + t);
|
||||
}
|
||||
|
||||
apply_command_as_subcommand (_midi_source.session(), c);
|
||||
apply_diff_command_as_subcommand (_midi_source.session(), c);
|
||||
}
|
||||
|
||||
/* Patch changes */
|
||||
@ -1714,7 +1721,7 @@ MidiModel::insert_silence_at_start (TimeType t)
|
||||
c->change_time (*i, (*i)->time() + t);
|
||||
}
|
||||
|
||||
apply_command_as_subcommand (_midi_source.session(), c);
|
||||
apply_diff_command_as_subcommand (_midi_source.session(), c);
|
||||
}
|
||||
|
||||
/* Controllers */
|
||||
@ -1736,7 +1743,7 @@ MidiModel::insert_silence_at_start (TimeType t)
|
||||
c->change (*i, (*i)->time() + t);
|
||||
}
|
||||
|
||||
apply_command_as_subcommand (_midi_source.session(), c);
|
||||
apply_diff_command_as_subcommand (_midi_source.session(), c);
|
||||
}
|
||||
|
||||
ContentsShifted (timecnt_t (t));
|
||||
|
Loading…
Reference in New Issue
Block a user