Blindly add a few stuff from VST
[juce-lv2.git] / juce / source / src / utilities / juce_UndoableAction.h
bloba3c731ae6d1124124a0c9961943bf11da5c479e1
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCE_UNDOABLEACTION_JUCEHEADER__
27 #define __JUCE_UNDOABLEACTION_JUCEHEADER__
30 //==============================================================================
31 /**
32 Used by the UndoManager class to store an action which can be done
33 and undone.
35 @see UndoManager
37 class JUCE_API UndoableAction
39 protected:
40 /** Creates an action. */
41 UndoableAction() noexcept {}
43 public:
44 /** Destructor. */
45 virtual ~UndoableAction() {}
47 //==============================================================================
48 /** Overridden by a subclass to perform the action.
50 This method is called by the UndoManager, and shouldn't be used directly by
51 applications.
53 Be careful not to make any calls in a perform() method that could call
54 recursively back into the UndoManager::perform() method
56 @returns true if the action could be performed.
57 @see UndoManager::perform
59 virtual bool perform() = 0;
61 /** Overridden by a subclass to undo the action.
63 This method is called by the UndoManager, and shouldn't be used directly by
64 applications.
66 Be careful not to make any calls in an undo() method that could call
67 recursively back into the UndoManager::perform() method
69 @returns true if the action could be undone without any errors.
70 @see UndoManager::perform
72 virtual bool undo() = 0;
74 //==============================================================================
75 /** Returns a value to indicate how much memory this object takes up.
77 Because the UndoManager keeps a list of UndoableActions, this is used
78 to work out how much space each one will take up, so that the UndoManager
79 can work out how many to keep.
81 The default value returned here is 10 - units are arbitrary and
82 don't have to be accurate.
84 @see UndoManager::getNumberOfUnitsTakenUpByStoredCommands,
85 UndoManager::setMaxNumberOfStoredUnits
87 virtual int getSizeInUnits() { return 10; }
89 /** Allows multiple actions to be coalesced into a single action object, to reduce storage space.
91 If possible, this method should create and return a single action that does the same job as
92 this one followed by the supplied action.
94 If it's not possible to merge the two actions, the method should return zero.
96 virtual UndoableAction* createCoalescedAction (UndoableAction* nextAction) { (void) nextAction; return nullptr; }
100 #endif // __JUCE_UNDOABLEACTION_JUCEHEADER__