Composable Function

Orbiter

A composable that creates an orbiter along the top or bottom edges of a view.

OrbiterBottomBarSample

/**
 * Sample demonstrating a bottom bar orbiter positioning using [OrbiterPosition].
 *
 * ```
 * +------------------------+
 * |                        |
 * |                        |
 * |      SpatialPanel      |
 * |                        |
 * |      +---------+       |
 * +------| Orbiter |-------+
 *        +---------+
 * ```
 */
@Sampled
@Composable
@SubspaceComposable
public fun OrbiterBottomBarSample() {
    SpatialPanel(SubspaceModifier.width(400.dp).height(300.dp)) {
        // Place a horizontal bar orbiter at the bottom-center edge of the panel.
        Orbiter(
            position =
                OrbiterPosition.BottomCenter(
                    offset = DpVolumeOffset(x = 0.dp, y = 0.dp, z = OrbiterDefaults.Elevation),
                    verticalEdgeAlignment = EdgeAlignment.Center,
                )
        ) {
            Box(
                modifier = Modifier.size(200.dp, 64.dp).background(Color.DarkGray),
                contentAlignment = Alignment.Center,
            ) {
                Text("Bottom Bar", color = Color.White, fontSize = 18.sp)
            }
        }
    }
}

/**
 * Sample demonstrating a top rail orbiter positioning using [OrbiterPosition].
 *
 * ```
 *     +---------+
 *     | Orbiter |
 *     +---------+--------------+
 *     |                        |
 *     |      SpatialPanel      |
 *     |                        |
 *     |                        |
 *     +------------------------+
 * ```
 */

OrbiterTopRailSample

@Sampled
@Composable
@SubspaceComposable
public fun OrbiterTopRailSample() {
    SpatialPanel(SubspaceModifier.width(400.dp).height(300.dp)) {
        // Place the orbiter at the top-start corner: horizontally aligned inside the left edge,
        // but vertically sitting completely above (outside) the top edge.
        Orbiter(
            position =
                OrbiterPosition.TopStart(
                    offset = DpVolumeOffset(x = 0.dp, y = 0.dp, z = OrbiterDefaults.Elevation),
                    horizontalEdgeAlignment = EdgeAlignment.Inside,
                    verticalEdgeAlignment = EdgeAlignment.Outside,
                )
        ) {
            Box(
                modifier = Modifier.size(200.dp, 64.dp).background(Color.DarkGray),
                contentAlignment = Alignment.Center,
            ) {
                Text("Top Rail", color = Color.White, fontSize = 18.sp)
            }
        }
    }
}

/**
 * Sample demonstrating a side rail orbiter positioning using [OrbiterPosition].
 *
 * ```
 * +---------+------------------------+
 * | Orbiter |                        |
 * +---------+                        |
 *           |      SpatialPanel      |
 *           |                        |
 *           |                        |
 *           +------------------------+
 * ```
 */

OrbiterSideRailSample

@Sampled
@Composable
@SubspaceComposable
public fun OrbiterSideRailSample() {
    SpatialPanel(SubspaceModifier.width(400.dp).height(300.dp)) {
        // Place the orbiter at the top-start corner: horizontally sitting completely to the side
        // (outside) of the left edge, but vertically aligned inside the top boundary.
        Orbiter(
            position =
                OrbiterPosition.TopStart(
                    offset = DpVolumeOffset(x = 0.dp, y = 0.dp, z = OrbiterDefaults.Elevation),
                    horizontalEdgeAlignment = EdgeAlignment.Outside,
                    verticalEdgeAlignment = EdgeAlignment.Inside,
                )
        ) {
            Box(
                modifier = Modifier.size(64.dp, 200.dp).background(Color.DarkGray),
                contentAlignment = Alignment.Center,
            ) {
                Text("Rail", color = Color.White, fontSize = 18.sp)
            }
        }
    }
}

Content updated: