OverlayHandle

fun VideoStageScope.OverlayHandle(placement: OverlayPlacement, onFrameAnchorChange: (Anchor) -> Unit, output: Size, modifier: Modifier = Modifier, colors: OverlayHandleColors = OverlayHandleDefaults.Palette, handleLength: Dp = OverlayHandleDefaults.HandleLength, enabled: Boolean = true, content: @Composable () -> Unit = { })(source)

A draggable box over the video a VideoStage is showing, drawn where the overlay it stands for really lands.

Controlled, so a drag reports the frame anchor it wants through onFrameAnchorChange and the box moves only when a placement carrying that anchor comes back. A host that drops the change draws a handle that does not move.

The box is placement resolved against output and mapped through the stage's own letterbox, so a handle sits over an overlay the effect chain has already burnt into the picture rather than beside it. placement and output are the pair placedOn produced and the frame it was given, and only the frame's proportions are read, so a stage measured in view pixels answers the same as the composition's output frame.

A drag keeps the point the overlay anchors to inside the frame, and the overlay's own centre inside it, which leaves at least a quarter of the overlay over the picture at the far corners.

content is the host's stand-in for the overlay, its text or its image, drawn inside the box. The handle draws the wash, the outline and the corner brackets, never the payload.

val placement = remember(text, anchor, measured) { TextOverlay(text, anchor = anchor).placedOn(measured) }

VideoStage(player = player, outputAspect = outputAspect) {
OverlayHandle(
placement = placement,
onFrameAnchorChange = { anchor = it },
output = outputSize,
)
}

Parameters

placement

Where the overlay lands, from placedOn.

onFrameAnchorChange

Called with the frame anchor a drag asks for, already held on the frame.

output

The frame placement was resolved against, in pixels.

modifier

Modifier for the handle, which fills the stage and places the box inside itself.

colors

What the handle paints with.

handleLength

How long a corner bracket's arms are drawn.

enabled

Whether the handle answers a drag and draws its brackets.

content

The host's stand-in for the overlay, drawn inside the box.