Skip to content

Latest commit

 

History

History
211 lines (120 loc) · 8.26 KB

class_aspectratiocontainer.rst

File metadata and controls

211 lines (120 loc) · 8.26 KB
github_url:hide

AspectRatioContainer

Inherits: :ref:`Container<class_Container>` < :ref:`Control<class_Control>` < :ref:`CanvasItem<class_CanvasItem>` < :ref:`Node<class_Node>` < :ref:`Object<class_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

.. rst-class:: classref-reftable-group

Properties

:ref:`AlignmentMode<enum_AspectRatioContainer_AlignmentMode>` :ref:`alignment_horizontal<class_AspectRatioContainer_property_alignment_horizontal>` 1
:ref:`AlignmentMode<enum_AspectRatioContainer_AlignmentMode>` :ref:`alignment_vertical<class_AspectRatioContainer_property_alignment_vertical>` 1
:ref:`float<class_float>` :ref:`ratio<class_AspectRatioContainer_property_ratio>` 1.0
:ref:`StretchMode<enum_AspectRatioContainer_StretchMode>` :ref:`stretch_mode<class_AspectRatioContainer_property_stretch_mode>` 2
.. rst-class:: classref-section-separator


.. rst-class:: classref-descriptions-group

Enumerations

.. rst-class:: classref-enumeration

enum StretchMode:

.. rst-class:: classref-enumeration-constant

:ref:`StretchMode<enum_AspectRatioContainer_StretchMode>` STRETCH_WIDTH_CONTROLS_HEIGHT = 0

The height of child controls is automatically adjusted based on the width of the container.

.. rst-class:: classref-enumeration-constant

:ref:`StretchMode<enum_AspectRatioContainer_StretchMode>` STRETCH_HEIGHT_CONTROLS_WIDTH = 1

The width of child controls is automatically adjusted based on the height of the container.

.. rst-class:: classref-enumeration-constant

:ref:`StretchMode<enum_AspectRatioContainer_StretchMode>` STRETCH_FIT = 2

The bounding rectangle of child controls is automatically adjusted to fit inside the container while keeping the aspect ratio.

.. rst-class:: classref-enumeration-constant

:ref:`StretchMode<enum_AspectRatioContainer_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<class_Control_property_clip_contents>` is enabled, this allows to show only the container's area restricted by its own bounding rectangle.

.. rst-class:: classref-item-separator


.. rst-class:: classref-enumeration

enum AlignmentMode:

.. rst-class:: classref-enumeration-constant

:ref:`AlignmentMode<enum_AspectRatioContainer_AlignmentMode>` ALIGNMENT_BEGIN = 0

Aligns child controls with the beginning (left or top) of the container.

.. rst-class:: classref-enumeration-constant

:ref:`AlignmentMode<enum_AspectRatioContainer_AlignmentMode>` ALIGNMENT_CENTER = 1

Aligns child controls with the center of the container.

.. rst-class:: classref-enumeration-constant

:ref:`AlignmentMode<enum_AspectRatioContainer_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

.. rst-class:: classref-property

:ref:`AlignmentMode<enum_AspectRatioContainer_AlignmentMode>` alignment_horizontal = 1

.. rst-class:: classref-property-setget

Specifies the horizontal relative position of child controls.

.. rst-class:: classref-item-separator


.. rst-class:: classref-property

:ref:`AlignmentMode<enum_AspectRatioContainer_AlignmentMode>` alignment_vertical = 1

.. rst-class:: classref-property-setget

Specifies the vertical relative position of child controls.

.. rst-class:: classref-item-separator


.. rst-class:: classref-property

:ref:`float<class_float>` ratio = 1.0

.. rst-class:: classref-property-setget

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>`.

.. rst-class:: classref-item-separator


.. rst-class:: classref-property

:ref:`StretchMode<enum_AspectRatioContainer_StretchMode>` stretch_mode = 2

.. rst-class:: classref-property-setget

The stretch mode used to align child controls.