PropertyHandlerSprite.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 <AzCore/base.h>
  11. #include <AzCore/Memory/SystemAllocator.h>
  12. #include <QtWidgets/QWidget>
  13. #include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
  14. #include <AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.hxx>
  15. #endif
  16. class PropertySpriteCtrl
  17. : public QWidget
  18. {
  19. Q_OBJECT
  20. public:
  21. AZ_CLASS_ALLOCATOR(PropertySpriteCtrl, AZ::SystemAllocator);
  22. PropertySpriteCtrl(QWidget* parent = nullptr);
  23. void dragEnterEvent(QDragEnterEvent* ev) override;
  24. void dragLeaveEvent(QDragLeaveEvent* ev) override;
  25. void dropEvent(QDropEvent* ev) override;
  26. AzToolsFramework::PropertyAssetCtrl* GetPropertyAssetCtrl();
  27. private:
  28. AzToolsFramework::PropertyAssetCtrl* m_propertyAssetCtrl;
  29. };
  30. //-------------------------------------------------------------------------------
  31. class PropertyHandlerSprite
  32. : public AzToolsFramework::PropertyHandler<AzFramework::SimpleAssetReferenceBase, PropertySpriteCtrl>
  33. {
  34. public:
  35. AZ_CLASS_ALLOCATOR(PropertyHandlerSprite, AZ::SystemAllocator);
  36. AZ::u32 GetHandlerName(void) const override { return AZ_CRC("Sprite", 0x351d8f9e); }
  37. QWidget* CreateGUI(QWidget* pParent) override;
  38. void ConsumeAttribute(PropertySpriteCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
  39. void WriteGUIValuesIntoProperty(size_t index, PropertySpriteCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  40. bool ReadValuesIntoGUI(size_t index, PropertySpriteCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  41. static void Register();
  42. };