# PopupPositionProvider

Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/window/Popup.kt+class:androidx.compose.ui.window.PopupPositionProvider) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  interface PopupPositionProvider
  ```
Known direct subclasses [DropdownMenuPopupPositionProvider](https://developer.android.com/reference/kotlin/androidx/compose/material3/DropdownMenuPopupPositionProvider)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/material3/DropdownMenuPopupPositionProvider` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/window/PopupPositionProvider` that communicates the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/TransformOrigin` to dropdown menu's implementation. |

*** ** * ** ***

Calculates the position of a `https://developer.android.com/reference/kotlin/androidx/compose/ui/window/Popup.composable#Popup(androidx.compose.ui.Alignment,androidx.compose.ui.unit.IntOffset,kotlin.Function0,androidx.compose.ui.window.PopupProperties,kotlin.Function0)` on screen.

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntOffset` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/window/PopupPositionProvider#calculatePosition(androidx.compose.ui.unit.IntRect,androidx.compose.ui.unit.IntSize,androidx.compose.ui.unit.LayoutDirection,androidx.compose.ui.unit.IntSize)( anchorBounds: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntRect, windowSize: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize, layoutDirection: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/LayoutDirection, popupContentSize: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize )` Calculates the position of a `https://developer.android.com/reference/kotlin/androidx/compose/ui/window/Popup.composable#Popup(androidx.compose.ui.Alignment,androidx.compose.ui.unit.IntOffset,kotlin.Function0,androidx.compose.ui.window.PopupProperties,kotlin.Function0)` on screen. | Cmn |

## Public functions

### calculatePosition

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

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

Calculates the position of a `https://developer.android.com/reference/kotlin/androidx/compose/ui/window/Popup.composable#Popup(androidx.compose.ui.Alignment,androidx.compose.ui.unit.IntOffset,kotlin.Function0,androidx.compose.ui.window.PopupProperties,kotlin.Function0)` 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: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntRect` | The window relative bounds of the layout which this popup is anchored to. |
| `windowSize: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize` | The size of the window containing the anchor layout. |
| `layoutDirection: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/LayoutDirection` | The layout direction of the anchor layout. |
| `popupContentSize: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntSize` | The size of the popup's content. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/IntOffset` | The window relative position where the popup should be positioned. |