Package-level declarations

Types

Link copied to clipboard

The standard alignments unaware of ComponentOrientation: a horizontal bias of -1 always resolves to the left and 1 to the right, neither mirrored under a right-to-left orientation the way Alignment's own constants are.

Link copied to clipboard
@Stable
fun interface Alignment

Where a child sits within the extent its container offers it: an Alignment places a child across both axes of a Box, an Alignment.Horizontal across a Column, an Alignment.Vertical across a Row.

Link copied to clipboard
sealed class AlignmentLine

An offset line a measured layout exposes to its parent for alignment.

Link copied to clipboard
@Immutable
object Arrangement

How a Row or Column places its children along the axis it arranges them on, and how much space it leaves between two adjacent children.

Link copied to clipboard
@Immutable
data class BiasAbsoluteAlignment(val horizontalBias: Float, val verticalBias: Float) : Alignment

Places a child according to horizontal and vertical biases without mirroring under a right-to-left component orientation.

Link copied to clipboard
@Immutable
data class BiasAlignment(val horizontalBias: Float, val verticalBias: Float) : Alignment

Places a child at a bias through the space it leaves free: -1 at the leading edge, 0 centered, 1 at the trailing edge, and any other value proportionally, which puts a bias outside -1..1 partly or wholly outside that space. A right-to-left orientation mirrors the horizontal bias.

Link copied to clipboard
sealed interface BoxScope : ConstrainedScope

The receiver of a Box's content, through which a child declares its own placement in that box.

Link copied to clipboard
sealed interface ColumnScope : ConstrainedScope

The receiver of a Column's content, through which a child declares its own placement in that column.

Link copied to clipboard
interface Constrainable

A component that reports what extent it takes under given constraints, and its intrinsic sizes at a given extent.

Link copied to clipboard

The scope of a container whose child stands between the constraints that container offers it and its own measurement: a fill, a padding, an offset, an aspect ratio or a default minimum size each narrows what reaches the child, states what the child plus its own space occupies, and places the child inside that.

Link copied to clipboard
class Constraints(val minWidth: Int = 0, val maxWidth: Int = Int.MAX_VALUE, val minHeight: Int = 0, val maxHeight: Int = Int.MAX_VALUE)

The extents a parent offers a child: the least it must occupy along each axis and the most it may.

Link copied to clipboard

A line whose position is measured from the top or bottom edge, such as a text baseline.

Link copied to clipboard
sealed interface IntrinsicMeasurable

A child as a MeasurePolicy asks about its unconstrained, axis-specific dimensions.

Link copied to clipboard
sealed interface IntrinsicMeasureScope

The receiver of a MeasurePolicy's four intrinsic measurement functions.

Link copied to clipboard

Which of a child's two intrinsic answers an intrinsic size modifier uses.

Link copied to clipboard

The node a LayoutModifierNodeElement creates once per slot and keeps for as long as an element of that type fills it.

Link copied to clipboard

A layout modifier: declares a LayoutModifierNode that measures one child between the constraints its parent offers and the result it reports back, and keeps its state across passes, such as an animation mid-flight. A child declares one through ConstrainedScope.layout.

Link copied to clipboard

A stable token for parent data a Layout policy reads through Measurable.parentData.

Link copied to clipboard
sealed interface Measurable : IntrinsicMeasurable

One child of a container that can answer both intrinsic and constrained measurement questions.

Link copied to clipboard
fun interface MeasurePolicy

How a container measures and places its children.

Link copied to clipboard
interface MeasureResult

What a MeasurePolicy settled on: the raw extent the container measured itself to, and where its children go in it.

Link copied to clipboard

The receiver a MeasurePolicy or a LayoutModifierNode measures in, and the one way it answers.

Link copied to clipboard
@Stable
interface PaintOutsets

Which part of a component's getInsets() is paint outsets: space it paints past its layout box, such as a focus ring or a shadow. A Foundation parent leaves them out of the layout box; a Swing parent clips the part that is the component's decoration. A component that is not a JComponent is never asked about, and keeps its layout box under every value. Declare it as a top-level object or a class with equals: a value that is unequal on each recomposition measures the whole subtree again every pass.

