GradientSignalEditorModule.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. #include <GradientSignalEditorModule.h>
  9. #include <Editor/EditorSurfaceAltitudeGradientComponent.h>
  10. #include <Editor/EditorSmoothStepGradientComponent.h>
  11. #include <Editor/EditorSurfaceSlopeGradientComponent.h>
  12. #include <Editor/EditorMixedGradientComponent.h>
  13. #include <Editor/EditorImageGradientComponent.h>
  14. #include <Editor/EditorConstantGradientComponent.h>
  15. #include <Editor/EditorThresholdGradientComponent.h>
  16. #include <Editor/EditorLevelsGradientComponent.h>
  17. #include <Editor/EditorReferenceGradientComponent.h>
  18. #include <Editor/EditorInvertGradientComponent.h>
  19. #include <Editor/EditorDitherGradientComponent.h>
  20. #include <Editor/EditorPosterizeGradientComponent.h>
  21. #include <Editor/EditorShapeAreaFalloffGradientComponent.h>
  22. #include <Editor/EditorPerlinGradientComponent.h>
  23. #include <Editor/EditorRandomGradientComponent.h>
  24. #include <Editor/EditorGradientTransformComponent.h>
  25. #include <Editor/EditorStreamingImageAssetCtrl.h>
  26. #include <Editor/EditorSurfaceMaskGradientComponent.h>
  27. #include <Editor/EditorGradientSurfaceDataComponent.h>
  28. #include <GradientSignal/Editor/GradientPreviewer.h>
  29. #include <GradientSignal/Editor/EditorGradientBakerComponent.h>
  30. #include <GradientSignal/Editor/EditorGradientComponentBase.h>
  31. #include <GradientSignal/Editor/PaintableImageAssetHelper.h>
  32. #include <UI/GradientPreviewDataWidget.h>
  33. namespace GradientSignal
  34. {
  35. GradientSignalEditorModule::GradientSignalEditorModule()
  36. {
  37. m_descriptors.insert(m_descriptors.end(), {
  38. GradientSignalEditorSystemComponent::CreateDescriptor(),
  39. EditorGradientBakerComponent::CreateDescriptor(),
  40. EditorSurfaceAltitudeGradientComponent::CreateDescriptor(),
  41. EditorSmoothStepGradientComponent::CreateDescriptor(),
  42. EditorSurfaceSlopeGradientComponent::CreateDescriptor(),
  43. EditorMixedGradientComponent::CreateDescriptor(),
  44. EditorImageGradientComponent::CreateDescriptor(),
  45. EditorConstantGradientComponent::CreateDescriptor(),
  46. EditorThresholdGradientComponent::CreateDescriptor(),
  47. EditorLevelsGradientComponent::CreateDescriptor(),
  48. EditorReferenceGradientComponent::CreateDescriptor(),
  49. EditorInvertGradientComponent::CreateDescriptor(),
  50. EditorDitherGradientComponent::CreateDescriptor(),
  51. EditorPosterizeGradientComponent::CreateDescriptor(),
  52. EditorShapeAreaFalloffGradientComponent::CreateDescriptor(),
  53. EditorPerlinGradientComponent::CreateDescriptor(),
  54. EditorRandomGradientComponent::CreateDescriptor(),
  55. EditorGradientTransformComponent::CreateDescriptor(),
  56. EditorSurfaceMaskGradientComponent::CreateDescriptor(),
  57. EditorGradientSurfaceDataComponent::CreateDescriptor(),
  58. });
  59. }
  60. AZ::ComponentTypeList GradientSignalEditorModule::GetRequiredSystemComponents() const
  61. {
  62. AZ::ComponentTypeList requiredComponents = GradientSignalModule::GetRequiredSystemComponents();
  63. requiredComponents.push_back(azrtti_typeid<GradientSignalEditorSystemComponent>());
  64. return requiredComponents;
  65. }
  66. void GradientSignalEditorSystemComponent::Reflect(AZ::ReflectContext* context)
  67. {
  68. GradientPreviewer::Reflect(context);
  69. ImageCreatorUtils::PaintableImageAssetHelper<EditorImageGradientComponent, EditorImageGradientComponentMode>::Reflect(context);
  70. if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  71. {
  72. serializeContext->Class<GradientSignalEditorSystemComponent, AZ::Component>()
  73. ->Version(0)
  74. ;
  75. if (auto editContext = serializeContext->GetEditContext())
  76. {
  77. editContext->Class<GradientSignalEditorSystemComponent>("GradientSignalEditorSystemComponent", "Handles registration of the gradient preview data widget handler")
  78. ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
  79. ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
  80. ;
  81. }
  82. }
  83. }
  84. void GradientSignalEditorSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  85. {
  86. provided.push_back(AZ_CRC_CE("GradientSignalEditorService"));
  87. }
  88. void GradientSignalEditorSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  89. {
  90. incompatible.push_back(AZ_CRC_CE("GradientSignalEditorService"));
  91. }
  92. void GradientSignalEditorSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  93. {
  94. required.push_back(AZ_CRC_CE("PropertyManagerService"));
  95. }
  96. void GradientSignalEditorSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& /*dependent*/)
  97. {
  98. }
  99. void GradientSignalEditorSystemComponent::OnActionContextModeBindingHook()
  100. {
  101. EditorImageGradientComponentMode::BindActionsToModes();
  102. }
  103. void GradientSignalEditorSystemComponent::Activate()
  104. {
  105. GradientPreviewDataWidgetHandler::Register();
  106. StreamingImagePropertyHandler::Register();
  107. AzToolsFramework::ActionManagerRegistrationNotificationBus::Handler::BusConnect();
  108. }
  109. void GradientSignalEditorSystemComponent::Deactivate()
  110. {
  111. AzToolsFramework::ActionManagerRegistrationNotificationBus::Handler::BusDisconnect();
  112. GradientPreviewDataWidgetHandler::Unregister();
  113. // We don't need to unregister the StreamingImagePropertyHandler
  114. // because its set to auto-delete (default)
  115. }
  116. }
  117. #if defined(O3DE_GEM_NAME)
  118. AZ_DECLARE_MODULE_CLASS(AZ_JOIN(Gem_, O3DE_GEM_NAME, _Editor), GradientSignal::GradientSignalEditorModule)
  119. #else
  120. AZ_DECLARE_MODULE_CLASS(Gem_GradientSignal_Editor, GradientSignal::GradientSignalEditorModule)
  121. #endif