OpenShot Audio Library | OpenShotAudio 0.4.0
 
Loading...
Searching...
No Matches
juce_UndoManager.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
51class JUCE_API UndoManager : public ChangeBroadcaster
52{
53public:
54 //==============================================================================
68 UndoManager (int maxNumberOfUnitsToKeep = 30000,
69 int minimumTransactionsToKeep = 30);
70
72 ~UndoManager() override;
73
74 //==============================================================================
76 void clearUndoHistory();
77
82
97 void setMaxNumberOfStoredUnits (int maxNumberOfUnitsToKeep,
98 int minimumTransactionsToKeep);
99
100 //==============================================================================
108 bool perform (UndoableAction* action);
109
120 bool perform (UndoableAction* action, const String& actionName);
121
128 void beginNewTransaction();
129
139 void beginNewTransaction (const String& actionName);
140
147 void setCurrentTransactionName (const String& newName);
148
153
154 //==============================================================================
158 bool canUndo() const;
159
165 bool undo();
166
181
186
193
198
208
214
215 //==============================================================================
219 bool canRedo() const;
220
225 bool redo();
226
231
238
244
246 bool isPerformingUndoRedo() const;
247
248private:
249 //==============================================================================
250 struct ActionSet;
251 OwnedArray<ActionSet> transactions, stashedFutureTransactions;
252 String newTransactionName;
253 int totalUnitsStored = 0, maxNumUnitsToKeep = 0, minimumTransactionsToKeep = 0, nextIndex = 0;
254 bool newTransaction = true, isInsideUndoRedoCall = false;
255 ActionSet* getCurrentSet() const;
256 ActionSet* getNextSet() const;
257 void moveFutureTransactionsToStash();
258 void restoreStashedFutureTransactions();
259 void dropOldTransactionsIfTooLarge();
260
261 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (UndoManager)
262};
263
264} // namespace juce
Time getTimeOfUndoTransaction() const
String getCurrentTransactionName() const
void setMaxNumberOfStoredUnits(int maxNumberOfUnitsToKeep, int minimumTransactionsToKeep)
String getRedoDescription() const
StringArray getRedoDescriptions() const
bool isPerformingUndoRedo() const
int getNumberOfUnitsTakenUpByStoredCommands() const
bool perform(UndoableAction *action)
Time getTimeOfRedoTransaction() const
StringArray getUndoDescriptions() const
String getUndoDescription() const
UndoManager(int maxNumberOfUnitsToKeep=30000, int minimumTransactionsToKeep=30)
void getActionsInCurrentTransaction(Array< const UndoableAction * > &actionsFound) const
int getNumActionsInCurrentTransaction() const
void setCurrentTransactionName(const String &newName)