HierarchyClipboard.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #pragma once
  9. class HierarchyClipboard
  10. {
  11. public:
  12. //-------------------------------------------------------------------------------
  13. //! The return value is the same as the parameter entryList.
  14. static SerializeHelpers::SerializedEntryList& Serialize(HierarchyWidget* widget,
  15. const QTreeWidgetItemRawPtrQList& selectedItems,
  16. HierarchyItemRawPtrList* optionalItemsToSerialize,
  17. SerializeHelpers::SerializedEntryList& entryList,
  18. bool isUndo);
  19. static bool Unserialize(HierarchyWidget* widget,
  20. SerializeHelpers::SerializedEntryList& entryList,
  21. bool isUndo);
  22. //-------------------------------------------------------------------------------
  23. static void CopySelectedItemsToClipboard(HierarchyWidget* widget,
  24. const QTreeWidgetItemRawPtrQList& selectedItems);
  25. static void CreateElementsFromClipboard(HierarchyWidget* widget,
  26. const QTreeWidgetItemRawPtrQList& selectedItems,
  27. bool createAsChildOfSelection);
  28. //-------------------------------------------------------------------------------
  29. //! Get the XML from the given elements (and their descendants)
  30. //! \param widget the HiearchyWidget in the Ui Editor editing the canvas
  31. //! \param elements the elements to serialize
  32. //! \param isCopyOperation True if this is a copy or cut operation, false if it is part of undo/redo
  33. //! \param referencedSliceAssets an out parameter listing the prefab assets used by the serialized elements
  34. //! \return a string containing XML or empty
  35. static AZStd::string GetXml(HierarchyWidget* widget,
  36. const LyShine::EntityArray& elements,
  37. bool isCopyOperation,
  38. AZStd::unordered_set<AZ::Data::AssetId>& referencedSliceAssets);
  39. //! Get the XML from the given canvas.
  40. //! The output SHOULDN'T be serialized to disk.
  41. //! The output should ONLY be used to determine if any changes
  42. //! have occurred between a "before" and an "after" states.
  43. //! \return a string containing XML or empty
  44. static AZStd::string GetXmlForDiff(AZ::EntityId canvasEntityId);
  45. //-------------------------------------------------------------------------------
  46. //! Record the state of all selected entities before a change
  47. static void BeginUndoableEntitiesChange(EditorWindow* editorWindow, SerializeHelpers::SerializedEntryList& preChangeState);
  48. //! Record an undo command of the changes to the selected entities
  49. static void EndUndoableEntitiesChange(EditorWindow* editorWindow, const char* commandName, SerializeHelpers::SerializedEntryList& preChangeState);
  50. };