UiHierarchyInteractivityToggleComponent.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 <LyShine/Bus/UiHierarchyInteractivityToggleBus.h>
  10. #include <AzCore/Component/Component.h>
  11. #include <LyShine/Bus/UiInitializationBus.h>
  12. class UiHierarchyInteractivityToggleComponent
  13. : public AZ::Component
  14. , public UiInitializationBus::Handler
  15. , public UiHierarchyInteractivityToggleBus::Handler
  16. {
  17. public:
  18. AZ_COMPONENT_DECL(UiHierarchyInteractivityToggleComponent);
  19. static void Reflect(AZ::ReflectContext* context);
  20. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  21. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  22. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  23. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  24. //UiInitializationBus::Handler overrides..
  25. void InGamePostActivate() override;
  26. //~UiInitializationBus::Handler overrides...
  27. //UiHierarchyInteractivityToggleBus::Handler overrides..
  28. //! The root Method call used to manipulate the Interactive state.
  29. bool SetInteractivity(bool enabled) override;
  30. bool SetParentInteractivity(bool parentEnabled) override; //Used for child propagation.
  31. //! Getter to see the current interactive state.
  32. bool GetInteractiveState() override { return m_isInteractionLocallyEnabled && m_isInteractionParentEnabled; };
  33. //~UiHierarchyInteractivityToggleBus::Handler overrides...
  34. //Local Methods.
  35. void UpdateInteractiveState();
  36. void DoRecursiveSetInteractivityToChildren(const AZ::EntityId& parentId, bool parentState);
  37. void Activate() override;
  38. void Deactivate() override;
  39. protected:
  40. //State
  41. bool m_isInteractionLocallyEnabled = true;
  42. bool m_isInteractionParentEnabled = true;
  43. };