mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added methods UndoManager::getUndoDescriptions() and UndoManager::getRedoDescriptions()
This commit is contained in:
parent
7bcd6a5ecd
commit
f752a3331e
2 changed files with 64 additions and 23 deletions
|
|
@ -98,7 +98,7 @@ void UndoManager::setMaxNumberOfStoredUnits (int maxUnits, int minTransactions)
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
bool UndoManager::perform (UndoableAction* const newAction, const String& actionName)
|
||||
bool UndoManager::perform (UndoableAction* newAction, const String& actionName)
|
||||
{
|
||||
if (perform (newAction))
|
||||
{
|
||||
|
|
@ -237,8 +237,8 @@ String UndoManager::getCurrentTransactionName() const noexcept
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
UndoManager::ActionSet* UndoManager::getCurrentSet() const noexcept { return transactions [nextIndex - 1]; }
|
||||
UndoManager::ActionSet* UndoManager::getNextSet() const noexcept { return transactions [nextIndex]; }
|
||||
UndoManager::ActionSet* UndoManager::getCurrentSet() const noexcept { return transactions[nextIndex - 1]; }
|
||||
UndoManager::ActionSet* UndoManager::getNextSet() const noexcept { return transactions[nextIndex]; }
|
||||
|
||||
bool UndoManager::canUndo() const noexcept { return getCurrentSet() != nullptr; }
|
||||
bool UndoManager::canRedo() const noexcept { return getNextSet() != nullptr; }
|
||||
|
|
@ -297,6 +297,32 @@ String UndoManager::getRedoDescription() const
|
|||
return {};
|
||||
}
|
||||
|
||||
StringArray UndoManager::getUndoDescriptions() const
|
||||
{
|
||||
StringArray descriptions;
|
||||
|
||||
for (int i = nextIndex;;)
|
||||
{
|
||||
if (auto* t = transactions[--i])
|
||||
descriptions.add (t->name);
|
||||
else
|
||||
return descriptions;
|
||||
}
|
||||
}
|
||||
|
||||
StringArray UndoManager::getRedoDescriptions() const
|
||||
{
|
||||
StringArray descriptions;
|
||||
|
||||
for (int i = nextIndex;;)
|
||||
{
|
||||
if (auto* t = transactions[i++])
|
||||
descriptions.add (t->name);
|
||||
else
|
||||
return descriptions;
|
||||
}
|
||||
}
|
||||
|
||||
Time UndoManager::getTimeOfUndoTransaction() const
|
||||
{
|
||||
if (auto* s = getCurrentSet())
|
||||
|
|
|
|||
|
|
@ -158,14 +158,10 @@ public:
|
|||
*/
|
||||
bool canUndo() const noexcept;
|
||||
|
||||
/** Returns the name of the transaction that will be rolled-back when undo() is called.
|
||||
@see undo
|
||||
*/
|
||||
String getUndoDescription() const;
|
||||
|
||||
/** Tries to roll-back the last transaction.
|
||||
@returns true if the transaction can be undone, and false if it fails, or
|
||||
if there aren't any transactions to undo
|
||||
@see undoCurrentTransactionOnly
|
||||
*/
|
||||
bool undo();
|
||||
|
||||
|
|
@ -184,6 +180,23 @@ public:
|
|||
*/
|
||||
bool undoCurrentTransactionOnly();
|
||||
|
||||
/** Returns the name of the transaction that will be rolled-back when undo() is called.
|
||||
@see undo, canUndo, getUndoDescriptions
|
||||
*/
|
||||
String getUndoDescription() 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.
|
||||
@see undo, canUndo, getUndoDescription
|
||||
*/
|
||||
StringArray getUndoDescriptions() 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().
|
||||
*/
|
||||
Time getTimeOfUndoTransaction() const;
|
||||
|
||||
/** Returns a list of the UndoableAction objects that have been performed during the
|
||||
transaction that is currently open.
|
||||
|
||||
|
|
@ -200,33 +213,35 @@ public:
|
|||
*/
|
||||
int getNumActionsInCurrentTransaction() 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().
|
||||
*/
|
||||
Time getTimeOfUndoTransaction() 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().
|
||||
*/
|
||||
Time getTimeOfRedoTransaction() const;
|
||||
|
||||
//==============================================================================
|
||||
/** Returns true if there's at least one action in the list to redo.
|
||||
@see getRedoDescription, redo, canUndo
|
||||
*/
|
||||
bool canRedo() const noexcept;
|
||||
|
||||
/** Returns the name of the transaction that will be redone when redo() is called.
|
||||
@see redo
|
||||
*/
|
||||
String getRedoDescription() const;
|
||||
|
||||
/** Tries to redo the last transaction that was undone.
|
||||
@returns true if the transaction can be redone, and false if it fails, or
|
||||
if there aren't any transactions to redo
|
||||
*/
|
||||
bool redo();
|
||||
|
||||
/** Returns the name of the transaction that will be redone when redo() is called.
|
||||
@see redo, canRedo, getRedoDescriptions
|
||||
*/
|
||||
String getRedoDescription() 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.
|
||||
@see redo, canRedo, getRedoDescription
|
||||
*/
|
||||
StringArray getRedoDescriptions() 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().
|
||||
@see redo, canRedo
|
||||
*/
|
||||
Time getTimeOfRedoTransaction() const;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue