LayoutModifierNode

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

Layout modifiers nest in declaration order: the first one is outermost and measures the next one as its measurable. Use MeasureScope.layout to return this node's size and to place the placeable measured from that child.

A node launches an animation from its measure in coroutineScope, which lives from onAttach until onDetach cancels it.

Its placement can place the content with a layer; see PlacementScope.placeWithLayer.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open val additive: Boolean
Link copied to clipboard
Link copied to clipboard
val coroutineScope: CoroutineScope
Link copied to clipboard
Link copied to clipboard

The decorator this node paints its component with, at the node's position in the modifier, or null for none. It paints at the node's own box: the size measure reports, where the node is placed.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val key: Any
Link copied to clipboard
open val name: String
Link copied to clipboard

The capability of the element this node fills a slot for.

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
fun SwingModifier.alpha(@FloatRange(from = 0.0, to = 1.0) alpha: Float): SwingModifier

Paints the component at alpha of its opacity, content and children alike, cut to the decorated box as androidx's Modifier.alpha cuts it.

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

Fills shape's outline with color under the component's content; the solid-color overload of background.

fun SwingModifier.background(brush: Brush, shape: Shape = RectangleShape, @FloatRange(from = 0.0, to = 1.0) alpha: Float = 1.0f): SwingModifier

Fills shape's outline with brush under the component's content.

Link copied to clipboard

Softens everything inside it, by radius: the component's content, its border and its children.

Link copied to clipboard
fun SwingModifier.border(border: BorderStroke, shape: Shape = RectangleShape): SwingModifier

Draws border along the inside of shape's outline; the BorderStroke overload of border.

fun SwingModifier.border(width: Int, color: Color, shape: Shape = RectangleShape): SwingModifier

Draws a line width wide in color along the inside of shape's outline; the solid-color overload of border.

fun SwingModifier.border(width: Int, brush: Brush, shape: Shape = RectangleShape): SwingModifier

Draws a line width wide along the inside of shape's outline, over the content.

Link copied to clipboard
fun SwingModifier.clip(shape: Shape, antialias: Boolean = false): SwingModifier

Clips everything inside it to shape's outline - the component's content, its border and, on a container, its children.

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

Declares decorator on a component that paints through a decoration: a component implementing Decoratable. Any other component is refused, with an IllegalStateException naming Decoratable.

Declares element, whose DecorationModifierNode is one step of the component's decoration, such as a DrawModifierNode. It paints at its place among the other steps, as a declared Decorator does, so the component must be a Decoratable and element must be additive; either is refused, before the node attaches when element names Decoratable as its target type, or as the node attaches otherwise.

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

Draws onDraw into the component's area before the content declared after this modifier. A shortcut for a DrawModifierNode whose ContentDrawScope.drawContent runs after the block.

Link copied to clipboard

Draws onDraw into the component's area, letting the block decide when the content declared after this modifier is painted by calling ContentDrawScope.drawContent.

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
open override fun <R> foldIn(initial: R, operation: (R, SwingModifier.Element) -> R): R
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

This node at width by height as a placeable a container reads alignment lines from while it answers an intrinsic question, or null where it has none. A Row or Column asking for its own size reads a child's baseline or alignBy line from it, so the line holds where this node moves it.

Link copied to clipboard

Has the container measure this node's component again and lay it out by that measure. Called while a layout pass of the container measures the component, this does nothing: the running pass lays the component out by the measure it runs. Otherwise it takes effect at once, or, while a layout of the container or of a container around it may be running, once the running event is over, unless a layout pass of the container has measured the component since. A request made from a measure that a size query runs therefore leaves the size that query answered standing where a layout pass of the container measures the component after it. Does nothing before the container has received the node.

Link copied to clipboard

Has the container place this node's component again, without measuring it, by the last measure result and this node's state as it stands: a node updates its state first and calls this last. A node whose shouldAutoInvalidate is false calls this from an update that changes only where it places its content.

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

The greatest useful height this node reports when its child is width wide.

Link copied to clipboard

The greatest useful width this node reports when its child is height tall.

Link copied to clipboard
abstract fun MeasureScope.measure(measurable: Measurable, constraints: Constraints): MeasureResult

Measures measurable under constraints, and places it, with a layer or without one.

Link copied to clipboard

The least height this node reports when its child is width wide.

Link copied to clipboard

The least width this node reports when its child is height tall.

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.

Link copied to clipboard
open fun onAttach()
Link copied to clipboard
open fun onDetach()
Link copied to clipboard

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

Link copied to clipboard
open fun onReset()
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

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
fun SwingModifier.shadow(radius: Int, color: Color, offsetX: Int = 0, offsetY: Int = 0): SwingModifier

Casts a blurred shadow of everything inside it, into outsets the component grows by.

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
open infix fun then(other: SwingModifier): SwingModifier
Link copied to clipboard
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
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.