SubspaceModifier

interface SubspaceModifier

Known direct subclasses
CombinedSubspaceModifier

A node in a SubspaceModifier chain.

SubspaceModifier.Companion

The companion object SubspaceModifier is the empty, default, or starter SubspaceModifier that contains no SubspaceModifierNodeElements.

SubspaceModifierNodeElement

Modifier elements manage an instance of a particular SubspaceModifier.Node implementation.


An ordered, immutable collection of subspace modifier elements that decorate or add behavior to Subspace Compose elements.

Based on androidx.compose.ui.Modifier

Summary

Nested types

The companion object SubspaceModifier is the empty, default, or starter SubspaceModifier that contains no SubspaceModifierNodeElements.

abstract class SubspaceModifier.Node

The longer-lived object that is created for each SubspaceModifierNodeElement applied to a SubspaceLayout

Public companion functions

infix SubspaceModifier
open String

Public functions

open Boolean

Returns true if predicate returns true for all SubspaceModifierNodeElements in this SubspaceModifier or if this SubspaceModifier contains no Elements.

open Boolean

Returns true if predicate returns true for any SubspaceModifierNodeElement in this SubspaceModifier.

open R
<R : Any?> foldIn(
    initial: R,
    operation: (SubspaceModifierNodeElement<SubspaceModifier.Node>, R) -> R
)

Accumulates a value starting with initial and applying operation to the current value and each SubspaceModifierNodeElement from outside in.

open R
<R : Any?> foldOut(
    initial: R,
    operation: (SubspaceModifierNodeElement<SubspaceModifier.Node>, R) -> R
)

Accumulates a value starting with initial and applying operation to the current value and each SubspaceModifierNodeElement from inside out.

open infix SubspaceModifier

Concatenates this modifier with another.

Extension functions

SubspaceModifier
SubspaceModifier.alpha(alpha: @FloatRange(from = 0.0, to = 1.0) Float)

Sets the opacity of this element (and its children) to a value between 0..1.

SubspaceModifier
SubspaceModifier.movable(
    enabled: Boolean,
    stickyPose: Boolean,
    scaleWithDistance: Boolean,
    onMoveStart: ((MoveStartEvent) -> Unit)?,
    onMoveEnd: ((MoveEndEvent) -> Unit)?,
    onMove: ((MoveEvent) -> Boolean)?
)

When the movable modifier is present and enabled, draggable UI controls will be shown that allow the user to move the element in 3D space.

SubspaceModifier
SubspaceModifier.offset(x: Dp, y: Dp, z: Dp)

Offset the content by (x dp, y dp, z dp).

SubspaceModifier

Invoke onGloballyPositioned with the SubspaceLayoutCoordinates of the element when the global position of the content may have changed.

SubspaceModifier
SubspaceModifier.onPointSourceParams(
    onPointSourceParams: (PointSourceParams) -> Unit
)

Used to provide a PointSourceParams to allow specifying the modified Composable as an audio source.

SubspaceModifier

Apply all dp of additional space along each edge of the content, left, top, right, bottom, front, and back.

SubspaceModifier
SubspaceModifier.padding(horizontal: Dp, vertical: Dp, depth: Dp)

Apply horizontal dp space along the left and right edges of the content, vertical dp space along the top and bottom edges, and depth dp space along front and back edged.

SubspaceModifier
SubspaceModifier.padding(
    left: Dp,
    top: Dp,
    right: Dp,
    bottom: Dp,
    front: Dp,
    back: Dp
)

Apply additional space along each edge of the content in Dp: left, top, right, bottom, front and back.

SubspaceModifier
SubspaceModifier
SubspaceModifier.resizable(
    enabled: Boolean,
    minimumSize: DpVolumeSize,
    maximumSize: DpVolumeSize,
    maintainAspectRatio: Boolean,
    onSizeChange: ((IntVolumeSize) -> Boolean)?
)

When the resizable modifier is present and enabled, draggable UI controls will be shown that allow the user to resize the element in 3D space.

SubspaceModifier

Rotate a subspace element (i.e. Panel) in space.

SubspaceModifier
SubspaceModifier.rotate(axisAngle: Vector3, rotation: Float)

Rotate a subspace element (i.e. Panel) in space.

