Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_UNDOABLEACTION_H_INCLUDED
  18. #define JUCE_UNDOABLEACTION_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. Used by the UndoManager class to store an action which can be done
  22. and undone.
  23. @see UndoManager
  24. */
  25. class JUCE_API UndoableAction
  26. {
  27. protected:
  28. /** Creates an action. */
  29. UndoableAction() noexcept {}
  30. public:
  31. /** Destructor. */
  32. virtual ~UndoableAction() {}
  33. //==============================================================================
  34. /** Overridden by a subclass to perform the action.
  35. This method is called by the UndoManager, and shouldn't be used directly by
  36. applications.
  37. Be careful not to make any calls in a perform() method that could call
  38. recursively back into the UndoManager::perform() method
  39. @returns true if the action could be performed.
  40. @see UndoManager::perform
  41. */
  42. virtual bool perform() = 0;
  43. /** Overridden by a subclass to undo the action.
  44. This method is called by the UndoManager, and shouldn't be used directly by
  45. applications.
  46. Be careful not to make any calls in an undo() method that could call
  47. recursively back into the UndoManager::perform() method
  48. @returns true if the action could be undone without any errors.
  49. @see UndoManager::perform
  50. */
  51. virtual bool undo() = 0;
  52. //==============================================================================
  53. /** Returns a value to indicate how much memory this object takes up.
  54. Because the UndoManager keeps a list of UndoableActions, this is used
  55. to work out how much space each one will take up, so that the UndoManager
  56. can work out how many to keep.
  57. The default value returned here is 10 - units are arbitrary and
  58. don't have to be accurate.
  59. @see UndoManager::getNumberOfUnitsTakenUpByStoredCommands,
  60. UndoManager::setMaxNumberOfStoredUnits
  61. */
  62. virtual int getSizeInUnits() { return 10; }
  63. /** Allows multiple actions to be coalesced into a single action object, to reduce storage space.
  64. If possible, this method should create and return a single action that does the same job as
  65. this one followed by the supplied action.
  66. If it's not possible to merge the two actions, the method should return zero.
  67. */
  68. virtual UndoableAction* createCoalescedAction (UndoableAction* nextAction) { (void) nextAction; return nullptr; }
  69. };
  70. #endif // JUCE_UNDOABLEACTION_H_INCLUDED