:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/AspectRatioContainer.xml. .. _class_AspectRatioContainer: AspectRatioContainer ==================== **Inherits:** :ref:`Container` **<** :ref:`Control` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` A container that preserves the proportions of its child controls. .. rst-class:: classref-introduction-group Description ----------- A container type that arranges its child controls in a way that preserves their proportions automatically when the container is resized. Useful when a container has a dynamic size and the child nodes must adjust their sizes accordingly without losing their aspect ratios. .. rst-class:: classref-introduction-group Tutorials --------- - :doc:`Using Containers <../tutorials/ui/gui_containers>` .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +---------------------------------------------------------------+---------------------------------------------------------------------------------------+---------+ | :ref:`AlignmentMode` | :ref:`alignment_horizontal` | ``1`` | +---------------------------------------------------------------+---------------------------------------------------------------------------------------+---------+ | :ref:`AlignmentMode` | :ref:`alignment_vertical` | ``1`` | +---------------------------------------------------------------+---------------------------------------------------------------------------------------+---------+ | :ref:`float` | :ref:`ratio` | ``1.0`` | +---------------------------------------------------------------+---------------------------------------------------------------------------------------+---------+ | :ref:`StretchMode` | :ref:`stretch_mode` | ``2`` | +---------------------------------------------------------------+---------------------------------------------------------------------------------------+---------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Enumerations ------------ .. _enum_AspectRatioContainer_StretchMode: .. rst-class:: classref-enumeration enum **StretchMode**: :ref:`🔗` .. _class_AspectRatioContainer_constant_STRETCH_WIDTH_CONTROLS_HEIGHT: .. rst-class:: classref-enumeration-constant :ref:`StretchMode` **STRETCH_WIDTH_CONTROLS_HEIGHT** = ``0`` The height of child controls is automatically adjusted based on the width of the container. .. _class_AspectRatioContainer_constant_STRETCH_HEIGHT_CONTROLS_WIDTH: .. rst-class:: classref-enumeration-constant :ref:`StretchMode` **STRETCH_HEIGHT_CONTROLS_WIDTH** = ``1`` The width of child controls is automatically adjusted based on the height of the container. .. _class_AspectRatioContainer_constant_STRETCH_FIT: .. rst-class:: classref-enumeration-constant :ref:`StretchMode` **STRETCH_FIT** = ``2`` The bounding rectangle of child controls is automatically adjusted to fit inside the container while keeping the aspect ratio. .. _class_AspectRatioContainer_constant_STRETCH_COVER: .. rst-class:: classref-enumeration-constant :ref:`StretchMode` **STRETCH_COVER** = ``3`` 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. When the bounding rectangle of child controls exceed the container's size and :ref:`Control.clip_contents` is enabled, this allows to show only the container's area restricted by its own bounding rectangle. .. rst-class:: classref-item-separator ---- .. _enum_AspectRatioContainer_AlignmentMode: .. rst-class:: classref-enumeration enum **AlignmentMode**: :ref:`🔗` .. _class_AspectRatioContainer_constant_ALIGNMENT_BEGIN: .. rst-class:: classref-enumeration-constant :ref:`AlignmentMode` **ALIGNMENT_BEGIN** = ``0`` Aligns child controls with the beginning (left or top) of the container. .. _class_AspectRatioContainer_constant_ALIGNMENT_CENTER: .. rst-class:: classref-enumeration-constant :ref:`AlignmentMode` **ALIGNMENT_CENTER** = ``1`` Aligns child controls with the center of the container. .. _class_AspectRatioContainer_constant_ALIGNMENT_END: .. rst-class:: classref-enumeration-constant :ref:`AlignmentMode` **ALIGNMENT_END** = ``2`` Aligns child controls with the end (right or bottom) of the container. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_AspectRatioContainer_property_alignment_horizontal: .. rst-class:: classref-property :ref:`AlignmentMode` **alignment_horizontal** = ``1`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_alignment_horizontal**\ (\ value\: :ref:`AlignmentMode`\ ) - :ref:`AlignmentMode` **get_alignment_horizontal**\ (\ ) Specifies the horizontal relative position of child controls. .. rst-class:: classref-item-separator ---- .. _class_AspectRatioContainer_property_alignment_vertical: .. rst-class:: classref-property :ref:`AlignmentMode` **alignment_vertical** = ``1`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_alignment_vertical**\ (\ value\: :ref:`AlignmentMode`\ ) - :ref:`AlignmentMode` **get_alignment_vertical**\ (\ ) Specifies the vertical relative position of child controls. .. rst-class:: classref-item-separator ---- .. _class_AspectRatioContainer_property_ratio: .. rst-class:: classref-property :ref:`float` **ratio** = ``1.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_ratio**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_ratio**\ (\ ) The aspect ratio to enforce on child controls. This is the width divided by the height. The ratio depends on the :ref:`stretch_mode`. .. rst-class:: classref-item-separator ---- .. _class_AspectRatioContainer_property_stretch_mode: .. rst-class:: classref-property :ref:`StretchMode` **stretch_mode** = ``2`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_stretch_mode**\ (\ value\: :ref:`StretchMode`\ ) - :ref:`StretchMode` **get_stretch_mode**\ (\ ) The stretch mode used to align child controls. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`