androidx.ink.authoring.compose
Top-level functions summary
Unit |
@ComposableA |
Unit |
@ComposableA |
Top-level functions
InProgressShapes
@Composable
fun <ShapeSpecT : Any, InProgressShapeT : InProgressShape<ShapeSpecT, CompletedShapeT>, CompletedShapeT : Any> InProgressShapes(
customShapeWorkflow: ShapeWorkflow<ShapeSpecT, InProgressShapeT, CompletedShapeT>,
defaultShapeSpec: ShapeSpecT?,
nextShapeSpec: () -> ShapeSpecT? = { defaultShapeSpec },
pointerEventToWorldTransform: Matrix = IDENTITY_MATRIX,
shapeToWorldTransform: Matrix = IDENTITY_MATRIX,
maskPath: Path? = null,
onShapesCompleted: (List<CompletedShapeT>) -> Unit
): Unit
A Composable that displays in-progress ink shapes as it receives user pointer input.
Multiple simultaneous shapes are supported. This implementation handles all best practices for the fastest, lowest latency rendering of real-time user input. For an alternative compatible with Android Views, see InProgressShapesView.
For performance reasons, it is recommended to only have one InProgressShapes on screen at a time, and to avoid unnecessarily resizing it or changing whether it is present on screen.
This will process pointers (and display the resulting shapes) that are not already consumed by an earlier touch listener - when androidx.compose.ui.input.pointer.PointerInputChange.isConsumed is false. If a pointer's down event arrives to this composable already consumed, it will not be drawn, even if later events for that pointer arrive unconsumed. If a pointer's initial events are not consumed by arrival, then it will be drawn, but if its later events have been consumed by arrival then the shape for that pointer will be canceled and removed from this composable's UI. If all of a pointer's events from down through moves through up arrive to this composable unconsumed, then the entire shape will be drawn and finished, and the completed shape will be made available by a call to onShapesCompleted. All shapes that were in progress simultaneously will be delivered in the same callback, running on the UI thread. To avoid visual flicker when transitioning rendering from this composable to another composable, during this callback the finished shapes must be added to some mutable state that triggers a recomposition that will render those shapes, typically using androidx.ink.rendering.android.canvas.CanvasStrokeRenderer.
| Parameters | |
|---|---|
customShapeWorkflow: ShapeWorkflow<ShapeSpecT, InProgressShapeT, CompletedShapeT> |
A |
defaultShapeSpec: ShapeSpecT? |
Specification for the shape being started. If this is |
nextShapeSpec: () -> ShapeSpecT? = { defaultShapeSpec } |
A way to override |
pointerEventToWorldTransform: Matrix = IDENTITY_MATRIX |
The matrix that transforms |
shapeToWorldTransform: Matrix = IDENTITY_MATRIX |
Allows an object-specific (shape-specific) coordinate space to be defined in relation to the caller's "world" coordinate space. This defaults to the identity matrix, which is typical for many use cases at the time of shape construction. In typical use cases, shape coordinates and world coordinates may start to differ from one another only after shape authoring as a finished shape is manipulated within the world, e.g. it may be moved, scaled, or rotated relative to other content within an app's document. This matrix must be invertible. |
maskPath: Path? = null |
An area of this composable where no ink will be visible. A value of |
onShapesCompleted: (List<CompletedShapeT>) -> Unit |
Called when there are no longer any in-progress shapes for a short period. All shapes that were in progress simultaneously will be delivered in the same callback, running on the UI thread. The callback should pass the shapes to another |
InProgressStrokes
@Composable
fun InProgressStrokes(
defaultBrush: Brush?,
nextBrush: () -> Brush? = { defaultBrush },
pointerEventToWorldTransform: Matrix = IDENTITY_MATRIX,
strokeToWorldTransform: Matrix = IDENTITY_MATRIX,
maskPath: Path? = null,
textureBitmapStore: TextureBitmapStore = TextureBitmapStore { null },
onStrokesFinished: (List<Stroke>) -> Unit
): Unit
A Composable that displays in-progress ink strokes as it receives user pointer input.
Multiple simultaneous strokes are supported. This implementation handles all best practices for the fastest, lowest latency rendering of real-time user input. For an alternative compatible with Android Views, see androidx.ink.authoring.InProgressStrokesView.
For performance reasons, it is recommended to only have one InProgressStrokes on screen at a time, and to avoid unnecessarily resizing it or changing whether it is present on screen.
This will process pointers (and display the resulting strokes) that are not already consumed by an earlier touch listener - when androidx.compose.ui.input.pointer.PointerInputChange.isConsumed is false. If a pointer's down event arrives to this composable already consumed, it will not be drawn, even if later events for that pointer arrive unconsumed. If a pointer's initial events are not consumed by arrival, then it will be drawn, but if its later events have been consumed by arrival then the stroke for that pointer will be canceled and removed from this composable's UI. If all of a pointer's events from down through moves through up arrive to this composable unconsumed, then the entire stroke will be drawn and finished, and the finished stroke will be made available by a call to onStrokesFinished. All strokes that were in progress simultaneously will be delivered in the same callback, running on the UI thread. To avoid visual flicker when transitioning rendering from this composable to another composable, during this callback the finished strokes must be added to some mutable state that triggers a recomposition that will render those strokes, typically using androidx.ink.rendering.android.canvas.CanvasStrokeRenderer.
| Parameters | |
|---|---|
defaultBrush: Brush? |
|
nextBrush: () -> Brush? = { defaultBrush } |
A way to override |
pointerEventToWorldTransform: Matrix = IDENTITY_MATRIX |
The matrix that transforms |
strokeToWorldTransform: Matrix = IDENTITY_MATRIX |
Allows an object-specific (stroke-specific) coordinate space to be defined in relation to the caller's "world" coordinate space. This defaults to the identity matrix, which is typical for many use cases at the time of stroke construction. In typical use cases, stroke coordinates and world coordinates may start to differ from one another only after stroke authoring as a finished stroke is manipulated within the world, e.g. it may be moved, scaled, or rotated relative to other content within an app's document. This matrix must be invertible. |
maskPath: Path? = null |
An area of this composable where no ink will be visible. A value of |
textureBitmapStore: TextureBitmapStore = TextureBitmapStore { null } |
Allows texture asset images to be loaded, corresponding to texture layers that may be specified by |
onStrokesFinished: (List<Stroke>) -> Unit |
Called when there are no longer any in-progress strokes for a short period. All strokes that were in progress simultaneously will be delivered in the same callback, running on the UI thread. The callback should pass the strokes to another |