2
0

BsCmdReparentSO.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsEditorCommand.h"
  4. #include "BsUndoRedo.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief A command used for undo/redo purposes. It records a scene object
  9. * parent change operations. It allows you to apply the parent change
  10. * or revert the object to its original parent as needed.
  11. */
  12. class BS_ED_EXPORT CmdReparentSO : public EditorCommand
  13. {
  14. public:
  15. /**
  16. * @brief Creates and executes the command on the provided scene object(s).
  17. * Automatically registers the command with undo/redo system.
  18. *
  19. * @param sceneObjects Object(s) to change the parent for.
  20. * @param newParent New parent for the provided objects.
  21. * @param description Optional description of what exactly the command does.
  22. */
  23. static void execute(const Vector<HSceneObject>& sceneObjects, const HSceneObject& newParent,
  24. const WString& description = StringUtil::WBLANK);
  25. /**
  26. * @brief Creates and executes the command on the provided scene object.
  27. * Automatically registers the command with undo/redo system.
  28. *
  29. * @param sceneObject Object to change the parent for.
  30. * @param newParent New parent for the provided objects.
  31. * @param description Optional description of what exactly the command does.
  32. */
  33. static void execute(HSceneObject& sceneObject, const HSceneObject& newParent,
  34. const WString& description = StringUtil::WBLANK);
  35. /**
  36. * @copydoc EditorCommand::commit
  37. */
  38. void commit() override;
  39. /**
  40. * @copydoc EditorCommand::revert
  41. */
  42. void revert() override;
  43. private:
  44. friend class UndoRedo;
  45. CmdReparentSO(const WString& description, const Vector<HSceneObject>& sceneObjects, const HSceneObject& newParent);
  46. Vector<HSceneObject> mSceneObjects;
  47. Vector<HSceneObject> mOldParents;
  48. HSceneObject mNewParent;
  49. };
  50. }