3
0

UiDropTargetComponent.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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/UiDropTargetBus.h>
  10. #include <LyShine/UiComponentTypes.h>
  11. #include <AzCore/Component/Component.h>
  12. #include "UiInteractableState.h"
  13. #include "UiStateActionManager.h"
  14. #include "UiNavigationSettings.h"
  15. namespace AZ
  16. {
  17. class ReflectContext;
  18. }
  19. ////////////////////////////////////////////////////////////////////////////////////////////////////
  20. class UiDropTargetComponent
  21. : public AZ::Component
  22. , public UiDropTargetBus::Handler
  23. {
  24. public: // member functions
  25. AZ_COMPONENT(UiDropTargetComponent, LyShine::UiDropTargetComponentUuid, AZ::Component);
  26. UiDropTargetComponent();
  27. ~UiDropTargetComponent() override;
  28. // UiDropTargetInterface
  29. const LyShine::ActionName& GetOnDropActionName() override;
  30. void SetOnDropActionName(const LyShine::ActionName& actionName) override;
  31. void HandleDropHoverStart(AZ::EntityId draggable) override;
  32. void HandleDropHoverEnd(AZ::EntityId draggable) override;
  33. void HandleDrop(AZ::EntityId draggable) override;
  34. DropState GetDropState() override;
  35. void SetDropState(DropState dropState) override;
  36. // ~UiDropTargetInterface
  37. protected: // member functions
  38. // AZ::Component
  39. void Init() override;
  40. void Activate() override;
  41. void Deactivate() override;
  42. // ~AZ::Component
  43. void OnDropValidStateActionsChanged();
  44. void OnDropInvalidStateActionsChanged();
  45. protected: // static member functions
  46. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  47. {
  48. provided.push_back(AZ_CRC("UiDropTargetService", 0x39a63abd));
  49. provided.push_back(AZ_CRC("UiNavigationService"));
  50. provided.push_back(AZ_CRC("UiStateActionsService"));
  51. }
  52. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  53. {
  54. incompatible.push_back(AZ_CRC("UiDropTargetService", 0x39a63abd));
  55. incompatible.push_back(AZ_CRC("UiNavigationService"));
  56. incompatible.push_back(AZ_CRC("UiStateActionsService"));
  57. }
  58. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  59. {
  60. required.push_back(AZ_CRC("UiElementService", 0x3dca7ad4));
  61. required.push_back(AZ_CRC("UiTransformService", 0x3a838e34));
  62. }
  63. static void Reflect(AZ::ReflectContext* context);
  64. private: // member functions
  65. AZ_DISABLE_COPY_MOVE(UiDropTargetComponent);
  66. private: // static member functions
  67. //! Get the drop targets that could be valid options for custom navigation from this drop target
  68. static LyShine::EntityArray GetNavigableDropTargets(AZ::EntityId sourceEntity);
  69. private: // persistent data
  70. using StateActions = AZStd::vector<UiInteractableStateAction*>;
  71. //! Dragging state action properties - allow visual states to be defined
  72. StateActions m_dropValidStateActions;
  73. StateActions m_dropInvalidStateActions;
  74. private: // data
  75. LyShine::ActionName m_onDropActionName;
  76. DropState m_dropState;
  77. UiStateActionManager m_stateActionManager;
  78. UiNavigationSettings m_navigationSettings;
  79. };