SubspaceModifier
SubspaceModifier.rotate(pitch: Float, yaw: Float, roll: Float)

Rotate a subspace element (i.e. Panel) in space.

SubspaceModifier

Scale the contents of the composable by the scale factor along horizontal, vertical, and depth axes.

SubspaceModifier

Add semantics key/value pairs to the layout node, for use in testing, accessibility, etc.

SubspaceModifier

Declare the preferred size of the content to be exactly depth dp along the z dimension.

SubspaceModifier
SubspaceModifier.fillMaxDepth(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float
)

Have the content fill (possibly only partially) the VolumeConstraints.maxDepth of the incoming measurement constraints, by setting the minimum depth and the maximum depth to be equal to the maximum depth multiplied by fraction.

SubspaceModifier
SubspaceModifier.fillMaxHeight(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float
)

Have the content fill (possibly only partially) the VolumeConstraints.maxHeight of the incoming measurement constraints, by setting the minimum height and the maximum height to be equal to the maximum height multiplied by fraction.

SubspaceModifier
SubspaceModifier.fillMaxSize(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float
)

Have the content fill (possibly only partially) the VolumeConstraints.maxWidth, VolumeConstraints.maxHeight, and VolumeConstraints.maxDepth of the incoming measurement constraints.

SubspaceModifier
SubspaceModifier.fillMaxWidth(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float
)

Have the content fill (possibly only partially) the VolumeConstraints.maxWidth of the incoming measurement constraints, by setting the minimum width and the maximum width to be equal to the maximum width multiplied by fraction.

SubspaceModifier

Declare the preferred size of the content to be exactly height dp along the y dimension.

SubspaceModifier

Declare the size of the content to be exactly depth dp along the z dimension.

SubspaceModifier

Declare the size of the content to be exactly height dp along the y dimension.

SubspaceModifier

Declare the size of the content to be exactly a size dp cube.

SubspaceModifier

Declare the size of the content to be exactly size in each of the three dimensions.

SubspaceModifier

Declare the size of the content to be exactly width dp along the x dimension.

SubspaceModifier

Declare the preferred size of the content to be exactly a size dp cube.

SubspaceModifier

Declare the preferred size of the content to be exactly size in each of the three dimensions.

SubspaceModifier

Declare the preferred size of the content to be exactly width dp along the x dimension.

SubspaceModifier

Applies a tag to allow modified element to be found in tests.

Public companion functions

toString

open fun toString(): String

Public functions

all

Added in 1.0.0-alpha04
open fun all(
    predicate: (SubspaceModifierNodeElement<SubspaceModifier.Node>) -> Boolean
): Boolean

Returns true if predicate returns true for all SubspaceModifierNodeElements in this SubspaceModifier or if this SubspaceModifier contains no Elements.

any

Added in 1.0.0-alpha04
open fun any(
    predicate: (SubspaceModifierNodeElement<SubspaceModifier.Node>) -> Boolean
): Boolean

Returns true if predicate returns true for any SubspaceModifierNodeElement in this SubspaceModifier.

foldIn

Added in 1.0.0-alpha04
open fun <R : Any?> foldIn(
    initial: R,
    operation: (SubspaceModifierNodeElement<SubspaceModifier.Node>, R) -> R
): R

Accumulates a value starting with initial and applying operation to the current value and each SubspaceModifierNodeElement from outside in.

foldOut

Added in 1.0.0-alpha04
open fun <R : Any?> foldOut(
    initial: R,
    operation: (SubspaceModifierNodeElement<SubspaceModifier.Node>, R) -> R
): R

Accumulates a value starting with initial and applying operation to the current value and each SubspaceModifierNodeElement from inside out.

then

Added in 1.0.0-alpha04
open infix fun then(other: SubspaceModifier): SubspaceModifier

Concatenates this modifier with another.

Returns a SubspaceModifier representing this modifier followed by other in sequence.

Extension functions

fun SubspaceModifier.alpha(alpha: @FloatRange(from = 0.0, to = 1.0) Float): SubspaceModifier

Sets the opacity of this element (and its children) to a value between 0..1. An alpha value of 0.0f means fully transparent while a value of 1.0f is completely opaque. Elements with semi-transparent alpha values (> 0.0 but < 1.0f) will be rendered using alpha-blending.

