Add API to determine undo status
This is is useful to determine if an undoable action was performed before adding additional information (e.g. selection changes) to the undo transaction.
This commit is contained in:
parent
1ef4fc1140
commit
9fb21a0905
@ -1075,6 +1075,28 @@ public:
|
|||||||
|
|
||||||
bool operation_in_progress (GQuark) const;
|
bool operation_in_progress (GQuark) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if any undo commands were added since the
|
||||||
|
* call to begin_reversible_command ()
|
||||||
|
*
|
||||||
|
* This is is useful to determine if an undoable
|
||||||
|
* action was performed before adding additional
|
||||||
|
* information (e.g. selection changes) to the
|
||||||
|
* undo transaction.
|
||||||
|
*
|
||||||
|
* @return true if undo operation is valid but empty
|
||||||
|
*/
|
||||||
|
bool collected_undo_commands () const {
|
||||||
|
return _current_trans && !_current_trans->empty ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abort reversible commend IFF no undo changes
|
||||||
|
* have been collected.
|
||||||
|
* @return true if undo operation was aborted.
|
||||||
|
*/
|
||||||
|
bool abort_empty_reversible_command ();
|
||||||
|
|
||||||
void add_commands (std::vector<Command*> const & cmds);
|
void add_commands (std::vector<Command*> const & cmds);
|
||||||
|
|
||||||
std::map<PBD::ID,PBD::StatefulDestructible*> registry;
|
std::map<PBD::ID,PBD::StatefulDestructible*> registry;
|
||||||
|
@ -2536,6 +2536,8 @@ LuaBindings::common (lua_State* L)
|
|||||||
.addFunction ("begin_reversible_command", (void (Session::*)(const std::string&))&Session::begin_reversible_command)
|
.addFunction ("begin_reversible_command", (void (Session::*)(const std::string&))&Session::begin_reversible_command)
|
||||||
.addFunction ("commit_reversible_command", &Session::commit_reversible_command)
|
.addFunction ("commit_reversible_command", &Session::commit_reversible_command)
|
||||||
.addFunction ("abort_reversible_command", &Session::abort_reversible_command)
|
.addFunction ("abort_reversible_command", &Session::abort_reversible_command)
|
||||||
|
.addFunction ("collected_undo_commands", &Session::collected_undo_commands)
|
||||||
|
.addFunction ("abort_empty_reversible_command", &Session::abort_empty_reversible_command)
|
||||||
.addFunction ("add_command", &Session::add_command)
|
.addFunction ("add_command", &Session::add_command)
|
||||||
.addFunction ("add_stateful_diff_command", &Session::add_stateful_diff_command)
|
.addFunction ("add_stateful_diff_command", &Session::add_stateful_diff_command)
|
||||||
.addFunction ("playlists", &Session::playlists)
|
.addFunction ("playlists", &Session::playlists)
|
||||||
|
@ -3093,6 +3093,16 @@ Session::abort_reversible_command ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Session::abort_empty_reversible_command ()
|
||||||
|
{
|
||||||
|
if (!collected_undo_commands ()) {
|
||||||
|
abort_reversible_command ();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Session::commit_reversible_command (Command *cmd)
|
Session::commit_reversible_command (Command *cmd)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user