class_aspectratiocontainer.rst 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.5/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.5/doc/classes/AspectRatioContainer.xml.
  6. .. _class_AspectRatioContainer:
  7. AspectRatioContainer
  8. ====================
  9. **Inherits:** :ref:`Container<class_Container>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Container that preserves its child controls' aspect ratio.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Arranges child controls in a way to preserve their aspect ratio automatically whenever the container is resized. Solves the problem where the container size is dynamic and the contents' size needs to adjust accordingly without losing proportions.
  15. .. rst-class:: classref-introduction-group
  16. Tutorials
  17. ---------
  18. - :doc:`GUI containers <../tutorials/ui/gui_containers>`
  19. .. rst-class:: classref-reftable-group
  20. Properties
  21. ----------
  22. .. table::
  23. :widths: auto
  24. +-----------------------------------------------------------+---------------------------------------------------------------------------------------+---------+
  25. | :ref:`AlignMode<enum_AspectRatioContainer_AlignMode>` | :ref:`alignment_horizontal<class_AspectRatioContainer_property_alignment_horizontal>` | ``1`` |
  26. +-----------------------------------------------------------+---------------------------------------------------------------------------------------+---------+
  27. | :ref:`AlignMode<enum_AspectRatioContainer_AlignMode>` | :ref:`alignment_vertical<class_AspectRatioContainer_property_alignment_vertical>` | ``1`` |
  28. +-----------------------------------------------------------+---------------------------------------------------------------------------------------+---------+
  29. | :ref:`float<class_float>` | :ref:`ratio<class_AspectRatioContainer_property_ratio>` | ``1.0`` |
  30. +-----------------------------------------------------------+---------------------------------------------------------------------------------------+---------+
  31. | :ref:`StretchMode<enum_AspectRatioContainer_StretchMode>` | :ref:`stretch_mode<class_AspectRatioContainer_property_stretch_mode>` | ``2`` |
  32. +-----------------------------------------------------------+---------------------------------------------------------------------------------------+---------+
  33. .. rst-class:: classref-section-separator
  34. ----
  35. .. rst-class:: classref-descriptions-group
  36. Enumerations
  37. ------------
  38. .. _enum_AspectRatioContainer_StretchMode:
  39. .. rst-class:: classref-enumeration
  40. enum **StretchMode**:
  41. .. _class_AspectRatioContainer_constant_STRETCH_WIDTH_CONTROLS_HEIGHT:
  42. .. rst-class:: classref-enumeration-constant
  43. :ref:`StretchMode<enum_AspectRatioContainer_StretchMode>` **STRETCH_WIDTH_CONTROLS_HEIGHT** = ``0``
  44. The height of child controls is automatically adjusted based on the width of the container.
  45. .. _class_AspectRatioContainer_constant_STRETCH_HEIGHT_CONTROLS_WIDTH:
  46. .. rst-class:: classref-enumeration-constant
  47. :ref:`StretchMode<enum_AspectRatioContainer_StretchMode>` **STRETCH_HEIGHT_CONTROLS_WIDTH** = ``1``
  48. The width of child controls is automatically adjusted based on the height of the container.
  49. .. _class_AspectRatioContainer_constant_STRETCH_FIT:
  50. .. rst-class:: classref-enumeration-constant
  51. :ref:`StretchMode<enum_AspectRatioContainer_StretchMode>` **STRETCH_FIT** = ``2``
  52. The bounding rectangle of child controls is automatically adjusted to fit inside the container while keeping the aspect ratio.
  53. .. _class_AspectRatioContainer_constant_STRETCH_COVER:
  54. .. rst-class:: classref-enumeration-constant
  55. :ref:`StretchMode<enum_AspectRatioContainer_StretchMode>` **STRETCH_COVER** = ``3``
  56. The width and height of child controls is automatically adjusted to make their bounding rectangle cover the entire area of the container while keeping the aspect ratio.
  57. When the bounding rectangle of child controls exceed the container's size and :ref:`Control.rect_clip_content<class_Control_property_rect_clip_content>` is enabled, this allows to show only the container's area restricted by its own bounding rectangle.
  58. .. rst-class:: classref-item-separator
  59. ----
  60. .. _enum_AspectRatioContainer_AlignMode:
  61. .. rst-class:: classref-enumeration
  62. enum **AlignMode**:
  63. .. _class_AspectRatioContainer_constant_ALIGN_BEGIN:
  64. .. rst-class:: classref-enumeration-constant
  65. :ref:`AlignMode<enum_AspectRatioContainer_AlignMode>` **ALIGN_BEGIN** = ``0``
  66. Aligns child controls with the beginning (left or top) of the container.
  67. .. _class_AspectRatioContainer_constant_ALIGN_CENTER:
  68. .. rst-class:: classref-enumeration-constant
  69. :ref:`AlignMode<enum_AspectRatioContainer_AlignMode>` **ALIGN_CENTER** = ``1``
  70. Aligns child controls with the center of the container.
  71. .. _class_AspectRatioContainer_constant_ALIGN_END:
  72. .. rst-class:: classref-enumeration-constant
  73. :ref:`AlignMode<enum_AspectRatioContainer_AlignMode>` **ALIGN_END** = ``2``
  74. Aligns child controls with the end (right or bottom) of the container.
  75. .. rst-class:: classref-section-separator
  76. ----
  77. .. rst-class:: classref-descriptions-group
  78. Property Descriptions
  79. ---------------------
  80. .. _class_AspectRatioContainer_property_alignment_horizontal:
  81. .. rst-class:: classref-property
  82. :ref:`AlignMode<enum_AspectRatioContainer_AlignMode>` **alignment_horizontal** = ``1``
  83. .. rst-class:: classref-property-setget
  84. - void **set_alignment_horizontal** **(** :ref:`AlignMode<enum_AspectRatioContainer_AlignMode>` value **)**
  85. - :ref:`AlignMode<enum_AspectRatioContainer_AlignMode>` **get_alignment_horizontal** **(** **)**
  86. Specifies the horizontal relative position of child controls.
  87. .. rst-class:: classref-item-separator
  88. ----
  89. .. _class_AspectRatioContainer_property_alignment_vertical:
  90. .. rst-class:: classref-property
  91. :ref:`AlignMode<enum_AspectRatioContainer_AlignMode>` **alignment_vertical** = ``1``
  92. .. rst-class:: classref-property-setget
  93. - void **set_alignment_vertical** **(** :ref:`AlignMode<enum_AspectRatioContainer_AlignMode>` value **)**
  94. - :ref:`AlignMode<enum_AspectRatioContainer_AlignMode>` **get_alignment_vertical** **(** **)**
  95. Specifies the vertical relative position of child controls.
  96. .. rst-class:: classref-item-separator
  97. ----
  98. .. _class_AspectRatioContainer_property_ratio:
  99. .. rst-class:: classref-property
  100. :ref:`float<class_float>` **ratio** = ``1.0``
  101. .. rst-class:: classref-property-setget
  102. - void **set_ratio** **(** :ref:`float<class_float>` value **)**
  103. - :ref:`float<class_float>` **get_ratio** **(** **)**
  104. The aspect ratio to enforce on child controls. This is the width divided by the height. The ratio depends on the :ref:`stretch_mode<class_AspectRatioContainer_property_stretch_mode>`.
  105. .. rst-class:: classref-item-separator
  106. ----
  107. .. _class_AspectRatioContainer_property_stretch_mode:
  108. .. rst-class:: classref-property
  109. :ref:`StretchMode<enum_AspectRatioContainer_StretchMode>` **stretch_mode** = ``2``
  110. .. rst-class:: classref-property-setget
  111. - void **set_stretch_mode** **(** :ref:`StretchMode<enum_AspectRatioContainer_StretchMode>` value **)**
  112. - :ref:`StretchMode<enum_AspectRatioContainer_StretchMode>` **get_stretch_mode** **(** **)**
  113. The stretch mode used to align child controls.
  114. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  115. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  116. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  117. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`