Link copied to clipboard
sealed class Placeable

A child measured, and the handle its container places it by.

Link copied to clipboard
sealed interface PlacementLayerScope

The properties of the layer PlacementScope.placeWithLayer places a child with, which its layerBlock sets, as androidx's GraphicsLayerScope does for a graphics layer.

Link copied to clipboard
sealed class PlacementScope

The receiver a MeasureResult places its children in, from a MeasurePolicy or a LayoutModifierNode.

Link copied to clipboard
sealed interface RowScope : ConstrainedScope

The receiver of a Row's content, through which a child declares its own placement in that row.

Link copied to clipboard

A line whose position is measured from the left or right edge.

Properties

Link copied to clipboard

Key for the default PaintOutsets value applied to descendants via paintOutsets.

Link copied to clipboard

The baseline of a child's first line of text: where java.awt.Component.getBaseline puts it, or where a MeasurePolicy or a LayoutModifierNode names it in MeasureResult.alignmentLines.

Link copied to clipboard

Functions

Link copied to clipboard

Moves the child by (x, y) from where it would otherwise sit, neither axis moved by default, the same under a right-to-left reading order as under a left-to-right one; see offset for an offset that follows the reading order instead.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.absolutePadding(left: Int = 0, top: Int = 0, right: Int = 0, bottom: Int = 0): SwingModifier

Reserves left, top, right and bottom along the child's edges, each left unreserved by default, the same under a right-to-left reading order as under a left-to-right one; see padding for a padding that follows the reading order instead.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.aspectRatio(@FloatRange(from = 0.0, fromInclusive = false) ratio: Float, matchHeightConstraintsFirst: Boolean = false): SwingModifier

Sizes the child to ratio width per unit height, taking the size from the greatest width its incoming constraints allow, then the greatest height, then the least width and the least height, and stopping at the first of those that satisfies both the constraints and the ratio. Where none of them does, the constraints are not respected: the child takes the size the first of those extents that names a size at all implies at the ratio, and only where none of them names one is the child measured under the incoming constraints unchanged.

Link copied to clipboard
@Composable
fun Box(modifier: SwingModifier = SwingModifier)

A box with no content that can participate in layout, drawing, and input through its modifier.

@Composable
inline fun Box(modifier: SwingModifier = SwingModifier, contentAlignment: Alignment = Alignment.TopStart, propagateMinConstraints: Boolean = false, crossinline content: @Composable BoxScope.() -> Unit)

A composable that stacks its content in one place, one child over another.

Link copied to clipboard

Clips the child's paint, and its descendants', to the box the modifiers after this one report for it, even where a modifier further along places something larger, such as a size transition mid-flight. A decoration declared before it is not clipped, and one declared after it is.

Link copied to clipboard
@Composable
inline fun Column(modifier: SwingModifier = SwingModifier, verticalArrangement: Arrangement.Vertical = Arrangement.Top, horizontalAlignment: Alignment.Horizontal = Alignment.Start, crossinline content: @Composable ColumnScope.() -> Unit)

A composable that arranges its content vertically, top to bottom.

Link copied to clipboard

Takes a size and returns the closest size to it that satisfies the constraints.

Takes otherConstraints and returns the result of coercing them in the current constraints. Note this means that any size satisfying the resulting constraints will satisfy the current constraints, but they might not satisfy the otherConstraints when the two set of constraints are disjoint. Examples (showing only width, height works the same): (minWidth=2, maxWidth=10).constrain(minWidth=7, maxWidth=12) -> (minWidth = 7, maxWidth = 10) (minWidth=2, maxWidth=10).constrain(minWidth=11, maxWidth=12) -> (minWidth=10, maxWidth=10) (minWidth=2, maxWidth=10).constrain(minWidth=5, maxWidth=7) -> (minWidth=5, maxWidth=7)

Link copied to clipboard
@Stable
fun Constraints.constrainHeight(height: Int): Int

Takes a height and returns the closest size to it that satisfies the constraints.

Link copied to clipboard
@Stable
fun Constraints.constrainWidth(width: Int): Int

