EditorGradientTransformComponent.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 "EditorGradientTransformComponent.h"
  9. #include <LmbrCentral/Dependency/DependencyNotificationBus.h>
  10. #include <AzToolsFramework/API/ToolsApplicationAPI.h>
  11. namespace GradientSignal
  12. {
  13. void EditorGradientTransformComponent::Reflect(AZ::ReflectContext* context)
  14. {
  15. BaseClassType::ReflectSubClass<EditorGradientTransformComponent, BaseClassType>(context, 1, &LmbrCentral::EditorWrappedComponentBaseVersionConverter<typename BaseClassType::WrappedComponentType, typename BaseClassType::WrappedConfigType,1>);
  16. }
  17. void EditorGradientTransformComponent::Activate()
  18. {
  19. BaseClassType::Activate();
  20. AzToolsFramework::EditorVisibilityNotificationBus::Handler::BusConnect(GetEntityId());
  21. LmbrCentral::DependencyNotificationBus::Handler::BusConnect(GetEntityId());
  22. UpdateFromShape();
  23. }
  24. void EditorGradientTransformComponent::Deactivate()
  25. {
  26. //ensure that we disconnect from any observed buses on teardown
  27. LmbrCentral::DependencyNotificationBus::Handler::BusDisconnect();
  28. LmbrCentral::DependencyNotificationBus::Handler::BusDisconnect();
  29. BaseClassType::Deactivate();
  30. }
  31. AZ::u32 EditorGradientTransformComponent::ConfigurationChanged()
  32. {
  33. BaseClassType::ConfigurationChanged();
  34. UpdateFromShape();
  35. // Refresh attributes because changing shapes affects read-only status of bounds
  36. return AZ::Edit::PropertyRefreshLevels::AttributesAndValues;
  37. }
  38. void EditorGradientTransformComponent::OnCompositionChanged()
  39. {
  40. UpdateFromShape();
  41. InvalidatePropertyDisplay(AzToolsFramework::Refresh_AttributesAndValues);
  42. }
  43. void EditorGradientTransformComponent::UpdateFromShape()
  44. {
  45. if (m_runtimeComponentActive)
  46. {
  47. // Update config from shape on game component, copy that back to our config.
  48. bool notifyDependentsOfChange = true;
  49. m_component.UpdateFromShape(notifyDependentsOfChange);
  50. auto oldConfig = m_configuration;
  51. m_component.WriteOutConfig(&m_configuration);
  52. if (oldConfig != m_configuration)
  53. {
  54. SetDirty();
  55. }
  56. }
  57. }
  58. } //namespace GradientSignal