PopupPositionProvider


Calculates the position of a Popup on screen.

Summary

Public functions

IntOffset
calculatePosition(
    anchorBounds: IntRect,
    windowSize: IntSize,
    layoutDirection: LayoutDirection,
    popupContentSize: IntSize
)

Calculates the position of a Popup on screen.

Cmn

Public functions

calculatePosition

fun calculatePosition(
    anchorBounds: IntRect,
    windowSize: IntSize,
    layoutDirection: LayoutDirection,
    popupContentSize: IntSize
): IntOffset

Calculates the position of a Popup on screen.

The window size is useful in cases where the popup is meant to be positioned next to its anchor instead of inside of it. The size can be used to calculate available space around the parent to find a spot with enough clearance (e.g. when implementing a dropdown). Note that positioning the popup outside of the window bounds might prevent it from being visible.

Parameters
anchorBounds: IntRect

The window relative bounds of the layout which this popup is anchored to.

windowSize: IntSize

The size of the window containing the anchor layout.

layoutDirection: LayoutDirection

The layout direction of the anchor layout.

popupContentSize: IntSize

The size of the popup's content.

Returns
IntOffset

The window relative position where the popup should be positioned.