3
0

UiButtonComponent.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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/UiInteractableBus.h>
  10. #include <LyShine/Bus/UiButtonBus.h>
  11. #include <LyShine/UiComponentTypes.h>
  12. #include "UiInteractableComponent.h"
  13. #include <AzCore/Serialization/SerializeContext.h>
  14. #include <AzCore/Math/Vector3.h>
  15. #include <LmbrCentral/Rendering/TextureAsset.h>
  16. ////////////////////////////////////////////////////////////////////////////////////////////////////
  17. class UiButtonComponent
  18. : public UiInteractableComponent
  19. , public UiButtonBus::Handler
  20. {
  21. public: // member functions
  22. AZ_COMPONENT(UiButtonComponent, LyShine::UiButtonComponentUuid, UiInteractableComponent);
  23. UiButtonComponent();
  24. ~UiButtonComponent() override;
  25. // UiInteractableInterface
  26. bool HandleReleased(AZ::Vector2 point) override;
  27. bool HandleEnterReleased() override;
  28. // ~UiInteractableInterface
  29. // UiButtonInterface
  30. OnClickCallback GetOnClickCallback() override;
  31. void SetOnClickCallback(OnClickCallback onClick) override;
  32. const LyShine::ActionName& GetOnClickActionName() override;
  33. void SetOnClickActionName(const LyShine::ActionName& actionName) override;
  34. // ~UiButtonInterface
  35. protected: // member functions
  36. // AZ::Component
  37. void Activate() override;
  38. void Deactivate() override;
  39. // ~AZ::Component
  40. protected: // static member functions
  41. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  42. {
  43. provided.push_back(AZ_CRC("UiInteractableService", 0x1d474c98));
  44. provided.push_back(AZ_CRC("UiNavigationService"));
  45. provided.push_back(AZ_CRC("UiStateActionsService"));
  46. }
  47. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  48. {
  49. incompatible.push_back(AZ_CRC("UiInteractableService", 0x1d474c98));
  50. incompatible.push_back(AZ_CRC("UiNavigationService"));
  51. incompatible.push_back(AZ_CRC("UiStateActionsService"));
  52. }
  53. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  54. {
  55. required.push_back(AZ_CRC("UiElementService", 0x3dca7ad4));
  56. required.push_back(AZ_CRC("UiTransformService", 0x3a838e34));
  57. }
  58. static void Reflect(AZ::ReflectContext* context);
  59. private: // member functions
  60. AZ_DISABLE_COPY_MOVE(UiButtonComponent);
  61. bool HandleReleasedCommon(const AZ::Vector2& point);
  62. private: // static member functions
  63. static bool VersionConverter(AZ::SerializeContext& context,
  64. AZ::SerializeContext::DataElementNode& classElement);
  65. private: // data
  66. OnClickCallback m_onClick;
  67. LyShine::ActionName m_actionName;
  68. };