adjust MidiModel API to require HistoryOwner not Session for commands
This commit is contained in:
@@ -44,9 +44,12 @@
|
||||
#include "evoral/Note.h"
|
||||
#include "evoral/Sequence.h"
|
||||
|
||||
namespace PBD {
|
||||
class HistoryOwner;
|
||||
}
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class Session;
|
||||
class MidiSource;
|
||||
class MidiStateTracker;
|
||||
|
||||
@@ -277,22 +280,22 @@ public:
|
||||
* This STARTS and COMMITS an undo command.
|
||||
* The command will constitute one item on the undo stack.
|
||||
*/
|
||||
void apply_diff_command_as_commit (Session& session, PBD::Command* cmd);
|
||||
void apply_diff_command_as_commit (PBD::HistoryOwner&, PBD::Command* cmd);
|
||||
|
||||
void apply_diff_command_as_commit (Session* session, PBD::Command* cmd) { if (session) { apply_diff_command_as_commit (*session, cmd); } }
|
||||
void apply_diff_command_as_commit (PBD::HistoryOwner* history, PBD::Command* cmd) { if (history) { apply_diff_command_as_commit (*history, cmd); } }
|
||||
|
||||
/** 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 be incorporated into the current command.
|
||||
*/
|
||||
void apply_diff_command_as_subcommand (Session& session, PBD::Command* cmd);
|
||||
void apply_diff_command_as_subcommand (PBD::HistoryOwner&, PBD::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, PBD::Command* cmd);
|
||||
void apply_diff_command_only (PBD::Command* cmd);
|
||||
|
||||
bool sync_to_source (const Source::WriterLock& source_lock);
|
||||
|
||||
|
||||
@@ -466,7 +466,7 @@ no_audio_tracks:
|
||||
/* PT C-2 = 0, Ardour C-1 = 0, subtract twelve to convert ? */
|
||||
midicmd->add (std::shared_ptr<Evoral::Note<Temporal::Beats> > (new Evoral::Note<Temporal::Beats> ((uint8_t)1, start, len, j->note, j->velocity)));
|
||||
}
|
||||
mm->apply_diff_command_only (*this, midicmd);
|
||||
mm->apply_diff_command_only (midicmd);
|
||||
delete midicmd;
|
||||
std::shared_ptr<Region> copy (RegionFactory::create (mr, true));
|
||||
playlist->clear_changes ();
|
||||
|
||||
@@ -1804,8 +1804,8 @@ LuaBindings::common (lua_State* L)
|
||||
.endClass ()
|
||||
|
||||
.deriveWSPtrClass <MidiModel, AutomatableSequence<Temporal::Beats> > ("MidiModel")
|
||||
.addFunction ("apply_command", (void (MidiModel::*)(Session*, PBD::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*, PBD::Command*))&MidiModel::apply_diff_command_as_commit)
|
||||
.addFunction ("apply_command", (void (MidiModel::*)(PBD::HistoryOwner*, PBD::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::*)(PBD::HistoryOwner*, PBD::Command*))&MidiModel::apply_diff_command_as_commit)
|
||||
.addFunction ("new_note_diff_command", &MidiModel::new_note_diff_command)
|
||||
.addFunction ("new_sysex_diff_command", &MidiModel::new_sysex_diff_command)
|
||||
.addFunction ("new_patch_change_diff_command", &MidiModel::new_patch_change_diff_command)
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "pbd/compose.h"
|
||||
#include "pbd/enumwriter.h"
|
||||
#include "pbd/error.h"
|
||||
#include "pbd/history_owner.h"
|
||||
|
||||
#include "evoral/Control.h"
|
||||
|
||||
@@ -100,24 +101,24 @@ MidiModel::new_patch_change_diff_command (const string& name)
|
||||
|
||||
|
||||
void
|
||||
MidiModel::apply_diff_command_as_commit(Session& session, Command* cmd)
|
||||
MidiModel::apply_diff_command_as_commit(HistoryOwner& history, Command* cmd)
|
||||
{
|
||||
session.begin_reversible_command (cmd->name());
|
||||
history.begin_reversible_command (cmd->name());
|
||||
(*cmd)();
|
||||
session.commit_reversible_command (cmd);
|
||||
history.commit_reversible_command (cmd);
|
||||
set_edited (true);
|
||||
}
|
||||
|
||||
void
|
||||
MidiModel::apply_diff_command_as_subcommand(Session& session, Command* cmd)
|
||||
MidiModel::apply_diff_command_as_subcommand (HistoryOwner& history, Command* cmd)
|
||||
{
|
||||
(*cmd)();
|
||||
session.add_command (cmd);
|
||||
history.add_command (cmd);
|
||||
set_edited (true);
|
||||
}
|
||||
|
||||
void
|
||||
MidiModel::apply_diff_command_only(Session& session, Command* cmd)
|
||||
MidiModel::apply_diff_command_only (Command* cmd)
|
||||
{
|
||||
(*cmd)();
|
||||
set_edited (true);
|
||||
|
||||
Reference in New Issue
Block a user