MeasurePolicy

fun interface MeasurePolicy

How a container measures and places its children.

A policy is handed one Measurable per child and the Constraints the container was given, measures each child under constraints of its own working out, and answers with the extent it occupies and the placement of what it measured.

Row, Column and Box are each written as one of these.

Functions

Link copied to clipboard

The height beyond which growing measurables no longer reduces their width at width.

Link copied to clipboard

The width beyond which growing measurables no longer reduces their height at height.

Link copied to clipboard
abstract fun MeasureScope.measure(measurables: List<Measurable>, constraints: Constraints): MeasureResult

Measures measurables under constraints and answers the extent this container occupies, along with where each measured child goes inside it.

Link copied to clipboard
open fun MeasureScope.measureAtAssignedSize(measurables: List<Measurable>, width: Int, height: Int): MeasureResult

Measures measurables for the container's assigned inner bounds width by height, and returns where each measured child goes. A Swing parent that sets the container's bounds, or the container laying itself out, calls this; a Foundation parent calls measure. width and height exclude the container's insets and paint outsets. They are the container's own size, not an offer to its children: an override can offer its children any constraints and still return layout(width, height). Like measure, it measures each child at most once. The default calls measure with exact constraints for width and height.

Link copied to clipboard

The smallest height that lets measurables paint correctly when they are width wide.

Link copied to clipboard

The smallest width that lets measurables paint correctly when they are height tall.

Link copied to clipboard
open fun IntrinsicMeasureScope.preferredSize(measurables: List<IntrinsicMeasurable>, assignedWidth: Int?): Dimension

Returns the preferred size of this container for Swing's getPreferredSize(). assignedWidth is the inner width Swing has set on the container, or null where it has no positive width to offer, which includes every container under a Foundation parent; use it for height-for-width. The result excludes insets and paint outsets, which the container adds, and must be nonnegative, or getPreferredSize() throws IllegalArgumentException. Minimum size reads do not call this; they use the minimum intrinsic functions.