Google is committed to advancing racial equity for Black communities. See how.

Owner

interface Owner
androidx.compose.ui.node.Owner

Owner implements the connection to the underlying view system. On Android, this connects to Android views and all layout, draw, input, and accessibility is hooked through them.

Summary

Public methods
abstract IntOffset

Returns the most global position of the owner that Compose can access (such as the device screen).

abstract OwnedLayer
createLayer(drawLayerModifier: DrawLayerModifier, drawBlock: (Canvas) -> Unit, invalidateParentLayer: () -> Unit)

Creates and returns an OwnedLayer for the given drawLayerModifier.

abstract Unit

Iterates through all LayoutNodes that have requested layout and measures and lays them out

abstract Unit
observeLayoutModelReads(node: LayoutNode, block: () -> Unit)

Observe model reads during layout of node, executed in block.

abstract Unit
observeMeasureModelReads(node: LayoutNode, block: () -> Unit)

Observe model reads during measure of node, executed in block.

abstract Unit
observeReads(target: T, onChanged: (T) -> Unit, block: () -> Unit)

Observe model reads for any target, allowing consumers to determine how to respond to state changes

abstract Unit

Called by LayoutNode when it is attached to the view system and now has an owner.

abstract Unit

Called by LayoutNode when it is detached from the view system, such as during LayoutNode.removeAt.

abstract Unit

Called by LayoutNode to request the Owner a new measurement+layout.

abstract Unit

Called by LayoutNode to request the Owner a new layout.

abstract Unit

The semantics have changed.

abstract Unit

Observing the model reads are temporary disabled during the block execution.

abstract Boolean

Ask the system to provide focus to this owner.

abstract Boolean

Send this KeyEvent to the focused component in this Owner.

Properties
abstract Autofill?

The Autofill class can be used to perform autofill operations.

abstract AutofillTree

A data structure used to store autofill information.

abstract ClipboardManager

Provide clipboard manager to the user.

abstract Density

abstract FocusManager

Provide a focus manager that controls focus within Compose.

abstract Font.ResourceLoader

abstract HapticFeedback

Provide haptic feedback to the user.

abstract Boolean

Whether the Owner has pending layout work.

abstract LayoutDirection

abstract Long

abstract LayoutNode

The root layout node in the component tree.

abstract SemanticsOwner

abstract Boolean

true when layout should draw debug bounds.

abstract TextInputService

abstract TextToolbar

Provide toolbar for text-related actions, such as copy, paste, cut etc.

Companion properties
Boolean

Enables additional (and expensive to do in production) assertions.

Public methods

calculatePosition

abstract fun calculatePosition(): IntOffset

Returns the most global position of the owner that Compose can access (such as the device screen).

createLayer

abstract fun createLayer(
    drawLayerModifier: DrawLayerModifier,
    drawBlock: (Canvas) -> Unit,
    invalidateParentLayer: () -> Unit
): OwnedLayer

Creates and returns an OwnedLayer for the given drawLayerModifier.

measureAndLayout

abstract fun measureAndLayout(): Unit

Iterates through all LayoutNodes that have requested layout and measures and lays them out

observeLayoutModelReads

abstract fun observeLayoutModelReads(
    node: LayoutNode,
    block: () -> Unit
): Unit

Observe model reads during layout of node, executed in block.

observeMeasureModelReads

abstract fun observeMeasureModelReads(
    node: LayoutNode,
    block: () -> Unit
): Unit

Observe model reads during measure of node, executed in block.

observeReads

abstract fun <T : OwnerScope> observeReads(
    target: T,
    onChanged: (T) -> Unit,
    block: () -> Unit
): Unit

Observe model reads for any target, allowing consumers to determine how to respond to state changes

onAttach

abstract fun onAttach(node: LayoutNode): Unit

Called by LayoutNode when it is attached to the view system and now has an owner. This is used by Owner to track which nodes are associated with it. It will only be called when node is not already attached to an owner.

onDetach

abstract fun onDetach(node: LayoutNode): Unit

Called by LayoutNode when it is detached from the view system, such as during LayoutNode.removeAt. This will only be called for nodes that are already LayoutNode.attached.

onRequestMeasure

abstract fun onRequestMeasure(layoutNode: LayoutNode): Unit

Called by LayoutNode to request the Owner a new measurement+layout.

onRequestRelayout

abstract fun onRequestRelayout(layoutNode: LayoutNode): Unit

Called by LayoutNode to request the Owner a new layout.

onSemanticsChange

abstract fun onSemanticsChange(): Unit

The semantics have changed. This function will be called when a SemanticsNode is added to or deleted from the Semantics tree. It will also be called when a SemanticsNode in the Semantics tree has some property change.

pauseModelReadObserveration

abstract fun pauseModelReadObserveration(block: () -> Unit): Unit

Observing the model reads are temporary disabled during the block execution. For example if we are currently within the measure stage and we want some code block to be skipped from the observing we disable if before calling the block, execute block and then enable it again.

requestFocus

abstract fun requestFocus(): Boolean

Ask the system to provide focus to this owner.

Return
true if the system granted focus to this owner. False otherwise.

sendKeyEvent

abstract fun sendKeyEvent(keyEvent: KeyEvent): Boolean

Send this KeyEvent to the focused component in this Owner.

Return
true if the event was consumed. False otherwise.

Properties

autofill

abstract val autofill: Autofill?

The Autofill class can be used to perform autofill operations. It is used as an ambient.

autofillTree

abstract val autofillTree: AutofillTree

A data structure used to store autofill information. It is used by components that want to provide autofill semantics. TODO(ralu): Replace with SemanticsTree. This is a temporary hack until we have a semantics tree implemented.

clipboardManager

abstract val clipboardManager: ClipboardManager

Provide clipboard manager to the user. Use the Android version of clipboard manager.

density

abstract val density: Density

focusManager

abstract val focusManager: FocusManager

Provide a focus manager that controls focus within Compose.

fontLoader

abstract val fontLoader: Font.ResourceLoader

hapticFeedBack

abstract val hapticFeedBack: HapticFeedback

Provide haptic feedback to the user. Use the Android version of haptic feedback.

hasPendingMeasureOrLayout

abstract val hasPendingMeasureOrLayout: Boolean

Whether the Owner has pending layout work.

layoutDirection

abstract val layoutDirection: LayoutDirection

measureIteration

abstract val measureIteration: Long

root

abstract val root: LayoutNode

The root layout node in the component tree.

semanticsOwner

abstract val semanticsOwner: SemanticsOwner

showLayoutBounds

abstract var showLayoutBounds: Boolean

true when layout should draw debug bounds.

textInputService

abstract val textInputService: TextInputService

textToolbar

abstract val textToolbar: TextToolbar

Provide toolbar for text-related actions, such as copy, paste, cut etc.

Companion properties

enableExtraAssertions

var enableExtraAssertions: Boolean

Enables additional (and expensive to do in production) assertions. Useful to be set to true during the tests covering our core logic.