@@ -425,35 +425,46 @@ def __str__(self):
425425
426426
427427class UIGridLayout (UILayout ):
428- """Place widgets in a grid .
428+ """Arranges each child widget over one or more columns and rows .
429429
430- Widgets can span multiple columns and rows.
431- By default, the layout will only use the minimal required space (``size_hint = (0, 0)``).
430+ The layout's ``size_hint`` requests a target size as a :py:class:`tuple`
431+ of ``(x, y)`` floats as ratios relative to the layout's parent:
432432
433- Widgets can provide a ``size_hint `` to request dynamic space relative to the layout size.
434- A size_hint of ``(1, 1)`` will fill the available space, while ``(0.1, 0.1)``
435- will use maximum 10% of the layouts total size.
433+ * The default of ``(0, 0) `` requests the minimum possible space
434+ * ``(1.0 , 1.0 )`` requests the maximum possible space
435+ * ``(0.1, 0.1)`` requests 10% of the layout parent's total size
436436
437- Children are resized based on ``size_hint``. Maximum and minimum
438- ``size_hint``s only take effect if a ``size_hint`` is given.
437+ Each child widget's ``size_hint`` value will be used to:
439438
440- The layouts ``size_hint_min`` is automatically
441- updated based on the minimal required space by children, after layouting.
439+ * control its size within the layout
440+ * automatically re-calculate the layout's ``size_hint_min``
442441
443- The width of columns and height of rows are calculated based on the size hints of the children.
444- The highest size_hint_min of a child in a column or row is used. If a child has no size_hint,
445- the actual size is considered.
442+ The width of each column and height of each row will be calculated
443+ on update by reading the sizing data of each child widget. For each
444+ row/column, the corresponding values along its axis will be read
445+ from widgets along its axis:
446+
447+ * the maximum ``size_hint_min`` of its widgets
448+ * the minimum ``size_hint_max`` of its widgets
449+
450+ If any widget lacks size hint data, its "actual" will be used instead.
451+ See :py:meth:`~.do_layout` to learn more.
452+
453+ .. note::
454+
455+ Maximum and minimum size hints only take effect when a ``size_hint``
456+ is set.
446457
447458 Args:
448459 x: ``x`` coordinate of bottom left corner.
449460 y: ``y`` coordinate of bottom left corner.
450461 width: Width of the layout.
451462 height: Height of the layout.
452- align_horizontal: Align children in orthogonal direction.
453- Options include `` left``, ``center``, and ``right``.
454- align_vertical: Align children in orthogonal direction. Options
455- include `` top``, ``center``, and ``bottom``.
456- children: Initial list of children. More can be added later.
463+ align_horizontal: Align children in along the X axis to the
464+ ``" left" ``, ``" center" ``, or ``" right" ``.
465+ align_vertical: Align children in along the Y axis to the
466+ ``" top" ``, ``" center" ``, or ``" bottom" ``.
467+ children: An initial iterable of children. More can be added later.
457468 size_hint: A size hint for :py:class:`~arcade.gui.UILayout`, if
458469 the :py:class:`~arcade.gui.UIWidget` would like to grow.
459470 size_hint_max: Maximum width and height in pixels.
@@ -651,18 +662,26 @@ def _update_size_hints(self):
651662 )
652663
653664 def do_layout (self ):
654- """Executes the layout algorithm.
655-
656- Children are placed in a grid layout based on the size hints.
665+ """Arrange children in the grid based on their size hints.
657666
658667 Algorithm
659668 ---------
660669
661- 0. generate list for all rows and columns
662- 1. per column, collect max of size_hint_min and max size_hint (widths)
663- 2. per row, collect max of size_hint_min and max size_hint (heights)
664- 3. use box layout algorithm to distribute space
665- 4. place widgets in grid layout
670+ 0. Generate lists of child widgets for each row and column
671+ 1. For each column, calculate the following values:
672+
673+ * If a widget lacks size hints, substitute the "actual" width instead
674+ * The :py:func:`max` of all its child ``size_hint_min[0]`` values
675+ * The :py:func:`max` of all its child ``size_hint[0]`` values
676+
677+ 2. For each row, calculate the following values:
678+
679+ * If a widget lacks size hints, substitute the "actual" height instead
680+ * The :py:func:`max` of all its child ``size_hint_min[1]`` values
681+ * The :py:func:`max` of all its child ``size_hint[1]`` values
682+
683+ 3. Use box layout algorithm to allocate on-screen space
684+ 4. Re-size and place the widgets to match the calculated grid layout
666685
667686 """
668687
0 commit comments