EditorStreamingImageAssetCtrl.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 <Atom/RPI.Reflect/Image/StreamingImageAsset.h>
  11. #include <AzToolsFramework/AssetBrowser/AssetPicker/AssetPickerDialog.h>
  12. #include <AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.hxx>
  13. #endif
  14. namespace GradientSignal
  15. {
  16. class SupportedImageAssetPickerDialog
  17. : public AzToolsFramework::AssetBrowser::AssetPickerDialog
  18. {
  19. Q_OBJECT
  20. public:
  21. AZ_CLASS_ALLOCATOR(SupportedImageAssetPickerDialog, AZ::SystemAllocator);
  22. explicit SupportedImageAssetPickerDialog(AssetSelectionModel& selection, QWidget* parent = nullptr);
  23. protected:
  24. bool EvaluateSelection() const override;
  25. };
  26. class StreamingImagePropertyAssetCtrl
  27. : public AzToolsFramework::PropertyAssetCtrl
  28. {
  29. Q_OBJECT
  30. public:
  31. AZ_CLASS_ALLOCATOR(StreamingImagePropertyAssetCtrl, AZ::SystemAllocator);
  32. StreamingImagePropertyAssetCtrl(QWidget* parent = nullptr);
  33. void PickAssetSelectionFromDialog(AssetSelectionModel& selection, QWidget* parent) override;
  34. bool CanAcceptAsset(const AZ::Data::AssetId& assetId, const AZ::Data::AssetType& assetType) const override;
  35. public Q_SLOTS:
  36. void OnAutocomplete(const QModelIndex& index) override;
  37. void UpdateAssetDisplay() override;
  38. };
  39. //! We need a custom asset property handler for the AZ::RPI::StreamingImageAsset on our
  40. //! Image Gradient component because only a subset of the streaming image asset pixel formats
  41. //! are currently supported by the image data pixel retrieval API that the Image Gradient
  42. //! relies on
  43. class StreamingImagePropertyHandler
  44. : QObject
  45. , public AzToolsFramework::PropertyHandler<AZ::Data::Asset<AZ::Data::AssetData>, StreamingImagePropertyAssetCtrl>
  46. {
  47. Q_OBJECT
  48. public:
  49. AZ_CLASS_ALLOCATOR(StreamingImagePropertyHandler, AZ::SystemAllocator);
  50. AZ::TypeId GetHandledType() const override;
  51. AZ::u32 GetHandlerName() const override;
  52. bool IsDefaultHandler() const override;
  53. QWidget* GetFirstInTabOrder(StreamingImagePropertyAssetCtrl* widget) override;
  54. QWidget* GetLastInTabOrder(StreamingImagePropertyAssetCtrl* widget) override;
  55. void UpdateWidgetInternalTabbing(StreamingImagePropertyAssetCtrl* widget);
  56. QWidget* CreateGUI(QWidget* parent) override;
  57. void ConsumeAttribute(StreamingImagePropertyAssetCtrl* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
  58. void WriteGUIValuesIntoProperty(size_t index, StreamingImagePropertyAssetCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  59. bool ReadValuesIntoGUI(size_t index, StreamingImagePropertyAssetCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) override;
  60. AZ::Data::Asset<AZ::Data::AssetData>* CastTo(void* instance, const AzToolsFramework::InstanceDataNode* node, const AZ::Uuid& fromId, const AZ::Uuid& toId) const override;
  61. static void Register();
  62. };
  63. }