Parameters
alpha: @FloatRange(from = 0.0, to = 1.0) Float
  • Opacity of this element (and its children). Must be between 0 and 1, inclusive. Values <0 or 1 will be clamped.

fun SubspaceModifier.movable(
    enabled: Boolean = true,
    stickyPose: Boolean = false,
    scaleWithDistance: Boolean = true,
    onMoveStart: ((MoveStartEvent) -> Unit)? = null,
    onMoveEnd: ((MoveEndEvent) -> Unit)? = null,
    onMove: ((MoveEvent) -> Boolean)? = null
): SubspaceModifier

When the movable modifier is present and enabled, draggable UI controls will be shown that allow the user to move the element in 3D space. This feature is only available for SpatialPanels at the moment.

The order of the SubspaceModifiers is important. Please take note of this when using movable. If you have the following modifier chain: SubspaceModifier.offset().size().movable(), the modifiers will work as expected. If instead you have this modifier chain: SubspaceModifier.size().offset().movable(), you will experience unexpected placement behavior when using the movable modifier. In general, the offset modifier should be specified before the size modifier, and the movable modifier should be specified last.

Parameters
enabled: Boolean = true

true if this composable should be movable.

stickyPose: Boolean = false

if enabled, the user specified position will be retained when the modifier is disabled or removed.

scaleWithDistance: Boolean = true

true if this composable should scale in size when moved in depth. When this scaleWithDistance is enabled, the subspace element moved will grow or shrink. It will also maintain any explicit scale that it had before movement.

onMoveStart: ((MoveStartEvent) -> Unit)? = null

a callback to process the start of a move event. This will only be called if enabled is true. The callback will be called with the MoveStartEvent type

onMoveEnd: ((MoveEndEvent) -> Unit)? = null

a callback to process the end of a move event. This will only be called if enabled is true. The callback will be called with the MoveEndEvent type

onMove: ((MoveEvent) -> Boolean)? = null

a callback to process the pose change during movement, with translation in pixels. This will only be called if enabled is true. If the callback returns false the default behavior of moving this composable's subspace hierarchy will be executed. If it returns true, it is the responsibility of the callback to process the event. The callback will be called with the MoveEvent type @see MoveEvent. @see MoveEvent.

fun SubspaceModifier.offset(x: Dp = 0.dp, y: Dp = 0.dp, z: Dp = 0.dp): SubspaceModifier

Offset the content by (x dp, y dp, z dp). The offsets can be positive as well as non-positive.

onGloballyPositioned

fun SubspaceModifier.onGloballyPositioned(
    onGloballyPositioned: (SubspaceLayoutCoordinates) -> Unit
): SubspaceModifier

Invoke onGloballyPositioned with the SubspaceLayoutCoordinates of the element when the global position of the content may have changed. Note that it will be called after a composition when the coordinates are finalized.

This callback will be invoked at least once when the SubspaceLayoutCoordinates are available, and every time the element's position changes within the window. However, it is not guaranteed to be invoked every time the position relative to the screen of the modified element changes. For example, the system may move the contents inside a window around without firing a callback. If you are using the SubspaceLayoutCoordinates to calculate position on the screen, and not just inside the window, you may not receive a callback.

onPointSourceParams

fun SubspaceModifier.onPointSourceParams(
    onPointSourceParams: (PointSourceParams) -> Unit
): SubspaceModifier

Used to provide a PointSourceParams to allow specifying the modified Composable as an audio source.

PointSourceParams are used to configure a sound to be spatialized as a point in 3D space.

Parameters
onPointSourceParams: (PointSourceParams) -> Unit
  • Will be called with a PointSourceParams once it is generated. This will generally only execute one time, but may be executed again if the modifier chain is updated with significant insertions and/or deletions, causing this modifier to be recreated. It is recommended to order this modifier before conditional modifiers in a chain to maintain one time execution, or to handle re-execution appropriately.

fun SubspaceModifier.padding(all: Dp): SubspaceModifier

Apply all dp of additional space along each edge of the content, left, top, right, bottom, front, and back. Padding is applied before content measurement and takes precedence; content may only be as large as the remaining space.

Negative padding is not permitted — it will cause IllegalArgumentException. See padding