Takes a width and returns the closest size to it that satisfies the constraints.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.defaultMinSize(minWidth: Int? = null, minHeight: Int? = null): SwingModifier

Raises the child's minimum size to minWidth by minHeight along whichever axis its incoming constraints leave a minimum of zero on. An axis already claiming a minimum is left as it is, and the minimum raised to is held between nothing and the space the child was offered, so a child in a container smaller than the minimum takes the container.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.fillMaxHeight(@FloatRange(from = 0.0, to = 1.0) fraction: Float = 1.0f): SwingModifier

Makes the child occupy fraction of the greatest bounded height its parent offers it. The result is held between the offered minimum and maximum height. An unbounded height is left unchanged.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.fillMaxSize(@FloatRange(from = 0.0, to = 1.0) fraction: Float = 1.0f): SwingModifier

Makes the child occupy fraction of the greatest bounded width and height its parent offers it. Each result is held between the offered minimum and maximum. Either unbounded axis is left unchanged.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.fillMaxWidth(@FloatRange(from = 0.0, to = 1.0) fraction: Float = 1.0f): SwingModifier

Makes the child occupy fraction of the greatest bounded width its parent offers it. The result is held between the offered minimum and maximum width. An unbounded width is left unchanged.

Link copied to clipboard

Prefers an exact height, while still allowing the constraints the parent offers to override it.

Prefers the child's intrinsicSize height, while still allowing the constraints the parent offers to override it.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.heightIn(min: Int? = null, max: Int? = null): SwingModifier

Prefers a height between min and max, with either bound absent when it is null. The constraints the parent offers still take precedence.

Link copied to clipboard

Takes a size and returns whether it satisfies the current constraints.

Link copied to clipboard
@Composable
fun Layout(measurePolicy: MeasurePolicy, modifier: SwingModifier = SwingModifier)

A Layout with no children that can participate in layout, drawing, and input through modifier.

@Composable
fun Layout(measurePolicy: MeasurePolicy, modifier: SwingModifier = SwingModifier, parentDataProtocol: LayoutParentDataProtocol? = null, content: @Composable ConstrainedScope.() -> Unit = {})

A composable that measures and places its content by a MeasurePolicy of your own: a container whose placement rules you write, with no LayoutManager to go with them.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.layout(measure: MeasureScope.(measurable: Measurable, constraints: Constraints) -> MeasureResult): SwingModifier

Measures and places the child with measure, a layout modifier written as a lambda: measure measures the child's measurable under the constraints it is handed, and answers with MeasureScope.layout.

Link copied to clipboard

Creates a stable token for parent data a Layout policy reads through Measurable.parentData.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.offset(x: Int = 0, y: Int = 0): SwingModifier

Moves the child by (x, y) from where it would otherwise sit, neither axis moved by default, without changing the space it measures into. A positive x moves the child toward the trailing edge: right under a left-to-right reading order and left under a right-to-left one. See absoluteOffset for an offset that always moves it toward the right.

@Stable
fun Constraints.offset(horizontal: Int = 0, vertical: Int = 0): Constraints

Returns the Constraints obtained by offsetting the current instance with the given values.

Link copied to clipboard

Runs onPlaced with the bounds the component occupies in its parent whenever those bounds change.

Link copied to clipboard

Runs onSizeChanged with the extent the component occupies whenever its size changes.

Link copied to clipboard

Reserves all along every edge of the child. A decoration declared before a padding paints over the space it reserves as well, as paint outsets: background(brush).padding(8) fills the child and the space around it.

context(scope: ConstrainedScope)
fun SwingModifier.padding(horizontal: Int = 0, vertical: Int = 0): SwingModifier

Reserves horizontal before and after the child along the reading order, and vertical above and below it, either pair left unreserved by default.

context(scope: ConstrainedScope)
fun SwingModifier.padding(start: Int = 0, top: Int = 0, end: Int = 0, bottom: Int = 0): SwingModifier

Reserves start before the child and end after it along the reading order, and top and bottom above and below it, each edge left unreserved by default. start and end swap edges under a right-to-left reading order; see absolutePadding for a padding that never does.

Link copied to clipboard

The same amount on every side, clamped to the insets; as emptyBorder(all).

