UiAnimUndo.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #include "UiAnimUndo.h"
  9. #include "UiAnimUndoManager.h"
  10. UiAnimUndo::UiAnimUndo(const char* description)
  11. : m_bCancelled(false)
  12. {
  13. if (!IsRecording())
  14. {
  15. UiAnimUndoManager::Get()->Begin();
  16. m_description = description;
  17. m_bStartedRecord = true;
  18. }
  19. else
  20. {
  21. m_bStartedRecord = false;
  22. }
  23. };
  24. UiAnimUndo::~UiAnimUndo()
  25. {
  26. if (m_bStartedRecord)
  27. {
  28. if (m_bCancelled)
  29. {
  30. UiAnimUndoManager::Get()->Cancel();
  31. }
  32. else
  33. {
  34. UiAnimUndoManager::Get()->Accept(m_description);
  35. }
  36. }
  37. };
  38. bool UiAnimUndo::IsRecording()
  39. {
  40. return UiAnimUndoManager::Get()->IsUndoRecording();
  41. }
  42. bool UiAnimUndo::IsSuspended()
  43. {
  44. return UiAnimUndoManager::Get()->IsUndoSuspended();
  45. }
  46. void UiAnimUndo::Record(UiAnimUndoObject* undo)
  47. {
  48. return UiAnimUndoManager::Get()->RecordUndo(undo);
  49. }