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 SubspaceModifierElements.

SubspaceModifierElement

An abstract class for SubspaceModifier that creates and updates SubspaceModifier.Node instances.


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 SubspaceModifierElements.

abstract class SubspaceModifier.Node

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

Public companion functions

infix SubspaceModifier
open String

Public functions

open Boolean

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

open Boolean

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

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

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

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

Accumulates a value starting with initial and applying operation to the current value and each SubspaceModifierElement 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,
    onPoseChange: (Pose) -> Boolean
)

Moves a subspace element (i.e. currently only affects Jetpack XR Entity Panels/Volumes) in 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 LayoutVolumeCoordinates of the element when the global position of the content may have changed.

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.resizable(
    enabled: Boolean,
    minimumSize: DpVolumeSize,
    maximumSize: DpVolumeSize,
    maintainAspectRatio: Boolean,
    onSizeChange: (IntVolumeSize) -> Boolean
)

Resize a subspace element (i.e. currently only affects Jetpack XR Entity Panels/Volumes) in 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-alpha01
open fun all(
    predicate: (SubspaceModifierElement<SubspaceModifier.Node>) -> Boolean
): Boolean

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

any

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

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

foldIn

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

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

foldOut

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

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

then

Added in 1.0.0-alpha01
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,
    onPoseChange: (Pose) -> Boolean = { false }
): SubspaceModifier

Moves a subspace element (i.e. currently only affects Jetpack XR Entity Panels/Volumes) in space. 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.

onPoseChange: (Pose) -> Boolean = { false }
  • 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.

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 LayoutVolumeCoordinates 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 LayoutVolumeCoordinates 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 LayoutVolumeCoordinates to calculate position on the screen, and not just inside the window, you may not receive a callback.

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 = { false }
): SubspaceModifier

Resize a subspace element (i.e. currently only affects Jetpack XR Entity Panels/Volumes) in space.

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 = { false }
  • a callback to process the size change during resizing. This will only be called if enabled is true. If the callback returns false 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.