MovePolicy
sealed interface MovePolicy
Defines the behavior and configuration for movement applied by the movable modifier.
Summary
Public companion functions |
|
|---|---|
MovePolicy |
@ExperimentalMoveAnchorPolicyA policy that enables anchoring the movable element to detected real-world planes. |
MovePolicy |
custom(scaleWithDistance: Boolean, onMove: (SpatialMoveEvent) -> Unit)A policy that accepts move events and reports the calculated pose updates via a callback, without automatically applying a resulting transformation. |
MovePolicy |
system(scaleWithDistance: Boolean, onMove: ((SpatialMoveEvent) -> Unit)?)A policy that delegates the pose transformation entirely to the system. |
Public companion properties |
|
|---|---|
MovePolicy |
The default system-handled move policy. |
Public companion functions
anchor
@ExperimentalMoveAnchorPolicy
fun anchor(
anchorPlaneOrientations: Set<PlaneOrientation> = emptySet(),
anchorPlaneSemantics: Set<PlaneSemantic> = emptySet(),
onMove: ((SpatialMoveEvent) -> Unit)? = null
): MovePolicy
A policy that enables anchoring the movable element to detected real-world planes.
Using this policy allows the user to snap the subspace element to physical surfaces (like tables or walls) that match the provided orientations and semantics. If no specific orientations or semantics are provided (i.e., the sets are empty), the element is permitted to anchor to any detected plane.
Note: Once a composable is anchored to an external plane using this policy, it is reparented outside the normal Compose hierarchy. As a result, conventional layout pose calculations and pose-based modifiers (such as rotate or gravityAligned) are not currently compatible with the anchored composable.
| Parameters | |
|---|---|
anchorPlaneOrientations: Set<PlaneOrientation> = emptySet() |
The set of |
anchorPlaneSemantics: Set<PlaneSemantic> = emptySet() |
The set of |
onMove: ((SpatialMoveEvent) -> Unit)? = null |
Optional observer callback invoked during the manipulation to monitor the movement and anchoring events. |
custom
fun custom(
scaleWithDistance: Boolean = false,
onMove: (SpatialMoveEvent) -> Unit
): MovePolicy
A policy that accepts move events and reports the calculated pose updates via a callback, without automatically applying a resulting transformation.
This policy enables custom behavior for movement of the content. The system calculates the target Pose based on input, but does not automatically apply it to the associated layout. The developer is responsible for consuming the onMove event and applying the result (e.g., by updating a state backed by SubspaceModifier.offset). Using this policy has higher latency than system.
| Parameters | |
|---|---|
scaleWithDistance: Boolean = false |
true if this composable should scale in size when moved in depth. When enabled, the subspace element will grow if pushed away from the user or shrink when pulled toward the user in order to maintain the interactability and legibility of the panel. Scaling with distance respects other transformations applied to this layout. |
onMove: (SpatialMoveEvent) -> Unit |
callback invoked continuously during the interaction that receives a |
system
fun system(
scaleWithDistance: Boolean = true,
onMove: ((SpatialMoveEvent) -> Unit)? = null
): MovePolicy
A policy that delegates the pose transformation entirely to the system.
The system intercepts spatial input events, calculates the resulting Pose and scale, and automatically applies these transformations to the element's layout. This is the standard behavior where a 1:1 transformation is desired, and custom gesture handling or manual state management is not required. This policy will have a better overall performance than the custom policy.
| Parameters | |
|---|---|
scaleWithDistance: Boolean = true |
true if this composable should scale in size when moved in depth. When enabled, the subspace element will grow if pushed away from the user or shrink when pulled toward the user in order to maintain the interactability and legibility of the panel. Scaling with distance respects other transformations applied to this layout. |
onMove: ((SpatialMoveEvent) -> Unit)? = null |
Optional observer callback invoked during the manipulation. Since the system automatically applies the move, this callback is strictly for monitoring changes and should not control the position. The |