UiNavigationHelpers.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/UiTransformBus.h>
  10. #include <AzFramework/Input/Channels/InputChannelDigitalWithSharedModifierKeyStates.h>
  11. #include <LyShine/UiBase.h>
  12. namespace AzFramework
  13. {
  14. class InputChannelId;
  15. }
  16. namespace UiNavigationHelpers
  17. {
  18. enum class Command
  19. {
  20. Up,
  21. Down,
  22. Left,
  23. Right,
  24. Enter,
  25. Back,
  26. NavEnd,
  27. NavHome,
  28. Unknown
  29. };
  30. //! Map input channel ids to interactable ui commands
  31. UiNavigationHelpers::Command MapInputChannelIdToUiNavigationCommand(const AzFramework::InputChannelId& inputChannelId, AzFramework::ModifierKeyMask activeModifierKeys);
  32. using ValidationFunction = AZStd::function<bool(AZ::EntityId)>;
  33. //! Find the next element given the current element and a direction
  34. AZ::EntityId GetNextElement(AZ::EntityId curEntityId, Command command,
  35. const LyShine::EntityArray& navigableElements, AZ::EntityId defaultEntityId,
  36. ValidationFunction isValidResult, AZ::EntityId parentElement = AZ::EntityId());
  37. //! Find the next element in the given direction for automatic mode
  38. AZ::EntityId SearchForNextElement(AZ::EntityId curElement, Command command,
  39. const LyShine::EntityArray& navigableElements, AZ::EntityId parentElement = AZ::EntityId());
  40. //! Follow one of the custom links (used when navigation mode is custom)
  41. AZ::EntityId FollowCustomLink(AZ::EntityId curEntityId, Command command);
  42. //! Check if an interactable can be navigated to
  43. bool IsInteractableNavigable(AZ::EntityId interactableEntityId);
  44. //! Check if an element is an interactable that can be navigated to
  45. bool IsElementInteractableAndNavigable(AZ::EntityId entityId);
  46. //! Make a list of all navigable & interactable elements under the specified parent
  47. void FindNavigableInteractables(AZ::EntityId parentElement, AZ::EntityId ignoreElement, LyShine::EntityArray& result);
  48. //! Find the first ancestor that's a navigable interactable
  49. AZ::EntityId FindAncestorNavigableInteractable(AZ::EntityId childInteractable, bool ignoreAutoActivatedAncestors = false);
  50. } // namespace UiNavigationHelpers