popup-rect ( visible-rect popup-dim screen-dim -- rect )


Vocabulary
math.rectangles.positioning

Inputs
visible-recta rect
popup-dima pair of real numbers
screen-dima pair of real numbers


Outputs
recta rect


Word description
Calculates the position of a popup with a heuristic:
The new rectangle must fit inside screen-dim
The new rectangle must not obscure visible-rect
The child must otherwise be as close as possible to the edges of visible-rect

For example, when displaying a menu, visible-rect is a single point at the mouse location, and when displaying a completion popup, visible-rect contains the bounds of the text element being completed.

Definition