fun SubspaceModifier.padding(
    horizontal: Dp = 0.dp,
    vertical: Dp = 0.dp,
    depth: Dp = 0.dp
): SubspaceModifier

Apply horizontal dp space along the left and right edges of the content, vertical dp space along the top and bottom edges, and depth dp space along front and back edged. Padding is applied before content measurement and takes precedence; content may only be as large as the remaining space.

Negative padding is not permitted — it will cause IllegalArgumentException. See padding

fun SubspaceModifier.padding(
    left: Dp = 0.dp,
    top: Dp = 0.dp,
    right: Dp = 0.dp,
    bottom: Dp = 0.dp,
    front: Dp = 0.dp,
    back: Dp = 0.dp
): SubspaceModifier

Apply additional space along each edge of the content in Dp: left, top, right, bottom, front and back. Padding is applied before content measurement and takes precedence; content may only be as large as the remaining space.

Negative padding is not permitted — it will cause IllegalArgumentException.

fun SubspaceModifier.resizable(
    enabled: Boolean = true,
    minimumSize: DpVolumeSize = DpVolumeSize.Zero,
    maximumSize: DpVolumeSize = DpVolumeSize(Dp.Infinity, Dp.Infinity, Dp.Infinity),
    maintainAspectRatio: Boolean = false,
    onSizeChange: ((IntVolumeSize) -> Boolean)? = null
): SubspaceModifier

When the resizable modifier is present and enabled, draggable UI controls will be shown that allow the user to resize the element in 3D space. This feature is only available for SpatialPanels at the moment.

Parameters
enabled: Boolean = true

true if this composable should be resizable.

minimumSize: DpVolumeSize = DpVolumeSize.Zero

the smallest allowed dimensions for this composable.

maximumSize: DpVolumeSize = DpVolumeSize(Dp.Infinity, Dp.Infinity, Dp.Infinity)

the largest allowed dimensions for this composable.

maintainAspectRatio: Boolean = false

true if the new size should maintain the same aspect ratio as the existing size.

onSizeChange: ((IntVolumeSize) -> Boolean)? = null

a callback to process the size change in pixels during resizing. This will only be called if enabled is true. If the callback returns false or isn't specified, the default behavior of resizing this composable will be executed. If it returns true, it is the responsibility of the callback to process the event.

fun SubspaceModifier.rotate(quaternion: Quaternion): SubspaceModifier

Rotate a subspace element (i.e. Panel) in space.

Parameters
quaternion: Quaternion

Quaternion describing the rotation.

fun SubspaceModifier.rotate(axisAngle: Vector3, rotation: Float): SubspaceModifier

Rotate a subspace element (i.e. Panel) in space.

Parameters
axisAngle: Vector3

Vector representing the axis of rotation.

rotation: Float

Degrees of rotation.

fun SubspaceModifier.rotate(pitch: Float, yaw: Float, roll: Float): SubspaceModifier

Rotate a subspace element (i.e. Panel) in space. Parameter rotation angles are specified in degrees. The rotations are applied with the order pitch, then yaw, then roll.

Parameters
pitch: Float

Rotation around the x-axis. The x-axis is the axis width is measured on.

yaw: Float

Rotation around the y-axis. The y-axis is the axis height is measured on.

roll: Float

Rotation around the z-axis. The z-axis is the axis depth is measured on.

fun SubspaceModifier.scale(scale: Float): SubspaceModifier

Scale the contents of the composable by the scale factor along horizontal, vertical, and depth axes. Scaling does not change the measured size of the composable content during layout. Measured size of @SubspaceComposable elements can be controlled using Size Modifiers. Scale factor should be a positive number.

Parameters
scale: Float
  • Multiplier to scale content along vertical, horizontal, depth axes.

fun SubspaceModifier.semantics(properties: SemanticsPropertyReceiver.() -> Unit): SubspaceModifier

Add semantics key/value pairs to the layout node, for use in testing, accessibility, etc.

Based on androidx.compose.ui.semantics.SemanticsModifier.

fun SubspaceModifier.depth(depth: Dp): SubspaceModifier

Declare the preferred size of the content to be exactly depth dp along the z dimension. Panels have 0 depth and ignore this modifier.

fillMaxDepth

