Skip to main content

Module popup

Module popup 

Source
Expand description

Top-level overlay / Popup primitive.

Compose parity with androidx.compose.ui.window.Popup: content composed inside a Popup renders in a top-level overlay that draws above all normal content and is not clipped by the bounds of the ancestor the call site sits under. This is what lets a text field’s selection handles hang below the last line, and a contextual menu float above a selection, without being cut off by a scrolling parent’s clip rectangle.

§How it works

Composition is single-rooted and both paint order and hit-test order are derived purely from tree position (later sibling = on top, and a node is only clipped by an ancestor that opted into clip_to_bounds). Therefore the only way for content to draw above everything and escape any ancestor clip is to be composed as a last-order sibling directly under an unclipped root. PopupHost provides exactly that root: it wraps the whole app in an unclipped, viewport-filling [Box] and renders every registered popup as a trailing child, positioned absolutely at its anchor.

Popup itself emits no node at its call site. Instead it registers its (position, content) into a PopupRegistry carried down the tree by a [CompositionLocal]; the enclosing PopupHost reads that registry and composes the content at the root. Registration/teardown is reactive: adding, removing, or moving a popup invalidates the host so it recomposes.

Structs§

PopupRegistry
Shared, cheaply-cloneable handle to the popup registry provided by the nearest PopupHost.

Functions§

Popup
Composes content in the top-level overlay layer, positioned at anchor shifted by offset (logical px, window coordinates).
PopupDismissable
A Popup with an outside-tap dismissal: the host renders a viewport-filling scrim beneath the content that calls on_dismiss — the analogue of Compose’s Popup(onDismissRequest = …). Menus and pickers use this; anchored chrome like selection handles uses plain Popup.
PopupDismissableWhen
A dismissable popup whose modal scrim can be disabled without unmounting its visual content. Controls with an exit animation use this to stop intercepting the rest of the UI as soon as dismissal begins while their popup surface finishes animating out.
PopupHost
Installs the top-level overlay layer and composes content beneath it.
local_popup_viewport
The PopupHost’s live measured viewport size (logical px), published on every measure pass through a shared cell. Overlay content (selection menus, the loupe) reads it to clamp itself to the window edges; Size::ZERO means “not measured yet” (or no host) — treat as unclamped.