3
0

UiLayoutCellComponent.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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/UiLayoutCellBus.h>
  10. #include <LyShine/UiComponentTypes.h>
  11. #include <AzCore/Component/Component.h>
  12. ////////////////////////////////////////////////////////////////////////////////////////////////////
  13. //! This component allows the default layout cell properties to be overridden
  14. class UiLayoutCellComponent
  15. : public AZ::Component
  16. , public UiLayoutCellBus::Handler
  17. {
  18. public: // member functions
  19. AZ_COMPONENT(UiLayoutCellComponent, LyShine::UiLayoutCellComponentUuid, AZ::Component);
  20. UiLayoutCellComponent();
  21. ~UiLayoutCellComponent() override;
  22. // UiLayoutCellInterface
  23. float GetMinWidth() override;
  24. void SetMinWidth(float width) override;
  25. float GetMinHeight() override;
  26. void SetMinHeight(float height) override;
  27. float GetTargetWidth() override;
  28. void SetTargetWidth(float width) override;
  29. float GetTargetHeight() override;
  30. void SetTargetHeight(float height) override;
  31. float GetMaxWidth() override;
  32. void SetMaxWidth(float width) override;
  33. float GetMaxHeight() override;
  34. void SetMaxHeight(float height) override;
  35. float GetExtraWidthRatio() override;
  36. void SetExtraWidthRatio(float width) override;
  37. float GetExtraHeightRatio() override;
  38. void SetExtraHeightRatio(float height) override;
  39. // ~UiLayoutCellInterface
  40. public: // static member functions
  41. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
  42. {
  43. provided.push_back(AZ_CRC("UiLayoutCellService", 0x67ba28f2));
  44. }
  45. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
  46. {
  47. incompatible.push_back(AZ_CRC("UiLayoutCellService", 0x67ba28f2));
  48. }
  49. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  50. {
  51. required.push_back(AZ_CRC("UiElementService", 0x3dca7ad4));
  52. required.push_back(AZ_CRC("UiTransformService", 0x3a838e34));
  53. }
  54. static void Reflect(AZ::ReflectContext* context);
  55. protected: // member functions
  56. // AZ::Component
  57. void Activate() override;
  58. void Deactivate() override;
  59. // ~AZ::Component
  60. AZ_DISABLE_COPY_MOVE(UiLayoutCellComponent);
  61. //! Invalidate the layouts affected by layout cell properties. Called when a layout cell property has changed
  62. void InvalidateLayout();
  63. protected: // data
  64. //! Whether the minimum width has been overridden
  65. bool m_minWidthOverridden;
  66. //! The minimum width
  67. float m_minWidth;
  68. //! Whether the minimum height has been overridden
  69. bool m_minHeightOverridden;
  70. //! The minimum height
  71. float m_minHeight;
  72. //! Whether the target width has been overridden
  73. bool m_targetWidthOverridden;
  74. //! The target width
  75. float m_targetWidth;
  76. //! Whether the target height has been overridden
  77. bool m_targetHeightOverridden;
  78. //! The target height
  79. float m_targetHeight;
  80. //! Whether the max width has been overridden
  81. bool m_maxWidthOverridden;
  82. //! The max width
  83. float m_maxWidth;
  84. //! Whether the max height has been overridden
  85. bool m_maxHeightOverridden;
  86. //! The max height
  87. float m_maxHeight;
  88. //! Whether the extra width ratio has been overridden
  89. bool m_extraWidthRatioOverridden;
  90. //! The extra width ratio
  91. float m_extraWidthRatio;
  92. //! Whether the extra height ratio has been overridden
  93. bool m_extraHeightRatioOverridden;
  94. //! The extra height ratio
  95. float m_extraHeightRatio;
  96. };