LayoutModifierNodeElement

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.

Its equals decides whether a later declaration updates the node: an equal one leaves the node as it is, and an unequal one runs update, after which the child is measured again unless the node's shouldAutoInvalidate is false.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
override val additive: Boolean

Layout modifiers wrap one another, so every declaration remains in order.

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 a Foundation Layout must support to interpret this modifier.

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
abstract fun create(): N
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
abstract operator override fun equals(other: Any?): Boolean
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
abstract override fun hashCode(): Int
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
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
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

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

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
abstract fun update(node: N)
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.