PropertyHandlerDirectory.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #include <AzToolsFramework/AssetBrowser/AssetSelectionModel.h>
  16. #endif
  17. class PropertyDirectoryCtrl
  18. : public QWidget
  19. {
  20. Q_OBJECT
  21. public:
  22. AZ_CLASS_ALLOCATOR(PropertyDirectoryCtrl, AZ::SystemAllocator);
  23. PropertyDirectoryCtrl(QWidget* parent = nullptr);
  24. void dragEnterEvent(QDragEnterEvent* ev) override;
  25. void dragLeaveEvent(QDragLeaveEvent* ev) override;
  26. void dropEvent(QDropEvent* ev) override;
  27. AzToolsFramework::PropertyAssetCtrl* GetPropertyAssetCtrl();
  28. private:
  29. AzToolsFramework::PropertyAssetCtrl* m_propertyAssetCtrl;
  30. };
  31. //-------------------------------------------------------------------------------
  32. class PropertyAssetDirectorySelectionCtrl
  33. : public AzToolsFramework::PropertyAssetCtrl
  34. {
  35. public:
  36. AZ_CLASS_ALLOCATOR(PropertyAssetDirectorySelectionCtrl, AZ::SystemAllocator)
  37. PropertyAssetDirectorySelectionCtrl(QWidget *pParent = NULL)
  38. : PropertyAssetCtrl(pParent) {}
  39. AzToolsFramework::AssetBrowser::AssetSelectionModel GetAssetSelectionModel() override;
  40. void SetFolderSelection(const AZStd::string& folderPath) override;
  41. const AZStd::string GetFolderSelection() const override { return m_folderPath; }
  42. void ClearAssetInternal() override;
  43. private:
  44. AZStd::string m_folderPath;
  45. };
  46. //-------------------------------------------------------------------------------
  47. class PropertyHandlerDirectory
  48. : public AzToolsFramework::PropertyHandler<AZStd::string, PropertyDirectoryCtrl>
  49. {
  50. public:
  51. AZ_CLASS_ALLOCATOR(PropertyHandlerDirectory, AZ::SystemAllocator);
  52. AZ::u32 GetHandlerName(void) const override { return AZ_CRC("Directory", 0x467844da); }
  53. QWidget* CreateGUI(QWidget* pParent) override;
  54. void ConsumeAttribute(PropertyDirectoryCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
  55. void WriteGUIValuesIntoProperty(size_t index, PropertyDirectoryCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  56. bool ReadValuesIntoGUI(size_t index, PropertyDirectoryCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  57. static void Register();
  58. };