GradientPreviewDataWidget.h 2.8 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. #include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
  10. #include <GradientSignal/Ebuses/GradientPreviewRequestBus.h>
  11. #include <GradientSignal/GradientSampler.h>
  12. #include <UI/GradientPreviewWidget.h>
  13. #include <LmbrCentral/Dependency/DependencyMonitor.h>
  14. #include <LmbrCentral/Dependency/DependencyNotificationBus.h>
  15. #include <QWidget>
  16. namespace GradientSignal
  17. {
  18. class GradientPreviewWidget;
  19. class GradientPreviewDataWidget
  20. : public QWidget
  21. , public LmbrCentral::DependencyNotificationBus::Handler
  22. , public GradientPreviewRequestBus::Handler
  23. {
  24. public:
  25. GradientPreviewDataWidget(QWidget* parent = nullptr);
  26. ~GradientPreviewDataWidget() override;
  27. void SetGradientSampler(const GradientSampler& sampler);
  28. void SetGradientSampleFilter(GradientPreviewWidget::SampleFilterFunc sampleFunc);
  29. void SetGradientEntity(const AZ::EntityId& id);
  30. //////////////////////////////////////////////////////////////////////////
  31. // LmbrCentral::DependencyNotificationBus::Handler
  32. void OnCompositionChanged() override;
  33. //////////////////////////////////////////////////////////////////////////
  34. // GradientPreviewRequestBus::Handler
  35. void Refresh() override;
  36. AZ::EntityId CancelRefresh() override;
  37. void PreventRefresh(bool preventRefresh);
  38. private:
  39. GradientPreviewWidget::SampleFilterFunc m_sampleFilterFunc;
  40. GradientSampler m_sampler;
  41. GradientPreviewWidget* m_preview = nullptr;
  42. GradientPreviewWidget* m_previewWindow = nullptr;
  43. AZ::EntityId m_observerEntityStub;
  44. LmbrCentral::DependencyMonitor m_dependencyMonitor;
  45. bool m_refreshInProgress = false;
  46. bool m_preventRefresh = false;
  47. bool m_refreshQueued = false;
  48. };
  49. class GradientPreviewDataWidgetHandler
  50. : public AzToolsFramework::GenericPropertyHandler<GradientPreviewDataWidget>
  51. {
  52. public:
  53. AZ_CLASS_ALLOCATOR(GradientPreviewDataWidgetHandler, AZ::SystemAllocator);
  54. AZ::u32 GetHandlerName() const override;
  55. bool ReadValueIntoGUI(size_t index, GradientPreviewDataWidget* GUI, void* value, const AZ::Uuid& propertyType) override;
  56. void ConsumeAttribute(GradientPreviewDataWidget* GUI, AZ::u32 attrib, AzToolsFramework::PropertyAttributeReader* attrValue, const char* debugName) override;
  57. QWidget* CreateGUI(QWidget* pParent) override;
  58. void PreventRefresh(QWidget* widget, bool shouldPrevent) override;
  59. static void Register();
  60. static void Unregister();
  61. };
  62. }