RelativeLayoutBounds
class RelativeLayoutBounds
internal constructor(
private val topLeft: Long,
private val bottomRight: Long,
private val windowOffset: IntOffset,
private val screenOffset: IntOffset,
private val windowSize: Long,
private val viewToWindowMatrix: Matrix?,
private val node: DelegatableNode,
)
Represents an axis-aligned bounding Rectangle for an element in a compose hierarchy, in the coordinates of either the Root of the compose hierarchy, the Window, or the Screen.
Properties
val positionInRoot: IntOffset
The top left position of the Rect in the coordinates of the root node of the compose hierarchy.
val positionInWindow: IntOffset
The top left position of the Rect in the coordinates of the Window it is contained in
val positionInScreen: IntOffset
The top left position of the Rect in the coordinates of the Screen it is contained in.
val width: Int
The width, in pixels, of the Rect
val height: Int
The height, in pixels, of the Rect
val boundsInRoot: IntRect
The positioned bounding Rect in the coordinates of the root node of the compose hierarchy.
val boundsInWindow: IntRect
The positioned bounding Rect in the coordinates of the Window which it is contained in.
val boundsInScreen: IntRect
The positioned bounding Rect in the coordinates of the Screen which it is contained in.
Functions
fun calculateOcclusions(): List<IntRect>
At the current state of the layout, calculates which other Composable Layouts are occluding
the Composable associated with this RelativeLayoutBounds
. Note: Calling this method
during measure or layout may result on calculations with stale (or partially stale) layout
information.
An occlusion is defined by an intersecting Composable that may draw on top of the target Composable.
There's no guarantee that something was actually drawn to occlude, so a transparent Composable that could otherwise draw on top of the target is considered to be occluding.
There's no differentiation between partial and complete occlusions, they are all included as part of this calculation.
Ancestors, child and grandchild Layouts are never considered to be occluding.
Returns
A List of the rectangles that occlude the associated Composable Layout. |
fun fractionVisibleIn(viewport: RelativeLayoutBounds): Float
Used to determine the fraction of pixels that are inside the bounds of the viewport
.
If the viewport
is entirely contained inside of the bounds, this method will return 1f.
Otherwise, this will return the fraction of pixels of this element that are contained inside
the viewport
bounds.
fun fractionVisibleInRect(left: Int, top: Int, right: Int, bottom: Int): Float
Used to determine the fraction of pixels that are inside the provided rectangle.
If the rectangle is entirely contained inside of the bounds, this method will return 1f. Otherwise, this will return the fraction of pixels of this element that are contained inside the rectangle.
fun fractionVisibleInWindow(): Float
Used to determine the fraction of pixels that are inside the bounds of the window.
If the window is entirely contained inside of the bounds, this method will return 1f. Otherwise, this will return the fraction of pixels of this element that are contained inside the rectangle.
fun fractionVisibleInWindowWithInsets(
topLeftInset: IntOffset,
bottomRightInset: IntOffset,
): Float
Used to determine the fraction of pixels that are inside the rectangle defined by the window with the provided insets subtracted.
If the rectangle is entirely contained inside of the bounds, this method will return 1f. Otherwise, this will return the fraction of pixels of this element that are contained inside the rectangle.