OpenShot Audio Library | OpenShotAudio 0.3.2
|
#include <juce_UndoManager.h>
Manages a list of undo/redo commands.
An UndoManager object keeps a list of past actions and can use these actions to move backwards and forwards through an undo history.
To use it, create subclasses of UndoableAction which perform all the actions you need, then when you need to actually perform an action, create one and pass it to the UndoManager's perform() method.
The manager also uses the concept of 'transactions' to group the actions together - all actions performed between calls to beginNewTransaction() are grouped together and are all undone/redone as a group.
The UndoManager is a ChangeBroadcaster, so listeners can register to be told when actions are performed or undone.
Definition at line 52 of file juce_UndoManager.h.
juce::UndoManager::UndoManager | ( | int | maxNumberOfUnitsToKeep = 30000 , |
int | minimumTransactionsToKeep = 30 |
||
) |
Creates an UndoManager.
maxNumberOfUnitsToKeep | each UndoableAction object returns a value to indicate how much storage it takes up (UndoableAction::getSizeInUnits()), so this lets you specify the maximum total number of units that the undomanager is allowed to keep in memory before letting the older actions drop off the end of the list. |
minimumTransactionsToKeep | this specifies the minimum number of transactions that will be kept, even if this involves exceeding the amount of space specified in maxNumberOfUnitsToKeep |
Definition at line 69 of file juce_UndoManager.cpp.
|
override |
Destructor.
Definition at line 74 of file juce_UndoManager.cpp.
void juce::UndoManager::beginNewTransaction | ( | ) |
Starts a new group of actions that together will be treated as a single transaction.
All actions that are passed to the perform() method between calls to this method are grouped together and undone/redone together by a single call to undo() or redo().
Definition at line 210 of file juce_UndoManager.cpp.
Referenced by beginNewTransaction(), redo(), and undo().
Starts a new group of actions that together will be treated as a single transaction.
All actions that are passed to the perform() method between calls to this method are grouped together and undone/redone together by a single call to undo() or redo().
actionName | a description of the transaction that is about to be performed |
Definition at line 215 of file juce_UndoManager.cpp.
bool juce::UndoManager::canRedo | ( | ) | const |
Returns true if there's at least one action in the list to redo.
Definition at line 244 of file juce_UndoManager.cpp.
bool juce::UndoManager::canUndo | ( | ) | const |
Returns true if there's at least one action in the list to undo.
Definition at line 243 of file juce_UndoManager.cpp.
void juce::UndoManager::clearUndoHistory | ( | ) |
Deletes all stored actions in the list.
Definition at line 79 of file juce_UndoManager.cpp.
void juce::UndoManager::getActionsInCurrentTransaction | ( | Array< const UndoableAction * > & | actionsFound | ) | const |
Returns a list of the UndoableAction objects that have been performed during the transaction that is currently open.
Effectively, this is the list of actions that would be undone if undoCurrentTransactionOnly() were to be called now.
The first item in the list is the earliest action performed.
Definition at line 353 of file juce_UndoManager.cpp.
String juce::UndoManager::getCurrentTransactionName | ( | ) | const |
Returns the name of the current transaction.
Definition at line 229 of file juce_UndoManager.cpp.
int juce::UndoManager::getNumActionsInCurrentTransaction | ( | ) | const |
Returns the number of UndoableAction objects that have been performed during the transaction that is currently open.
Definition at line 361 of file juce_UndoManager.cpp.
int juce::UndoManager::getNumberOfUnitsTakenUpByStoredCommands | ( | ) | const |
Returns the current amount of space to use for storing UndoableAction objects.
Definition at line 87 of file juce_UndoManager.cpp.
String juce::UndoManager::getRedoDescription | ( | ) | const |
Returns the name of the transaction that will be redone when redo() is called.
Definition at line 292 of file juce_UndoManager.cpp.
StringArray juce::UndoManager::getRedoDescriptions | ( | ) | const |
Returns the names of the sequence of transactions that will be performed if redo() is repeatedly called. Note that for transactions where no name was provided, the corresponding string will be empty.
Definition at line 313 of file juce_UndoManager.cpp.
Time juce::UndoManager::getTimeOfRedoTransaction | ( | ) | const |
Returns the time to which the state would be restored if redo() was to be called. If a redo isn't currently possible, it'll return Time::getCurrentTime().
Definition at line 334 of file juce_UndoManager.cpp.
Time juce::UndoManager::getTimeOfUndoTransaction | ( | ) | const |
Returns the time to which the state would be restored if undo() was to be called. If an undo isn't currently possible, it'll return Time().
Definition at line 326 of file juce_UndoManager.cpp.
String juce::UndoManager::getUndoDescription | ( | ) | const |
Returns the name of the transaction that will be rolled-back when undo() is called.
Definition at line 284 of file juce_UndoManager.cpp.
StringArray juce::UndoManager::getUndoDescriptions | ( | ) | const |
Returns the names of the sequence of transactions that will be performed if undo() is repeatedly called. Note that for transactions where no name was provided, the corresponding string will be empty.
Definition at line 300 of file juce_UndoManager.cpp.
bool juce::UndoManager::isPerformingUndoRedo | ( | ) | const |
Returns true if the caller code is in the middle of an undo or redo action.
Definition at line 241 of file juce_UndoManager.cpp.
Referenced by perform().
bool juce::UndoManager::perform | ( | UndoableAction * | action | ) |
Performs an action and adds it to the undo history list.
action | the action to perform - this object will be deleted by the UndoManager when no longer needed |
Definition at line 112 of file juce_UndoManager.cpp.
Referenced by perform().
bool juce::UndoManager::perform | ( | UndoableAction * | action, |
const String & | actionName | ||
) |
Performs an action and also gives it a name.
action | the action to perform - this object will be deleted by the UndoManager when no longer needed |
actionName | if this string is non-empty, the current transaction will be given this name; if it's empty, the current transaction name will be left unchanged. See setCurrentTransactionName() |
Definition at line 99 of file juce_UndoManager.cpp.
bool juce::UndoManager::redo | ( | ) |
Tries to redo the last transaction that was undone.
Definition at line 265 of file juce_UndoManager.cpp.
Changes the name stored for the current transaction.
Each transaction is given a name when the beginNewTransaction() method is called, but this can be used to change that name without starting a new transaction.
Definition at line 221 of file juce_UndoManager.cpp.
Referenced by perform().
void juce::UndoManager::setMaxNumberOfStoredUnits | ( | int | maxNumberOfUnitsToKeep, |
int | minimumTransactionsToKeep | ||
) |
Sets the amount of space that can be used for storing UndoableAction objects.
maxNumberOfUnitsToKeep | each UndoableAction object returns a value to indicate how much storage it takes up (UndoableAction::getSizeInUnits()), so this lets you specify the maximum total number of units that the undomanager is allowed to keep in memory before letting the older actions drop off the end of the list. |
minimumTransactionsToKeep | this specifies the minimum number of transactions that will be kept, even if this involves exceeding the amount of space specified in maxNumberOfUnitsToKeep |
Definition at line 92 of file juce_UndoManager.cpp.
Referenced by UndoManager().
bool juce::UndoManager::undo | ( | ) |
Tries to roll-back the last transaction.
Definition at line 246 of file juce_UndoManager.cpp.
Referenced by undoCurrentTransactionOnly().
bool juce::UndoManager::undoCurrentTransactionOnly | ( | ) |
Tries to roll-back any actions that were added to the current transaction.
This will perform an undo() only if there are some actions in the undo list that were added after the last call to beginNewTransaction().
This is useful because it lets you call beginNewTransaction(), then perform an operation which may or may not actually perform some actions, and then call this method to get rid of any actions that might have been done without it rolling back the previous transaction if nothing was actually done.
Definition at line 342 of file juce_UndoManager.cpp.