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 |
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. |
SpatialSmoothFeatheringSize |
Defines a feathering size based on the percent width and height of the layout. |
SubspaceLayoutCoordinates |
A holder of the measured bounds. |
SubspaceModifier |
An ordered, immutable collection of |
Classes
CombinedSubspaceModifier |
A node in a |
MoveEndEvent |
An event representing the end of a move event. |
MoveEvent |
An event representing a change in pose, scale, and size. |
MoveStartEvent |
An event representing the start of a move event. |
Placeable |
A |
Placeable.PlacementScope |
Receiver scope that permits explicit placement of a |
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. |
SpatialRoundedCornerShape |
A shape describing a rectangle with rounded corners in 3D space. |
SpatialShape |
Base type for shapes that could be applied to spatial elements. |
SpatialSmoothFeatheringEffect |
A feathering effect that applies an alpha gradient to the edges of the canvas to give a fade out effect. |
SubspaceModifier.Node |
The longer-lived object that is created for each |
TestTagNode |
Objects
SubspaceModifier.Companion |
The companion object |
Type aliases
PoseChangeEvent |
This type alias is deprecated. Use MoveEvent instead |
Top-level functions summary
SpatialSmoothFeatheringEffect |
SpatialSmoothFeatheringEffect(horizontal: Dp, vertical: Dp) Defines a |
SpatialSmoothFeatheringEffect |
SpatialSmoothFeatheringEffect(horizontal: Float, vertical: Float) Defines a |
SpatialSmoothFeatheringEffect |
SpatialSmoothFeatheringEffect( Defines |
inline Unit |
@SubspaceComposable
|
inline Unit |
@SubspaceComposable
|
SpatialSmoothFeatheringSize |
spatialSmoothFeatheringSize(horizontal: Dp, vertical: Dp) Defines a smooth feathering size using |
SpatialSmoothFeatheringSize |
spatialSmoothFeatheringSize(horizontal: Float, vertical: Float) Defines a smooth feathering size using on pixels. |
SpatialSmoothFeatheringSize |
spatialSmoothFeatheringSize( Defines a smooth feathering size based on the percent width and height of the layout. |
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.depth(depth: Dp) Declare the preferred size of the content to be exactly |
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 |
SubspaceModifier.height(height: Dp) Declare the preferred size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.movable( 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) |
SubspaceModifier |
SubspaceModifier.onGloballyPositioned( Invoke |
SubspaceModifier |
SubspaceModifier.onPointSourceParams( Used to provide a |
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 |
|
SubspaceModifier |
SubspaceModifier.requiredDepth(depth: Dp) Declare the size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.requiredHeight(height: Dp) Declare the size of the content to be exactly |
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.requiredWidth(width: Dp) Declare the size of the content to be exactly |
SubspaceModifier |
SubspaceModifier.resizable( 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 |
SubspaceModifier.rotate(quaternion: Quaternion) 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 |
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.testTag(tag: String) 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 |
SubspaceModifier.width(width: Dp) Declare the preferred size of the content to be exactly |
Top-level properties summary
SpatialSmoothFeatheringSize |
A size representing no feathering. |
Top-level functions
SpatialSmoothFeatheringEffect
fun SpatialSmoothFeatheringEffect(horizontal: Dp, vertical: Dp): SpatialSmoothFeatheringEffect
Defines a SpatialSmoothFeatheringEffect
using Dp
.
SpatialSmoothFeatheringEffect
fun SpatialSmoothFeatheringEffect(horizontal: Float, vertical: Float): SpatialSmoothFeatheringEffect
Defines a SpatialSmoothFeatheringEffect
using pixels.
SpatialSmoothFeatheringEffect
fun SpatialSmoothFeatheringEffect(
percentHorizontal: @IntRange(from = 0, to = 50) Int,
percentVertical: @IntRange(from = 0, to = 50) Int
): SpatialSmoothFeatheringEffect
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 width the visible canvas. Accepted value range is 0 - 50 percent. |
SubspaceLayout
@SubspaceComposable
@Composable
inline fun SubspaceLayout(
modifier: SubspaceModifier = SubspaceModifier,
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. |
measurePolicy: MeasurePolicy |
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: 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 | |
---|---|
crossinline content: @Composable @SubspaceComposable () -> Unit |
the children composable to be laid out. |
modifier: SubspaceModifier = SubspaceModifier |
SubspaceModifier to apply during layout |
measurePolicy: MeasurePolicy |
a policy defining the measurement and positioning of the layout. |
spatialSmoothFeatheringSize
fun spatialSmoothFeatheringSize(horizontal: Dp, vertical: Dp): SpatialSmoothFeatheringSize
Defines a smooth feathering size using Dp
.
spatialSmoothFeatheringSize
fun spatialSmoothFeatheringSize(horizontal: Float, vertical: Float): SpatialSmoothFeatheringSize
Defines a smooth feathering size using on pixels.
spatialSmoothFeatheringSize
fun spatialSmoothFeatheringSize(
percentHorizontal: @IntRange(from = 0, to = 50) Int,
percentVertical: @IntRange(from = 0, to = 50) Int
): SpatialSmoothFeatheringSize
Defines a smooth feathering size 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 width the visible canvas. Accepted value range is 0 - 50 percent. |
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 |
|
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.
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 |
height
fun SubspaceModifier.height(height: Dp): SubspaceModifier
Declare the preferred size of the content to be exactly height
dp along the y dimension.
movable
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 SubspaceModifier
s 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 |
onMoveEnd: ((MoveEndEvent) -> Unit)? = null |
a callback to process the end of a move event. This will only be called if |
onMove: ((MoveEvent) -> Boolean)? = null |
a callback to process the pose change during movement, with translation in pixels. This will only be called if |
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 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 |
|
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
.
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.
resizable
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 |
rotate
fun SubspaceModifier.rotate(quaternion: Quaternion): SubspaceModifier
Rotate a subspace element (i.e. Panel) in space.
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.
rotate
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.
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 |
|
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.
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
.
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.
width
fun SubspaceModifier.width(width: Dp): SubspaceModifier
Declare the preferred size of the content to be exactly width
dp along the x dimension.
Top-level properties
ZeroFeatheringSize
val ZeroFeatheringSize: SpatialSmoothFeatheringSize
A size representing no feathering.