OpenShot Library | libopenshot-audio 0.2.0
juce_UndoableAction.h
1
2/** @weakgroup juce_data_structures-undomanager
3 * @{
4 */
5/*
6 ==============================================================================
7
8 This file is part of the JUCE library.
9 Copyright (c) 2017 - ROLI Ltd.
10
11 JUCE is an open source library subject to commercial or open-source
12 licensing.
13
14 By using JUCE, you agree to the terms of both the JUCE 5 End-User License
15 Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
16 27th April 2017).
17
18 End User License Agreement: www.juce.com/juce-5-licence
19 Privacy Policy: www.juce.com/juce-5-privacy-policy
20
21 Or: You may also use this code under the terms of the GPL v3 (see
22 www.gnu.org/licenses).
23
24 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
25 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
26 DISCLAIMED.
27
28 ==============================================================================
29*/
30
31namespace juce
32{
33
34//==============================================================================
35/**
36 Used by the UndoManager class to store an action which can be done
37 and undone.
38
39 @see UndoManager
40
41 @tags{DataStructures}
42*/
44{
45protected:
46 /** Creates an action. */
47 UndoableAction() = default;
48
49public:
50 /** Destructor. */
51 virtual ~UndoableAction() = default;
52
53 //==============================================================================
54 /** Overridden by a subclass to perform the action.
55
56 This method is called by the UndoManager, and shouldn't be used directly by
57 applications.
58
59 Be careful not to make any calls in a perform() method that could call
60 recursively back into the UndoManager::perform() method
61
62 @returns true if the action could be performed.
63 @see UndoManager::perform
64 */
65 virtual bool perform() = 0;
66
67 /** Overridden by a subclass to undo the action.
68
69 This method is called by the UndoManager, and shouldn't be used directly by
70 applications.
71
72 Be careful not to make any calls in an undo() method that could call
73 recursively back into the UndoManager::perform() method
74
75 @returns true if the action could be undone without any errors.
76 @see UndoManager::perform
77 */
78 virtual bool undo() = 0;
79
80 //==============================================================================
81 /** Returns a value to indicate how much memory this object takes up.
82
83 Because the UndoManager keeps a list of UndoableActions, this is used
84 to work out how much space each one will take up, so that the UndoManager
85 can work out how many to keep.
86
87 The default value returned here is 10 - units are arbitrary and
88 don't have to be accurate.
89
90 @see UndoManager::getNumberOfUnitsTakenUpByStoredCommands,
91 UndoManager::setMaxNumberOfStoredUnits
92 */
93 virtual int getSizeInUnits() { return 10; }
94
95 /** Allows multiple actions to be coalesced into a single action object, to reduce storage space.
96
97 If possible, this method should create and return a single action that does the same job as
98 this one followed by the supplied action.
99
100 If it's not possible to merge the two actions, the method should return a nullptr.
101 */
102 virtual UndoableAction* createCoalescedAction (UndoableAction* nextAction) { ignoreUnused (nextAction); return nullptr; }
103};
104
105} // namespace juce
106
107/** @}*/
Used by the UndoManager class to store an action which can be done and undone.
virtual bool undo()=0
Overridden by a subclass to undo the action.
UndoableAction()=default
Creates an action.
virtual ~UndoableAction()=default
Destructor.
virtual UndoableAction * createCoalescedAction(UndoableAction *nextAction)
Allows multiple actions to be coalesced into a single action object, to reduce storage space.
virtual bool perform()=0
Overridden by a subclass to perform the action.
virtual int getSizeInUnits()
Returns a value to indicate how much memory this object takes up.
#define JUCE_API
This macro is added to all JUCE public class declarations.