MeshNodeHandler.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #if !defined(Q_MOC_RUN)
  10. #include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
  11. #include <AzCore/Asset/AssetCommon.h>
  12. #include <AzToolsFramework/UI/PropertyEditor/PropertyStringComboBoxCtrl.hxx>
  13. #include <QObject>
  14. #endif
  15. namespace NvCloth
  16. {
  17. namespace Editor
  18. {
  19. /*
  20. =============================================================
  21. = Handler Documentation =
  22. =============================================================
  23. Custom handler for the Cloth Component's Mesh Node property as a PropertyStringComboBoxCtrl widget.
  24. Handler Name: "MeshNodeSelector"
  25. Available Attributes:
  26. EntityId - Entity identifier used to query the mesh asset via MeshComponentRequestBus.
  27. StringList - List of mesh node names that contain cloth data.
  28. NOTE: EntityId must be the first attribute set so it's available when consuming StringList.
  29. */
  30. class MeshNodeHandler
  31. : public QObject
  32. , public AzToolsFramework::PropertyHandler<AZStd::string, AzToolsFramework::PropertyStringComboBoxCtrl>
  33. {
  34. Q_OBJECT
  35. public:
  36. AZ_CLASS_ALLOCATOR(MeshNodeHandler, AZ::SystemAllocator);
  37. MeshNodeHandler() = default;
  38. // AzToolsFramework::PropertyHandler overrides ...
  39. AZ::u32 GetHandlerName() const override;
  40. QWidget* CreateGUI(QWidget* parent) override;
  41. bool IsDefaultHandler() const override;
  42. void ConsumeAttribute(widget_t* widget, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
  43. void WriteGUIValuesIntoProperty(size_t index, widget_t* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  44. bool ReadValuesIntoGUI(size_t index, widget_t* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  45. private:
  46. void OnEditButtonClicked();
  47. AZ::Data::Asset<AZ::Data::AssetData> GetMeshAsset(const AZ::EntityId entityId) const;
  48. AZ::EntityId m_entityId;
  49. };
  50. } // namespace Editor
  51. } // namespace NvCloth