OpenShot Audio Library | OpenShotAudio: juce_UndoManager.h Source File

OpenShot Audio Library | OpenShotAudio 0.6.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//==============================================================================
51 class 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
81 int getNumberOfUnitsTakenUpByStoredCommands() const;
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
152 String getCurrentTransactionName() const;
153
154 //==============================================================================
158 bool canUndo() const;
159
165 bool undo();
166
180 bool undoCurrentTransactionOnly();
181
185 String getUndoDescription() const;
186
192 StringArray getUndoDescriptions() const;
193
197 Time getTimeOfUndoTransaction() const;
198
207 void getActionsInCurrentTransaction (Array<const UndoableAction*>& actionsFound) const;
208
213 int getNumActionsInCurrentTransaction() const;
214
215 //==============================================================================
219 bool canRedo() const;
220
225 bool redo();
226
230 String getRedoDescription() const;
231
237 StringArray getRedoDescriptions() const;
238
243 Time getTimeOfRedoTransaction() const;
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
juce::Array
Definition juce_Array.h:56
juce::ChangeBroadcaster::ChangeBroadcaster
ChangeBroadcaster() noexcept
Definition juce_ChangeBroadcaster.cpp:26
juce::OwnedArray
Definition juce_OwnedArray.h:50
juce::StringArray
Definition juce_StringArray.h:35
juce::String
Definition juce_String.h:53
juce::Time
Definition juce_Time.h:37
juce::UndoManager::beginNewTransaction
void beginNewTransaction()
Definition juce_UndoManager.cpp:209
juce::UndoManager::getTimeOfUndoTransaction
Time getTimeOfUndoTransaction() const
Definition juce_UndoManager.cpp:325
juce::UndoManager::getCurrentTransactionName
String getCurrentTransactionName() const
Definition juce_UndoManager.cpp:228
juce::UndoManager::setMaxNumberOfStoredUnits
void setMaxNumberOfStoredUnits(int maxNumberOfUnitsToKeep, int minimumTransactionsToKeep)
Definition juce_UndoManager.cpp:91
juce::UndoManager::redo
bool redo()
Definition juce_UndoManager.cpp:264
juce::UndoManager::getRedoDescription
String getRedoDescription() const
Definition juce_UndoManager.cpp:291
juce::UndoManager::getRedoDescriptions
StringArray getRedoDescriptions() const
Definition juce_UndoManager.cpp:312
juce::UndoManager::undo
bool undo()
Definition juce_UndoManager.cpp:245
juce::UndoManager::isPerformingUndoRedo
bool isPerformingUndoRedo() const
Definition juce_UndoManager.cpp:240
juce::UndoManager::clearUndoHistory
void clearUndoHistory()
Definition juce_UndoManager.cpp:78
juce::UndoManager::canUndo
bool canUndo() const
Definition juce_UndoManager.cpp:242
juce::UndoManager::undoCurrentTransactionOnly
bool undoCurrentTransactionOnly()
Definition juce_UndoManager.cpp:341
juce::UndoManager::getNumberOfUnitsTakenUpByStoredCommands
int getNumberOfUnitsTakenUpByStoredCommands() const
Definition juce_UndoManager.cpp:86
juce::UndoManager::perform
bool perform(UndoableAction *action)
Definition juce_UndoManager.cpp:111
juce::UndoManager::getTimeOfRedoTransaction
Time getTimeOfRedoTransaction() const
Definition juce_UndoManager.cpp:333
juce::UndoManager::canRedo
bool canRedo() const
Definition juce_UndoManager.cpp:243
juce::UndoManager::getUndoDescriptions
StringArray getUndoDescriptions() const
Definition juce_UndoManager.cpp:299
juce::UndoManager::getUndoDescription
String getUndoDescription() const
Definition juce_UndoManager.cpp:283
juce::UndoManager::UndoManager
UndoManager(int maxNumberOfUnitsToKeep=30000, int minimumTransactionsToKeep=30)
Definition juce_UndoManager.cpp:68
juce::UndoManager::getActionsInCurrentTransaction
void getActionsInCurrentTransaction(Array< const UndoableAction * > &actionsFound) const
Definition juce_UndoManager.cpp:352
juce::UndoManager::getNumActionsInCurrentTransaction
int getNumActionsInCurrentTransaction() const
Definition juce_UndoManager.cpp:360
juce::UndoManager::setCurrentTransactionName
void setCurrentTransactionName(const String &newName)
Definition juce_UndoManager.cpp:220
juce::UndoableAction
Definition juce_UndoableAction.h:39