Skip to main content

Module align

Module align 

Source
Expand description

Anchor-relative placement math for popups — this framework’s answer to egui’s RectAlign.

A popup attaches to an anchor rectangle (usually the bounds of the widget that opened it). RectAlign names a point on that anchor (parent) and a point on the popup (child); RectAlign::place_child positions the popup so its child point coincides with the anchor’s parent point, then pushes it gap pixels outward.

§Y-up note

Unlike egui (Y-down), this framework is first-quadrant / Y-up: y grows upward and the origin is the bottom-left. Consequently Align::Max on the Y axis is the top edge and Align::Min is the bottom edge. The named presets below (TOP, BOTTOM, …) are expressed so they land on the same visual side a user expects, not the numeric side egui’s constants use.

This module is the one genuinely new primitive the Popup API adds on top of the existing menu system (super::super::menu), which can only anchor a popup left-aligned and extending straight up or down. The placement is a pure function so it is unit-tested directly against production code.

Structs§

Align2
A 2D anchor point within a rectangle (an x and a y Align).
RectAlign
A parent/child anchor pair describing how a popup attaches to its anchoring widget — the placement half of the Popup API (egui’s RectAlign).

Enums§

Align
One-axis alignment: the fraction of an extent an anchor sits at.

Functions§

clamp_rect
Clamp rect inside viewport with a [MARGIN] gutter. If the rect is larger than the viewport it is pinned to the low edge rather than pushed off the high one.