androidx.compose.ui.layout

LayoutCoordinates

Interface · from org.jetbrains.compose.ui:ui:1.12.2

No hand-written docs yet.

A holder of the measured bounds for the Layout.

interface LayoutCoordinates

How to get one

Ready-made values and functions that return it

Used by

Parameters that take a LayoutCoordinates.

Properties

size

val size: IntSize

The size of this layout in the local coordinates space.

providedAlignmentLines

val providedAlignmentLines: Set<AlignmentLine>

The alignment lines provided for this layout, not including inherited lines.

parentLayoutCoordinates

val parentLayoutCoordinates: LayoutCoordinates?

The coordinates of the parent layout. Null if there is no parent.

parentCoordinates

val parentCoordinates: LayoutCoordinates?

The coordinates of the parent layout modifier or parent layout if there is no parent layout modifier, or null if there is no parent.

isAttached

val isAttached: Boolean

Returns false if the corresponding layout was detached from the hierarchy.

introducesMotionFrameOfReference

val introducesMotionFrameOfReference: Boolean

Indicates whether the corresponding Layout is expected to change its Offset in small increments (such as when its parent is a Scroll).

Functions

screenToLocal

fun screenToLocal(relativeToScreen: Offset): Offset

Converts relativeToScreen relative to the device's screen's origin into an Offset relative to this layout. Returns Offset.Unspecified if the conversion cannot be performed.

localToScreen

fun localToScreen(relativeToLocal: Offset): Offset

Converts relativeToLocal position within this layout into an Offset relative to the device's screen. Returns Offset.Unspecified if the conversion cannot be performed.

windowToLocal

fun windowToLocal(relativeToWindow: Offset): Offset

Converts relativeToWindow relative to the window's origin into an Offset relative to this layout.

localToWindow

fun localToWindow(relativeToLocal: Offset): Offset

Converts relativeToLocal position within this layout into an Offset relative to the window's origin.

localToRoot

fun localToRoot(relativeToLocal: Offset): Offset

Converts a local position within this layout into an offset from the root composable.

localPositionOf

fun localPositionOf(sourceCoordinates: LayoutCoordinates, relativeToSource: Offset): Offset

Converts an relativeToSource in sourceCoordinates space into local coordinates. sourceCoordinates may be any LayoutCoordinates that belong to the same compose layout hierarchy.

fun localPositionOf(
    sourceCoordinates: LayoutCoordinates,
    relativeToSource: Offset = Offset.Zero,
    includeMotionFrameOfReference: Boolean = true,
): Offset

Converts an relativeToSource in sourceCoordinates space into local coordinates. sourceCoordinates may be any LayoutCoordinates that belong to the same compose layout hierarchy.

localBoundingBoxOf

fun localBoundingBoxOf(
    sourceCoordinates: LayoutCoordinates,
    clipBounds: Boolean = true,
): Rect

Returns the bounding box of sourceCoordinates in the local coordinates. If clipBounds is true, any clipping that occurs between sourceCoordinates and this layout will affect the returned bounds, and can even result in an empty rectangle if clipped regions do not overlap. If clipBounds is false, the bounding box of sourceCoordinates will be converted to local coordinates irrespective of any clipping applied between the layouts.

transformFrom

fun transformFrom(sourceCoordinates: LayoutCoordinates, matrix: Matrix)

Modifies matrix to be a transform to convert a coordinate in sourceCoordinates to a coordinate in this LayoutCoordinates.

transformToScreen

fun transformToScreen(matrix: Matrix)

Takes a matrix which transforms some coordinate system C to local coordinates, and updates the matrix to transform from C to screen coordinates instead.

get

fun get(alignmentLine: AlignmentLine): Int

Returns the position in pixels of an [alignment line]AlignmentLine, or AlignmentLine.Unspecified if the line is not provided.

Library docs

A holder of the measured bounds for the Layout.