androidx.xr.compose.subspace.layout
Interfaces
DelegatableSubspaceNode |
Represents a |
ParentLayoutParamsAdjustable |
Marker interface for types allowed to be adjusted by a |
ParentLayoutParamsModifier |
Interface for modifiers that can adjust the layout parameters of a composable that implements |
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. |
SpatialArrangement.AxisIndependent |
Used to specify the horizontal arrangement of the layout's children in horizontal layouts like SpatialRow, or the vertical arrangement of the layout's children in vertical layouts like SpatialColumn. |
SpatialArrangement.Horizontal |
Used to specify the horizontal arrangement of the layout's children in layouts like SpatialRow. |
SpatialArrangement.Vertical |
Used to specify the vertical arrangement of the layout's children in layouts like SpatialColumn. |
SubspaceLayoutCoordinates |
A holder of the measured bounds. |
SubspaceMeasurable |
A part of the composition layout that can be measured. |
SubspaceMeasurePolicy |
Defines the measure and layout behavior of a |
SubspaceMeasureResult |
Interface holding the size and alignment lines of the measured layout, as well as the children positioning logic. |
SubspaceMeasureScope |
The receiver scope of a layout's measure lambda. |
SubspaceModifier |
An ordered, immutable collection of |
Classes
InteractionPolicy |
Defines the interaction policy for a spatial object. |
PlaneOrientation |
Type of plane based on orientation i.e. Horizontal or Vertical. |
PlaneSemantic |
Semantic plane types. |
SpatialBiasAbsoluteAlignment |
An |
SpatialBiasAbsoluteAlignment.Horizontal |
Creates a weighted alignment that specifies a horizontal bias and independent of layout direction |
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. |
SpatialFeatheringEffect |
Base class for feathering effects. |
SpatialInputEvent |
Defines Spatial input events for Compose, representing a user's input in 3D space. |
SpatialMoveEndEvent |
An event representing the end of a move event. |
SpatialMoveEvent |
An event representing a change in pose, scale, and size. |
SpatialMoveStartEvent |
An event representing the start of a move event. |
SpatialRoundedCornerShape |
A shape describing a rectangle with rounded corners in 3D space. |
SpatialShape |
Base type for shapes that could be applied to spatial elements. |
SubspaceModifier.Node |
The longer-lived object that is created for each |
SubspacePlaceable |
A |
SubspacePlaceable.SubspacePlacementScope |
Receiver scope that permits explicit placement of a |
Objects
SpatialAbsoluteAlignment |
A collection of common |
SpatialArrangement |
Used to specify the arrangement of the layout's children in layouts like SpatialRow or SpatialColumn in the main axis direction (horizontal and vertical, respectively). |
SpatialArrangement.Absolute |
Used to specify arrangement which doesn't change with layout direction. |
SubspaceModifier.Companion |
The companion object |
Top-level functions summary
SpatialFeatheringEffect |
SpatialSmoothFeatheringEffect(horizontal: Dp, vertical: Dp)Defines a |
SpatialFeatheringEffect |
SpatialSmoothFeatheringEffect(horizontal: Float, vertical: Float)Defines a |
SpatialFeatheringEffect |
SpatialSmoothFeatheringEffect(Defines |
inline Unit |
@SubspaceComposable
|
inline Unit |
@SubspaceComposable
|
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 |
SubspaceModifier.aspectRatio(Attempts to size the content to match a specified aspect ratio by trying to match one of the incoming constraints in the following order: |
SubspaceModifier |
SubspaceModifier.billboard(enabled: Boolean)A |
SubspaceModifier |
SubspaceModifier.depth(depth: Dp)Declare the preferred size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.depthIn(min: Dp, max: Dp)Constrain the depth of the content to be between |
SubspaceModifier |
SubspaceModifier.fillMaxDepth(Have the content fill (possibly only partially) the |
SubspaceModifier |
SubspaceModifier.fillMaxHeight(Have the content fill (possibly only partially) the |
SubspaceModifier |
SubspaceModifier.fillMaxSize(Have the content fill (possibly only partially) the |
SubspaceModifier |
SubspaceModifier.fillMaxWidth(Have the content fill (possibly only partially) the |
SubspaceModifier |
A |
SubspaceModifier |
SubspaceModifier.height(height: Dp)Declare the preferred size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.heightIn(min: Dp, max: Dp)Constrain the height of the content to be between |
SubspaceModifier |
SubspaceModifier.layout(Creates a node that allows changing how the wrapped element is measured and laid out. |
SubspaceModifier |
SubspaceModifier.lookAtUser(enabled: Boolean, up: Vector3)A |
SubspaceModifier |
SubspaceModifier.offset(x: Dp, y: Dp, z: Dp) |
SubspaceModifier |
SubspaceModifier.onGloballyPositioned(Invoke |
SubspaceModifier |
SubspaceModifier.onPointSourceParamsAvailable(Used to provide a |
SubspaceModifier |
SubspaceModifier.onSizeChanged(Invokes |
SubspaceModifier |
SubspaceModifier.padding(all: Dp)Apply |
SubspaceModifier |
SubspaceModifier.padding(horizontal: Dp, vertical: Dp, depth: Dp)Apply |
SubspaceModifier |
Apply additional space along each edge of the content in |
SubspaceModifier |
When present, this modifier defines how the pointer icon will be displayed when the spatial pointer hovers over an element. |
SubspaceModifier |
SubspaceModifier.requiredDepth(depth: Dp)Declare the size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.requiredDepthIn(min: Dp, max: Dp)Constrain the depth of the content to be between |
SubspaceModifier |
SubspaceModifier.requiredHeight(height: Dp)Declare the size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.requiredHeightIn(min: Dp, max: Dp)Constrain the height of the content to be between |
SubspaceModifier |
SubspaceModifier.requiredSize(size: Dp)Declare the size of the content to be exactly a |
SubspaceModifier |
Declare the size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.requiredSize(width: Dp, height: Dp, depth: Dp)Declare the size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.requiredSizeIn(Constrain the size of the content to be between min and max dp, disregarding the incoming measurement |
SubspaceModifier |
SubspaceModifier.requiredWidth(width: Dp)Declare the size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.requiredWidthIn(min: Dp, max: Dp)Constrain the width of the content to be between |
SubspaceModifier |
SubspaceModifier.rotate(quaternion: Quaternion)Rotate a subspace element (i.e. Panel) in space with regards to the center of the element. |
SubspaceModifier |
SubspaceModifier.rotate(axisAngle: Vector3, rotation: Float)Rotate a subspace element (i.e. Panel) in space with regards to the center of the element. |
SubspaceModifier |
SubspaceModifier.rotate(pitch: Float, yaw: Float, roll: Float)Rotate a subspace element (i.e. Panel) in space with regards to the center of the element. |
SubspaceModifier |
SubspaceModifier.scale(scale: Float)Scale the contents of the composable by the scale factor along horizontal, vertical, and depth axes. |
SubspaceModifier |
SubspaceModifier.semantics(properties: SemanticsPropertyReceiver.() -> Unit)Add semantics key/value pairs to the layout node, for use in testing, accessibility, etc. |
SubspaceModifier |
SubspaceModifier.size(size: Dp)Declare the preferred size of the content to be exactly a |
SubspaceModifier |
SubspaceModifier.size(size: DpVolumeSize)Declare the preferred size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.size(width: Dp, height: Dp, depth: Dp)Declare the preferred size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.sizeIn(Constrain the size of the content to be between min and max dp as permitted by the incoming measurement constraints. |
SubspaceModifier |
SubspaceModifier.testTag(tag: String)Applies a tag to allow modified element to be found in tests. |
SubspaceModifier |
SubspaceModifier.width(width: Dp)Declare the preferred size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.widthIn(min: Dp, max: Dp)Constrain the width of the content to be between |
Top-level properties summary
SpatialFeatheringEffect |
An effect representing no feathering. |
Top-level functions
SpatialSmoothFeatheringEffect
fun SpatialSmoothFeatheringEffect(horizontal: Dp, vertical: Dp): SpatialFeatheringEffect
Defines a SpatialSmoothFeatheringEffect using Dp.
SpatialSmoothFeatheringEffect
fun SpatialSmoothFeatheringEffect(horizontal: Float, vertical: Float): SpatialFeatheringEffect
Defines a SpatialSmoothFeatheringEffect using pixels.
SpatialSmoothFeatheringEffect
fun SpatialSmoothFeatheringEffect(
percentHorizontal: @IntRange(from = 0, to = 50) Int,
percentVertical: @IntRange(from = 0, to = 50) Int
): SpatialFeatheringEffect
Defines SpatialSmoothFeatheringEffect based on the percent width and height of the layout.
| Parameters | |
|---|---|
percentHorizontal: @IntRange(from = 0, to = 50) Int |
Value to feather horizontal edges. A value of 5 represents 5% of the width of the visible canvas. Accepted value range is 0 - 50 percent. |
percentVertical: @IntRange(from = 0, to = 50) Int |
Value to feather vertical edges. A value of 5 represents 5% of the height the visible canvas. Accepted value range is 0 - 50 percent. |
SubspaceLayout
@SubspaceComposable
@Composable
inline fun SubspaceLayout(
modifier: SubspaceModifier = SubspaceModifier,
measurePolicy: SubspaceMeasurePolicy
): Unit
SubspaceLayout is the main component for laying out leaf nodes with zero children.
The measurement, layout and intrinsic measurement behaviours of this layout will be defined by the SubspaceMeasurePolicy instance. See SubspaceMeasurePolicy for more details.
Example:
fun ExactSizeSpacer(size: IntVolumeSize) {
SubspaceLayout(SubspaceModifier.testTag("exactSizeSpacer")) {
_, _ -> layout(size.width, size.height, size.depth) {}
}
}
| Parameters | |
|---|---|
modifier: SubspaceModifier = SubspaceModifier |
SubspaceModifier to apply during layout. |
measurePolicy: SubspaceMeasurePolicy |
a policy defining the measurement and positioning of the layout. |
SubspaceLayout
@SubspaceComposable
@Composable
inline fun SubspaceLayout(
crossinline content: @Composable @SubspaceComposable () -> Unit,
modifier: SubspaceModifier = SubspaceModifier,
measurePolicy: SubspaceMeasurePolicy
): 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 SubspaceMeasurePolicy instance. See SubspaceMeasurePolicy for more details.
Example:
fun MyLayout(
modifier: SubspaceModifier = SubspaceModifier,
content: @SubspaceComposable @Composable () -> Unit) {
SubspaceLayout(content = content, modifier = modifier) {
measurables, constraints ->
val placeables = measurables.map { it.measure(constraints) }
layout(constraints.maxWidth, constraints.maxHeight, constraints.maxDepth) {
placeables.forEach { it.place(Pose.Identity) }
}
}
}
| Parameters | |
|---|---|
crossinline content: @Composable @SubspaceComposable () -> Unit |
the child composables to be laid out. |
modifier: SubspaceModifier = SubspaceModifier |
SubspaceModifier to apply during layout |
measurePolicy: SubspaceMeasurePolicy |
a policy defining the measurement and positioning of the layout. |
Extension functions
alpha
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 |
the opacity of this element (and its children). Must be a value between 0 and 1, inclusive. Values < 0 or 1 will be clamped. |
aspectRatio
fun SubspaceModifier.aspectRatio(
ratio: @FloatRange(from = 0.0, fromInclusive = false) Float,
matchHeightConstraintsFirst: Boolean = false
): SubspaceModifier
Attempts to size the content to match a specified aspect ratio by trying to match one of the incoming constraints in the following order: VolumeConstraints.maxWidth, VolumeConstraints.maxHeight, VolumeConstraints.minWidth, VolumeConstraints.minHeight if matchHeightConstraintsFirst is false (which is the default), or VolumeConstraints.maxHeight, VolumeConstraints.maxWidth, VolumeConstraints.minHeight, VolumeConstraints.minWidth if matchHeightConstraintsFirst is true. The size in the other dimension is determined by the aspect ratio. The combinations will be tried in this order until one non-empty is found to satisfy the constraints. If no valid size is obtained this way, it means that there is no non-empty size satisfying both the constraints and the aspect ratio, so the constraints will not be respected and the content will be sized such that the VolumeConstraints.maxWidth or VolumeConstraints.maxHeight is matched (depending on matchHeightConstraintsFirst). Note that this modifier constrains the ratio between the content's width and height only. The depth dimension is not affected or constrained by this aspect ratio modifier.
Example usage:
SpatialPanel(SubspaceModifier.width(100.dp).aspectRatio(16f / 9f)) {
Text(text = "Inner Composable Content")
}
| Parameters | |
|---|---|
ratio: @FloatRange(from = 0.0, fromInclusive = false) Float |
the desired width/height positive ratio |
matchHeightConstraintsFirst: Boolean = false |
if true, height constraints will be matched before width constraints and used to calculate the resulting size according to |
billboard
fun SubspaceModifier.billboard(enabled: Boolean = true): SubspaceModifier
A SubspaceModifier that forces the content to remain upright and will rotate on the y-axis that the content faces the user at all times.
A user of this API should configure the activity's Session object with Config.HeadTrackingMode.LAST_KNOWN which requires android.permission.HEAD_TRACKING Android permission be granted by the calling application. session.configure( config = session.config.copy(headTracking = Config.HeadTrackingMode.LAST_KNOWN) )
| Parameters | |
|---|---|
enabled: Boolean = true |
true if this composable should always face the user. |
| See also | |
|---|---|
lookAtUser |
modifier for making content that will tilt in all directions to face the user. |
depth
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.
depthIn
fun SubspaceModifier.depthIn(min: Dp = Dp.Unspecified, max: Dp = Dp.Unspecified): SubspaceModifier
Constrain the depth of the content to be between mindp and maxdp as permitted by the incoming measurement constraints. If the incoming constraints are more restrictive the requested size will obey the incoming constraints and attempt to be as close as possible to the preferred size.
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 |
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 |
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 |
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 |
gravityAligned
fun SubspaceModifier.gravityAligned(): SubspaceModifier
A SubspaceModifier that forces the content to remain upright, aligned with gravity by isolating the element's yaw by cancelling parent pitch and roll.
This modifier calculates the necessary counter-rotation to ignore the pitch and roll of its parent entity's total world transformation. It only affects the rotation and not the translation. This is useful for UI elements like labels or billboards that should always stay level, regardless of the orientation of the object they are attached to. It effectively isolates the yaw (rotation around the vertical Y-axis).
height
fun SubspaceModifier.height(height: Dp): SubspaceModifier
Declare the preferred size of the content to be exactly height dp along the y dimension.
heightIn
fun SubspaceModifier.heightIn(min: Dp = Dp.Unspecified, max: Dp = Dp.Unspecified): SubspaceModifier
Constrain the height of the content to be between mindp and maxdp as permitted by the incoming measurement constraints. If the incoming constraints are more restrictive the requested size will obey the incoming constraints and attempt to be as close as possible to the preferred size.
layout
fun SubspaceModifier.layout(
measure: SubspaceMeasureScope.(SubspaceMeasurable, VolumeConstraints) -> SubspaceMeasureResult
): SubspaceModifier
Creates a node that allows changing how the wrapped element is measured and laid out.
lookAtUser
fun SubspaceModifier.lookAtUser(
enabled: Boolean = true,
up: Vector3 = Vector3(0f, 1f, 0f)
): SubspaceModifier
A SubspaceModifier that continuously rotates content so that it faces the user at all times.
A user of this API should configure the activity's Session object with Config.HeadTrackingMode.LAST_KNOWN which requires android.permission.HEAD_TRACKING Android permission be granted by the calling application. session.configure( config = session.config.copy(headTracking = Config.HeadTrackingMode.LAST_KNOWN) )
| Parameters | |
|---|---|
enabled: Boolean = true |
true if this composable should always face the user. |
up: Vector3 = Vector3(0f, 1f, 0f) |
Indicates which direction is "up" when orienting the content upright. LookAtUser makes the front of the content face the user. But this can be accomplished with the content sitting upright, upside-down or any rotation in-between. "up" addresses that ambiguity. By default, up is 0,1,0. |
| See also | |
|---|---|
billboard |
modifier for making content that will generally face the user's direction but keeps the content in an upright position. |
offset
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 or the orientation of the content may have changed. Note that it will be called after a composition when the coordinates are finalized.
This callback executes after composition once the final coordinates are determined. It will be invoked at least once when the SubspaceLayoutCoordinates become available and subsequently whenever the composable's transform (position, rotation, scale) is updated relative to the subspace's origin.
The callback information will be relative to its subspace. For instance, When a nested subspace is moved by the global subspace its Pose will reflect its position in the nested subspace. Its position value will not be updated despite moving locations in the Global Subspace.
onPointSourceParamsAvailable
fun SubspaceModifier.onPointSourceParamsAvailable(
onPointSourceParamsAvailable: (PointSourceParams) -> Unit
): SubspaceModifier
Used to provide a PointSourceParams to allow specifying the modified Composable as an audio source. See PointSourceParams for more info on how to attach this object to a media source.
PointSourceParams are used to configure a sound to be spatialized as a point in 3D space. This is to override the default behavior where sound is played from the SpatialMainPanel.
import androidx.compose.foundation.AndroidExternalSurface import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.unit.dp import androidx.xr.compose.platform.LocalSession import androidx.xr.compose.subspace.MovePolicy import androidx.xr.compose.subspace.SpatialPanel import androidx.xr.compose.subspace.SubspaceComposable import androidx.xr.compose.subspace.layout.SubspaceModifier import androidx.xr.compose.subspace.layout.onPointSourceParamsAvailable import androidx.xr.compose.subspace.layout.size import androidx.xr.scenecore.SpatialMediaPlayer @Composable @SubspaceComposable fun MediaPlayerInSpatialPanel(mediaUri: Uri) { val session = LocalSession.current val context = LocalContext.current val mediaPlayer = remember { MediaPlayer() } val paramsSet = remember { mutableStateOf(false) } SpatialPanel( SubspaceModifier.size(400.dp).onPointSourceParamsAvailable { if (!paramsSet.value) { paramsSet.value = true mediaPlayer.setDataSource(context, mediaUri) SpatialMediaPlayer.setPointSourceParams(session!!, mediaPlayer, it) mediaPlayer.prepare() mediaPlayer.start() } }, dragPolicy = MovePolicy(), ) { DisposableEffect(Unit) { onDispose { mediaPlayer.release() } } // Use this for playing video, or omit it for audio only use cases. AndroidExternalSurface { onSurface { surface, _, _ -> mediaPlayer.setSurface(surface) } } } }
| Parameters | |
|---|---|
onPointSourceParamsAvailable: (PointSourceParams) -> Unit |
Will be called with a |
onSizeChanged
fun SubspaceModifier.onSizeChanged(
onSizeChanged: (size: IntVolumeSize) -> Unit
): SubspaceModifier
Invokes onSizeChanged with the IntVolumeSize of the element when its size changes.
This callback is executed after the layout pass when the SubspaceComposable's size is finalized. It will be invoked at least once when the size becomes available and subsequently whenever the size changes.
For observing changes to position or orientation in addition to size, use SubspaceModifier.onGloballyPositioned instead.
| Parameters | |
|---|---|
onSizeChanged: (size: IntVolumeSize) -> Unit |
The callback that is invoked when the size changes. The |
padding
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
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
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.
pointerHoverIcon
fun SubspaceModifier.pointerHoverIcon(icon: SpatialPointerIcon): SubspaceModifier
When present, this modifier defines how the pointer icon will be displayed when the spatial pointer hovers over an element. Any child elements will inherit the pointer icon setting that this modifier defines for their parent element upon hovering.
| Parameters | |
|---|---|
icon: SpatialPointerIcon |
The |
| Returns | |
|---|---|
SubspaceModifier |
A |
requiredDepth
fun SubspaceModifier.requiredDepth(depth: Dp): SubspaceModifier
Declare the size of the content to be exactly depth dp along the z dimension, disregarding the incoming VolumeConstraints.
This is in contrast to SubspaceModifier.depth, which respects the parent's constraints. requiredDepth will ignore the minDepth and maxDepth from the incoming constraints, which can be useful for sizing an element to a specific value even if it exceeds the parent's bounds.
requiredDepthIn
fun SubspaceModifier.requiredDepthIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
): SubspaceModifier
Constrain the depth of the content to be between min dp and max dp, disregarding the incoming measurement VolumeConstraints.
This is in contrast to SubspaceModifier.depthIn, which respects the parent's constraints. requiredDepthIn will ignore the minDepth and maxDepth from the incoming constraints.
requiredHeight
fun SubspaceModifier.requiredHeight(height: Dp): SubspaceModifier
Declare the size of the content to be exactly height dp along the y dimension, disregarding the incoming VolumeConstraints.
This is in contrast to SubspaceModifier.height, which respects the parent's constraints. requiredHeight will ignore the minHeight and maxHeight from the incoming constraints, which can be useful for sizing an element to a specific value even if it exceeds the parent's bounds.
requiredHeightIn
fun SubspaceModifier.requiredHeightIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
): SubspaceModifier
Constrain the height of the content to be between min dp and max dp, disregarding the incoming measurement VolumeConstraints.
This is in contrast to SubspaceModifier.heightIn, which respects the parent's constraints. requiredHeightIn will ignore the minHeight and maxHeight from the incoming constraints.
requiredSize
fun SubspaceModifier.requiredSize(size: Dp): SubspaceModifier
Declare the size of the content to be exactly a size dp cube, disregarding the incoming VolumeConstraints. When applied to a Panel, the size will be a size dp square instead.
This is in contrast to SubspaceModifier.size, which respects the parent's constraints. requiredSize will ignore all min and max constraints from the incoming constraints, which can be useful for sizing an element to a specific value even if it exceeds the parent's bounds.
requiredSize
fun SubspaceModifier.requiredSize(size: DpVolumeSize): SubspaceModifier
Declare the size of the content to be exactly size in each of the three dimensions, disregarding the incoming VolumeConstraints. Panels have 0 depth and ignore the z-component of this modifier.
This is in contrast to SubspaceModifier.size, which respects the parent's constraints. requiredSize will ignore all min and max constraints from the incoming constraints, which can be useful for sizing an element to a specific value even if it exceeds the parent's bounds. The parent will then determine how to handle the overflow.
requiredSize
fun SubspaceModifier.requiredSize(
width: Dp = Dp.Unspecified,
height: Dp = Dp.Unspecified,
depth: Dp = Dp.Unspecified
): SubspaceModifier
Declare the size of the content to be exactly width, height, and depth in each of the three dimensions, disregarding the incoming VolumeConstraints. Panels have 0 depth and ignore the z-component of this modifier.
This is in contrast to SubspaceModifier.size, which respects the parent's constraints. requiredSize will ignore all min and max constraints from the incoming constraints, which can be useful for sizing an element to a specific value even if it exceeds the parent's bounds. The parent will then determine how to handle the overflow.
requiredSizeIn
fun SubspaceModifier.requiredSizeIn(
minWidth: Dp = Dp.Unspecified,
maxWidth: Dp = Dp.Unspecified,
minHeight: Dp = Dp.Unspecified,
maxHeight: Dp = Dp.Unspecified,
minDepth: Dp = Dp.Unspecified,
maxDepth: Dp = Dp.Unspecified
): SubspaceModifier
Constrain the size of the content to be between min and max dp, disregarding the incoming measurement VolumeConstraints.
This is in contrast to SubspaceModifier.sizeIn, which respects the parent's constraints. requiredSizeIn will ignore the min and max constraints from the incoming constraints, which can be useful for sizing an element to a specific range even if it exceeds the parent's bounds.
| Parameters | |
|---|---|
minWidth: Dp = Dp.Unspecified |
The minimum width. |
maxWidth: Dp = Dp.Unspecified |
The maximum width. |
minHeight: Dp = Dp.Unspecified |
The minimum height. |
maxHeight: Dp = Dp.Unspecified |
The maximum height. |
minDepth: Dp = Dp.Unspecified |
The minimum depth. |
maxDepth: Dp = Dp.Unspecified |
The maximum depth. |
requiredWidth
fun SubspaceModifier.requiredWidth(width: Dp): SubspaceModifier
Declare the size of the content to be exactly width dp along the x dimension, disregarding the incoming VolumeConstraints.
This is in contrast to SubspaceModifier.width, which respects the parent's constraints. requiredWidth will ignore the minWidth and maxWidth from the incoming constraints, which can be useful for sizing an element to a specific value even if it exceeds the parent's bounds.
requiredWidthIn
fun SubspaceModifier.requiredWidthIn(
min: Dp = Dp.Unspecified,
max: Dp = Dp.Unspecified
): SubspaceModifier
Constrain the width of the content to be between min dp and max dp, disregarding the incoming measurement VolumeConstraints.
This is in contrast to SubspaceModifier.widthIn, which respects the parent's constraints. requiredWidthIn will ignore the minWidth and maxWidth from the incoming constraints.
rotate
fun SubspaceModifier.rotate(quaternion: Quaternion): SubspaceModifier
Rotate a subspace element (i.e. Panel) in space with regards to the center of the element. The rotation is directly specified by the provided Quaternion. The Quaternion values are specified as x,y,z,w. Where w is the rotation of the unit vector, in radians.
| Parameters | |
|---|---|
quaternion: Quaternion |
Quaternion describing the rotation. |
rotate
fun SubspaceModifier.rotate(axisAngle: Vector3, rotation: Float): SubspaceModifier
Rotate a subspace element (i.e. Panel) in space with regards to the center of the element. The rotation is defined by a Vector3 and a rotation angle in degrees. The axis angle will be normalized during construction. The rotation will be applied to the unit vector representing the axisAngle.
rotate
fun SubspaceModifier.rotate(pitch: Float = 0.0f, yaw: Float = 0.0f, roll: Float = 0.0f): SubspaceModifier
Rotate a subspace element (i.e. Panel) in space with regards to the center of the element. Parameter rotation angles are specified in degrees. The rotations are applied with the order pitch, then yaw, then roll. If no values are provided, no rotation is applied.
| Parameters | |
|---|---|
pitch: Float = 0.0f |
Rotation around the x-axis. Defaults to |
yaw: Float = 0.0f |
Rotation around the y-axis. Defaults to |
roll: Float = 0.0f |
Rotation around the z-axis. Defaults to |
scale
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. |
semantics
fun SubspaceModifier.semantics(properties: SemanticsPropertyReceiver.() -> Unit): SubspaceModifier
Add semantics key/value pairs to the layout node, for use in testing, accessibility, etc.
size
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.
size
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.
size
fun SubspaceModifier.size(
width: Dp = Dp.Unspecified,
height: Dp = Dp.Unspecified,
depth: Dp = Dp.Unspecified
): SubspaceModifier
Declare the preferred size of the content to be exactly width dp along the x dimensions, height dp along the y dimensions, and depth dp along the z dimension.
sizeIn
fun SubspaceModifier.sizeIn(
minWidth: Dp = Dp.Unspecified,
maxWidth: Dp = Dp.Unspecified,
minHeight: Dp = Dp.Unspecified,
maxHeight: Dp = Dp.Unspecified,
minDepth: Dp = Dp.Unspecified,
maxDepth: Dp = Dp.Unspecified
): SubspaceModifier
Constrain the size of the content to be between min and max dp as permitted by the incoming measurement constraints. If the incoming constraints are more restrictive the requested size will obey the incoming constraints and attempt to be as close as possible to the preferred size.
| Parameters | |
|---|---|
minWidth: Dp = Dp.Unspecified |
The minimum width. |
maxWidth: Dp = Dp.Unspecified |
The maximum width. |
minHeight: Dp = Dp.Unspecified |
The minimum height. |
maxHeight: Dp = Dp.Unspecified |
The maximum height. |
minDepth: Dp = Dp.Unspecified |
The minimum depth. |
maxDepth: Dp = Dp.Unspecified |
The maximum depth. |
testTag
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.
width
fun SubspaceModifier.width(width: Dp): SubspaceModifier
Declare the preferred size of the content to be exactly width dp along the x dimension.
widthIn
fun SubspaceModifier.widthIn(min: Dp = Dp.Unspecified, max: Dp = Dp.Unspecified): SubspaceModifier
Constrain the width of the content to be between mindp and maxdp as permitted by the incoming measurement constraints. If the incoming constraints are more restrictive the requested size will obey the incoming constraints and attempt to be as close as possible to the preferred size.
Top-level properties
ZeroFeatheringEffect
val ZeroFeatheringEffect: SpatialFeatheringEffect
An effect representing no feathering.