fun PaintOutsets(top: Int, left: Int, bottom: Int, right: Int): PaintOutsets

A fixed amount, clamped per side to the insets; the order of emptyBorder(top, left, bottom, right).

Link copied to clipboard

Declares which part of this component's insets is paint outsets; see PaintOutsets. Under a Swing parent it changes only what a Decoratable reports and clips.

Link copied to clipboard

Requires an exact height, even where it is outside the constraints the parent offers.

Requires the child's intrinsicSize height, even where it is outside the constraints the parent offers.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.requiredHeightIn(min: Int? = null, max: Int? = null): SwingModifier

Requires a height inside the bounds named here, with either bound absent when it is null.

Link copied to clipboard

Requires an exact square size, even where it is outside the constraints the parent offers.

context(scope: ConstrainedScope)
fun SwingModifier.requiredSize(width: Int, height: Int): SwingModifier

Requires an exact width by height, even where either is outside the constraints the parent offers.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.requiredSizeIn(minWidth: Int? = null, minHeight: Int? = null, maxWidth: Int? = null, maxHeight: Int? = null): SwingModifier

Requires a size inside the bounds named here, with any null bound absent.

Link copied to clipboard

Requires an exact width, even where it is outside the constraints the parent offers.

Requires the child's intrinsicSize width, even where it is outside the constraints the parent offers.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.requiredWidthIn(min: Int? = null, max: Int? = null): SwingModifier

Requires a width inside the bounds named here, with either bound absent when it is null.

Link copied to clipboard
@Composable
inline fun Row(modifier: SwingModifier = SwingModifier, horizontalArrangement: Arrangement.Horizontal = Arrangement.Start, verticalAlignment: Alignment.Vertical = Alignment.Top, crossinline content: @Composable RowScope.() -> Unit)

A composable that arranges its content horizontally, along the panel's reading order.

Link copied to clipboard

Prefers an exact square size, while still allowing the constraints the parent offers to override it.

context(scope: ConstrainedScope)
fun SwingModifier.size(width: Int, height: Int): SwingModifier

Prefers an exact width by height, while still allowing the constraints the parent offers to override either extent.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.sizeIn(minWidth: Int? = null, minHeight: Int? = null, maxWidth: Int? = null, maxHeight: Int? = null): SwingModifier

Prefers a size inside the bounds named here, with any null bound absent. The constraints the parent offers still take precedence.

Link copied to clipboard

Prefers an exact width, while still allowing the constraints the parent offers to override it.

context(scope: ConstrainedScope)
fun SwingModifier.width(intrinsicSize: IntrinsicSize): SwingModifier

Prefers the child's intrinsicSize width, while still allowing the constraints the parent offers to override it.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.widthIn(min: Int? = null, max: Int? = null): SwingModifier

Prefers a width between min and max, with either bound absent when it is null. The constraints the parent offers still take precedence.

Link copied to clipboard

This measurable under a width offer from minWidth, in place of any offer it carries: its height is read at a width, it returns the same results as when measured under an offer from minWidth, held to that width, up to that width. Its width intrinsic reads are its own.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.wrapContentHeight(align: Alignment.Vertical = Alignment.CenterVertically, unbounded: Boolean = false): SwingModifier

Lets the child choose its height without the offered minimum and, where unbounded, maximum; it is placed within the resulting wrapper by align.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.wrapContentSize(align: Alignment = Alignment.Center, unbounded: Boolean = false): SwingModifier

Lets the child choose both extents without the offered minima and, where unbounded, maxima; it is placed within the resulting wrapper by align.

Link copied to clipboard
context(scope: ConstrainedScope)
fun SwingModifier.wrapContentWidth(align: Alignment.Horizontal = Alignment.CenterHorizontally, unbounded: Boolean = false): SwingModifier

Lets the child choose its width without the offered minimum and, where unbounded, maximum; it is placed within the resulting wrapper by align.

Link copied to clipboard

Places the child at zIndex in its container's paint and hit-testing order: a child with a larger value paints over, and receives a mouse event before, every sibling with a smaller one. Siblings with the same value keep the order they are declared in, the last on top, whatever order their container places them in. A child declaring none is at 0f.