UndoUtil.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #ifndef CRYINCLUDE_EDITOR_CORE_UTIL_UNDO_UTIL_H
  9. #define CRYINCLUDE_EDITOR_CORE_UTIL_UNDO_UTIL_H
  10. #pragma once
  11. #include "Include/EditorCoreAPI.h"
  12. struct IUndoObject;
  13. class EDITOR_CORE_API CUndo
  14. {
  15. public:
  16. CUndo(const char* description);
  17. ~CUndo();
  18. void Cancel() { m_bCancelled = true; }
  19. //! Check if undo is recording.
  20. static bool IsRecording();
  21. //! Check if undo is suspended.
  22. static bool IsSuspended();
  23. //! Record specified object.
  24. static void Record(IUndoObject* undo);
  25. private:
  26. static const AZ::u32 scDescSize = 256;
  27. char m_description[scDescSize];
  28. bool m_bCancelled;
  29. bool m_bStartedRecord;
  30. };
  31. //! CUndoSuspend is a utility undo class
  32. //! Define instance of this class in block of code where you want to suspend undo operations
  33. class EDITOR_CORE_API CUndoSuspend
  34. {
  35. public:
  36. CUndoSuspend();
  37. ~CUndoSuspend();
  38. };
  39. #endif // CRYINCLUDE_EDITOR_CORE_UTIL_UNDO_UTIL_H