fun SubspaceModifier.fillMaxDepth(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f
): SubspaceModifier

Have the content fill (possibly only partially) the VolumeConstraints.maxDepth of the incoming measurement constraints, by setting the minimum depth and the maximum depth to be equal to the maximum depth multiplied by fraction. Note that, by default, the fraction is 1, so the modifier will make the content fill the whole available depth. If the incoming maximum depth is VolumeConstraints.Infinity this modifier will have no effect.

Parameters
fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f

The fraction of the maximum height to use, between 0 and 1, inclusive.

fillMaxHeight

fun SubspaceModifier.fillMaxHeight(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f
): SubspaceModifier

Have the content fill (possibly only partially) the VolumeConstraints.maxHeight of the incoming measurement constraints, by setting the minimum height and the maximum height to be equal to the maximum height multiplied by fraction. Note that, by default, the fraction is 1, so the modifier will make the content fill the whole available height. If the incoming maximum height is VolumeConstraints.Infinity this modifier will have no effect.

Parameters
fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f

The fraction of the maximum height to use, between 0 and 1, inclusive.

fun SubspaceModifier.fillMaxSize(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f
): SubspaceModifier

Have the content fill (possibly only partially) the VolumeConstraints.maxWidth, VolumeConstraints.maxHeight, and VolumeConstraints.maxDepth of the incoming measurement constraints. See SubspaceModifier.fillMaxWidth, SubspaceModifier.fillMaxHeight, and SubspaceModifier.fillMaxDepth for details. Note that, by default, the fraction is 1, so the modifier will make the content fill the whole available space. If the incoming maximum width or height or depth is VolumeConstraints.Infinity this modifier will have no effect in that dimension.

Parameters
fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f

The fraction of the maximum size to use, between 0 and 1, inclusive.

fillMaxWidth

fun SubspaceModifier.fillMaxWidth(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f
): SubspaceModifier

Have the content fill (possibly only partially) the VolumeConstraints.maxWidth of the incoming measurement constraints, by setting the minimum width and the maximum width to be equal to the maximum width multiplied by fraction. Note that, by default, the fraction is 1, so the modifier will make the content fill the whole available width. If the incoming maximum width is VolumeConstraints.Infinity this modifier will have no effect.

Parameters
fraction: @FloatRange(from = 0.0, to = 1.0) Float = 1.0f

The fraction of the maximum width to use, between 0 and 1, inclusive.

fun SubspaceModifier.height(height: Dp): SubspaceModifier

Declare the preferred size of the content to be exactly height dp along the y dimension.

requiredDepth

fun SubspaceModifier.requiredDepth(depth: Dp): SubspaceModifier

Declare the size of the content to be exactly depth dp along the z dimension. Panels have 0 depth and ignore this modifier.

requiredHeight

fun SubspaceModifier.requiredHeight(height: Dp): SubspaceModifier

Declare the size of the content to be exactly height dp along the y dimension.

requiredSize

fun SubspaceModifier.requiredSize(size: Dp): SubspaceModifier

Declare the size of the content to be exactly a size dp cube. When applied to a Panel, the size will be a size dp square instead.

requiredSize

fun SubspaceModifier.requiredSize(size: DpVolumeSize): SubspaceModifier

Declare the size of the content to be exactly size in each of the three dimensions. Panels have 0 depth and ignore the z-component of this modifier.

requiredWidth

fun SubspaceModifier.requiredWidth(width: Dp): SubspaceModifier

Declare the size of the content to be exactly width dp along the x dimension.

fun SubspaceModifier.size(size: Dp): SubspaceModifier

Declare the preferred size of the content to be exactly a size dp cube. When applied to a Panel, the preferred size will be a size dp square instead.

fun SubspaceModifier.size(size: DpVolumeSize): SubspaceModifier

Declare the preferred size of the content to be exactly size in each of the three dimensions. Panels have 0 depth and ignore the z-component of this modifier.

fun SubspaceModifier.width(width: Dp): SubspaceModifier

Declare the preferred size of the content to be exactly width dp along the x dimension.

fun SubspaceModifier.testTag(tag: String): SubspaceModifier

Applies a tag to allow modified element to be found in tests.

This is a convenience method for a semantics that sets SemanticsPropertyReceiver.testTag.