SourceHandlePropertyAssetCtrl.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/PropertyAssetCtrl.hxx>
  11. #include <Core/Core.h>
  12. #endif
  13. namespace ScriptCanvasEditor
  14. {
  15. class SourceHandlePropertyAssetCtrl
  16. : public AzToolsFramework::PropertyAssetCtrl
  17. {
  18. Q_OBJECT
  19. public:
  20. AZ_CLASS_ALLOCATOR(SourceHandlePropertyAssetCtrl, AZ::SystemAllocator);
  21. SourceHandlePropertyAssetCtrl(QWidget* parent = nullptr);
  22. AzToolsFramework::AssetBrowser::AssetSelectionModel GetAssetSelectionModel() override;
  23. void PopupAssetPicker() override;
  24. void ClearAssetInternal() override;
  25. void ConfigureAutocompleter() override;
  26. void SetSourceAssetFilterPattern(const QRegExp& filterPattern);
  27. AZ::IO::Path GetSelectedSourcePath() const;
  28. void SetSelectedSourcePath(const AZ::IO::Path& sourcePath);
  29. public Q_SLOTS:
  30. void OnAutocomplete(const QModelIndex& index) override;
  31. private:
  32. //! A regular expression pattern for filtering by source assets
  33. //! If this is set, the PropertyAssetCtrl will be dealing with source assets
  34. //! instead of a specific asset type
  35. QRegExp m_sourceAssetFilterPattern;
  36. AZ::IO::Path m_selectedSourcePath;
  37. };
  38. class SourceHandlePropertyHandler
  39. : QObject
  40. , public AzToolsFramework::PropertyHandler<SourceHandle, SourceHandlePropertyAssetCtrl>
  41. {
  42. Q_OBJECT
  43. public:
  44. AZ_CLASS_ALLOCATOR(SourceHandlePropertyHandler, AZ::SystemAllocator);
  45. AZ::u32 GetHandlerName(void) const override { return AZ_CRC_CE("SourceHandle"); }
  46. bool IsDefaultHandler() const override { return true; }
  47. QWidget* GetFirstInTabOrder(SourceHandlePropertyAssetCtrl* widget) override { return widget->GetFirstInTabOrder(); }
  48. QWidget* GetLastInTabOrder(SourceHandlePropertyAssetCtrl* widget) override { return widget->GetLastInTabOrder(); }
  49. void UpdateWidgetInternalTabbing(SourceHandlePropertyAssetCtrl* widget) override { widget->UpdateTabOrder(); }
  50. QWidget* CreateGUI(QWidget* pParent) override;
  51. void ConsumeAttribute(SourceHandlePropertyAssetCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
  52. void WriteGUIValuesIntoProperty(size_t index, SourceHandlePropertyAssetCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  53. bool ReadValuesIntoGUI(size_t index, SourceHandlePropertyAssetCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  54. };
  55. }