simvx.core.ui.overlay¶
The tree-owned overlay layer: an ordered registry of on-top UI overlays.
One :class:OverlayLayer per :class:SceneTree (tree.overlays) is the single
source of truth for “what is on top, in what order, and what it captures”. It
replaces the wrong render-iff-self-is-on-the-modal-stack coupling: layering is
registry insertion order, input scope is derived from the topmost capturing
entry, and background inertness is derived from any inert entry.
This module lives in core and never imports simvx.graphics at module
level. The single collector :func:iter_overlay_draws is consumed identically by
both the immediate :meth:SceneTree.render path and the retained item pipeline,
so desktop == web and headless == live hold by construction.
Module Contents¶
Classes¶
One registered overlay (design §3). Frozen: the registry holds entries by value. |
|
An ordered registry of open overlays owned by one :class: |
Functions¶
Yield |
Data¶
API¶
- simvx.core.ui.overlay.__all__¶
[‘OverlayEntry’, ‘OverlayLayer’, ‘iter_overlay_draws’, ‘DEFAULT_SCRIM_COLOUR’]
- simvx.core.ui.overlay.DEFAULT_SCRIM_COLOUR: tuple[float, float, float, float]¶
(0.0, 0.0, 0.0, 0.5)
- class simvx.core.ui.overlay.OverlayEntry[source]¶
One registered overlay (design §3). Frozen: the registry holds entries by value.
modalityis the preset string; the derived per-entry booleans arecapture_input/dim/inert/dismiss_on_outside_click.owneris the logical chain owner (theMenuBarfor a dropdown/submenu chain, else the control itself) and drives whole-chain dismissal.viewportis the owning render target (None= the main viewport).dim_colouris resolved from the theme at :meth:OverlayLayer.openso the collector needs no theme lookup.prev_focusis the focus snapshot restored on close. Draw and input order are the registry’s list (insertion) order, so there is no seq field.- control: Any¶
None
- modality: str¶
None
- capture_input: bool¶
None
- dim: bool¶
None
- inert: bool¶
None
- dismiss_on_outside_click: bool¶
None
- dim_colour: tuple[float, float, float, float]¶
None
- owner: Any¶
None
- viewport: Any¶
None
- prev_focus: Any¶
None
- static expand_preset(modality: str, *, dim: bool | None = None, dismiss: bool | None = None, inert: bool | None = None) tuple[bool, bool, bool, bool][source]¶
Resolve
modalityto(capture_input, dim, dismiss, inert).dim/dismiss/inert(None= take the preset default) override individual flags.capture_inputis preset-only.
- class simvx.core.ui.overlay.OverlayLayer(tree: Any)[source]¶
An ordered registry of open overlays owned by one :class:
SceneTree.Insertion order == draw order == open-chain order. Empty registry is an O(1) truthiness check (the zero-cost gate on every hot path).
Initialization
- __slots__¶
(‘_tree’, ‘_entries’)
- open(control: Any, entry: simvx.core.ui.overlay.OverlayEntry) None[source]¶
Register
entryforcontrolon top of the stack.Snapshots prior focus and focuses the first focusable descendant when the entry is capturing. Bumps
tree._structure_version(a registry mutation is a structural change) and emitstree.overlay_opened.
- close(control: Any) None[source]¶
Pop
controland every entry above it sharing its owner (the chain).controlis ALWAYS popped; entries above it that share its owner are popped too (whole-chain dismissal), while interleaved entries of OTHER owners (e.g. anonetooltip sitting between a dropdown and its submenu) are left in place. Restoresprev_focusper popped entry (LIFO, top-down) iff the prior-focus control is still in this tree, else clears focus. Bumpstree._structure_versionand emitstree.overlay_closedper popped control. Idempotent.
- chain_base(owner: Any) Any | None[source]¶
Return the lowest (earliest-opened) overlay control whose owner is
owner.Closing the base pops the whole owner chain (LIFO), so this is the handle for whole-chain dismissal (an outside click / Escape on a menu chain closes the bar + popup + submenu in one action).
- topmost_capturing() Any | None[source]¶
Return the topmost capturing overlay control, skipping
capture=none.
- any_inert() bool[source]¶
True if any open overlay is inert (drives tree pause). Short-circuits empty.
- entry_of(control: Any) simvx.core.ui.overlay.OverlayEntry | None[source]¶
Return the open entry for
control, orNone.
- simvx.core.ui.overlay.iter_overlay_draws(tree: Any, *, viewport: Any = None) collections.abc.Iterator[tuple[str, Any, simvx.core.ui.overlay.OverlayEntry]][source]¶
Yield
(kind, control, entry)overlay draws forviewportin open order.kindis"dim"(a full-screen scrim drawn behind the overlay) then"overlay"(the overlay control’s subtree). Filtered to entries whoseentry.viewport is viewport(None= the main viewport). The generator is only entered inside anif tree.overlaysguard, so it is allocation-free and O(1) when unused.