BsCmdReparentSO.h 2.1 KB

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