androidx.xr.compose.subspace.layout

Interfaces

Measurable

A part of the composition layout that can be measured.

MeasurePolicy

Defines the measure and layout behavior of a layout.

MeasureResult

Interface holding the size and alignment lines of the measured layout, as well as the children positioning logic.

MeasureScope

The receiver scope of a layout's measure lambda.

ParentLayoutParamsAdjustable

Marker interface for types allowed to be adjusted by a ParentLayoutParamsModifier.

ParentLayoutParamsModifier

Interface for classes involved in setting layout params.

SpatialAlignment

An interface to calculate the position of a sized box inside of an available 3D space.

SpatialAlignment.Depth

An interface to calculate the position of a box of a certain depth inside an available depth.

SpatialAlignment.Horizontal

An interface to calculate the position of a box of a certain width inside an available width.

SpatialAlignment.Vertical

An interface to calculate the position of a box of a certain height inside an available height.

SubspaceLayoutCoordinates

A holder of the measured bounds.

SubspaceModifier

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

Classes

CombinedSubspaceModifier

A node in a SubspaceModifier chain.

OnGloballyPositionedNode

Node associated with onGloballyPositioned.

Placeable

A Placeable corresponds to a child layout that can be positioned by its parent layout.

Placeable.PlacementScope

Receiver scope that permits explicit placement of a Placeable.

RotationNode
SpatialBiasAlignment

Creates a weighted alignment that specifies a horizontal, vertical, and depth bias.

SpatialBiasAlignment.Depth

Creates a weighted alignment that specifies a depth bias.

SpatialBiasAlignment.Horizontal

Creates a weighted alignment that specifies a horizontal bias.

SpatialBiasAlignment.Vertical

Creates a weighted alignment that specifies a vertical bias.

SpatialRoundedCornerShape

A shape describing a rectangle with rounded corners in 3D space.

SpatialShape

Base Spatial shape.

SubspaceModifier.Node

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

TestTagNode

Objects

SubspaceModifier.Companion

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

Top-level functions summary

Unit
@SubspaceComposable
@Composable
SubspaceLayout(
    modifier: SubspaceModifier,
    name: String,
    measurePolicy: MeasurePolicy
)

SubspaceLayout is the main core component for layout for "leaf" nodes.

Unit
@SubspaceComposable
@Composable
SubspaceLayout(
    content: @Composable @SubspaceComposable () -> Unit,
    modifier: SubspaceModifier,
    name: String,
    measurePolicy: MeasurePolicy
)

SubspaceLayout is the main core component for layout.

String

Extension functions summary

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

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

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
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 a size dp cube.

SubspaceModifier

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

SubspaceModifier

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

String

Returns information on pose, position and size.

Sequence<SubspaceModifier.Node>

Generates a lazy sequence that walks up the node tree to the root.

Sequence<SubspaceModifier.Node>

Generates a lazy sequence that walks down the node tree.

Sequence<SubspaceModifier.Node>

Generates a sequence with self and elements up the node tree to the root.

Sequence<SubspaceModifier.Node>

Generates a sequence with self and elements down the node tree.

SubspaceModifier

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

Top-level functions

SubspaceLayout

@SubspaceComposable
@Composable
fun SubspaceLayout(
    modifier: SubspaceModifier = SubspaceModifier,
    name: String = defaultSubspaceLayoutName(),
    measurePolicy: MeasurePolicy
): Unit

SubspaceLayout is the main core component for layout for "leaf" nodes. It can be used to measure and position zero children.

The measurement, layout and intrinsic measurement behaviours of this layout will be defined by the measurePolicy instance. See MeasurePolicy for more details.

Parameters
modifier: SubspaceModifier = SubspaceModifier

SubspaceModifier to apply during layout.

name: String = defaultSubspaceLayoutName()

a name for the ComposeSubspaceNode. This can be useful for debugging.

measurePolicy: MeasurePolicy

a policy defining the measurement and positioning of the layout.

SubspaceLayout

@SubspaceComposable
@Composable
fun SubspaceLayout(
    content: @Composable @SubspaceComposable () -> Unit,
    modifier: SubspaceModifier = SubspaceModifier,
    name: String = defaultSubspaceLayoutName(),
    measurePolicy: MeasurePolicy
): Unit

SubspaceLayout is the main core component for layout. It can be used to measure and position zero or more layout children.

The measurement, layout and intrinsic measurement behaviours of this layout will be defined by the measurePolicy instance. See MeasurePolicy for more details.

Parameters
content: @Composable @SubspaceComposable () -> Unit

the children composable to be laid out.

modifier: SubspaceModifier = SubspaceModifier

SubspaceModifier to apply during layout

name: String = defaultSubspaceLayoutName()

a name for the ComposeSubspaceNode. This can be useful for debugging.

measurePolicy: MeasurePolicy

a policy defining the measurement and positioning of the layout.

defaultSubspaceLayoutName

fun defaultSubspaceLayoutName(): String

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

fillMaxSize

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.

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.

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

toDebugString

fun SubspaceLayoutCoordinates.toDebugString(): String

Returns information on pose, position and size.

traverseAncestors

fun SubspaceModifier.Node.traverseAncestors(): Sequence<SubspaceModifier.Node>

Generates a lazy sequence that walks up the node tree to the root.

If this node is the root, an empty sequence is returned.

traverseDescendants

fun SubspaceModifier.Node.traverseDescendants(): Sequence<SubspaceModifier.Node>

Generates a lazy sequence that walks down the node tree.

If this node is a leaf node, an empty sequence is returned.

traverseSelfThenAncestors

fun SubspaceModifier.Node.traverseSelfThenAncestors(): Sequence<SubspaceModifier.Node>

Generates a sequence with self and elements up the node tree to the root.

traverseSelfThenDescendants

fun SubspaceModifier.Node.traverseSelfThenDescendants(): Sequence<SubspaceModifier.Node>

Generates a sequence with self and elements down the node tree.

fun SubspaceModifier.width(width: Dp): SubspaceModifier

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