ManifestVectorHandler.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. /*
  3. * Copyright (c) Contributors to the Open 3D Engine Project.
  4. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. *
  6. * SPDX-License-Identifier: Apache-2.0 OR MIT
  7. *
  8. */
  9. #if !defined(Q_MOC_RUN)
  10. #include <AzCore/Math/Crc.h>
  11. #include <AzCore/Memory/SystemAllocator.h>
  12. #include <AzCore/std/containers/vector.h>
  13. #include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
  14. #include <SceneAPI/SceneCore/DataTypes/IManifestObject.h>
  15. #include <SceneAPI/SceneUI/RowWidgets/ManifestVectorWidget.h>
  16. #endif
  17. class QWidget;
  18. namespace AZ
  19. {
  20. class SerializeContext;
  21. namespace SceneAPI
  22. {
  23. namespace UI
  24. {
  25. class ManifestVectorHandler
  26. {
  27. public:
  28. static void Register();
  29. static void Unregister();
  30. };
  31. // This class only has two specializations, that are defined in the cpp file
  32. template<typename ManifestType>
  33. class IManifestVectorHandler
  34. : public QObject
  35. , public AzToolsFramework::PropertyHandler<AZStd::vector<AZStd::shared_ptr<ManifestType>>, ManifestVectorWidget>
  36. {
  37. static_assert((AZStd::is_base_of<DataTypes::IManifestObject, ManifestType>::value), "Manifest type class must inherit from DataTypes::IManifestObject");
  38. public:
  39. AZ_CLASS_ALLOCATOR_DECL
  40. QWidget* CreateGUI(QWidget* parent) override;
  41. u32 GetHandlerName() const override;
  42. bool AutoDelete() const override;
  43. void ConsumeAttribute(ManifestVectorWidget* widget, u32 attrib,
  44. AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
  45. void WriteGUIValuesIntoProperty(size_t index, ManifestVectorWidget* GUI, typename IManifestVectorHandler::property_t& instance,
  46. AzToolsFramework::InstanceDataNode* node) override;
  47. bool ReadValuesIntoGUI(size_t index, ManifestVectorWidget* GUI, const typename IManifestVectorHandler::property_t& instance,
  48. AzToolsFramework::InstanceDataNode* node) override;
  49. static void Register();
  50. static void Unregister();
  51. private:
  52. static SerializeContext* s_serializeContext;
  53. static IManifestVectorHandler* s_instance;
  54. };
  55. } // UI
  56. } // SceneAPI
  57. } // AZ