The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

101 lines
3.7KB

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