Portals 0.7.0 · dev0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::Control Class Reference
UI-owned one-line control with owning Unicode text and local paint coordinates. Mutate through the free setters between frames. The frame owner translates local commands and intersects their clips with NodeGeometry, then renders before leaving tree.frame. Focus/enabled flags are presentation snapshots only; EventRouter owns input eligibility.
More...
Copy focus and ancestor eligibility on UI between frames; changes invalidate paint.
Detailed Description
UI-owned one-line control with owning Unicode text and local paint coordinates. Mutate through the free setters between frames. The frame owner translates local commands and intersects their clips with NodeGeometry, then renders before leaving tree.frame. Focus/enabled flags are presentation snapshots only; EventRouter owns input eligibility.
Own text/options and create fixed ASCII decorations under the text's validated width policy.
Parameters
text
Validated owning text, transferred into the control with its complete WidthPolicy.
prefix
Borrowed leading ASCII decoration, copied during construction; "[ ] " enables alternate same-width "[x] " and "[-] " decorations for checkbox presentation.
suffix
Borrowed trailing ASCII decoration, copied during construction.
style
Owning normal/focused/disabled paint values.
policy
Owning layout size policy, subsequently validated by the layout owner.
Exceptions
std::bad_alloc
If text transfer or decoration storage cannot allocate.
std::bad_expected_access<TextError>
If a supplied decoration cannot be validated within text limits.
Note
Construct on UI through tree.emplace, which translates allocation failure to NO_MEMORY and other constructor exceptions to CALLBACK_FAILED. Argument construction precedes that boundary.
Submit local fill/text commands from the synchronized presentation snapshot.
Parameters
context
Borrowed synchronous sink; command storage is valid during submit only. Text belongs to this control and may be borrowed by a retained command until the enclosing tree.frame returns.
Returns
Success, intrinsic-measurement INVALID_GEOMETRY, or the sink's unchanged TreeError.
Note
The frame owner translates local geometry, intersects the ancestor clip and renders before leaving tree.frame. No context/text reference escapes that frame; paint performs no model reads.
Exceptions
std::bad_alloc
If the sink cannot allocate. Other sink exceptions also propagate; WidgetTree::paint translates escaped exceptions to CALLBACK_FAILED.
Replace owning text between frames; equal bytes/policy are a no-op, changes invalidate layout.
Parameters
tree
Borrowed UI owner containing node; used only during this call.
node
Observing handle to the control whose text is replaced.
text
Validated owning replacement, transferred only after decorations are prepared and invalidation succeeds.
Returns
Success, internal NO_MEMORY, or the tree's WRONG_THREAD, WRONG_SESSION, STALE_NODE, closed, WOULD_BLOCK (active frame), CALLBACK_FAILED or invalidation error. Failure retains the previous text.
Exceptions
std::bad_alloc
If construction of the by-value argument fails before this function begins; allocation inside the mutation boundary is returned as NO_MEMORY instead. Numeric-only Slider views reject caption mutation with INVALID_ARGUMENT, including through a base node.
Copy focus and ancestor eligibility on UI between frames; changes invalidate paint.
Parameters
tree
Borrowed UI owner containing node; also supplies ancestor eligibility.
node
Observing control handle receiving the presentation snapshot.
focused
Observing snapshot obtained once from EventRouter::focused before synchronizing the controls; an empty handle means no focused control. This identity is compared, not dereferenced or made authoritative.
Returns
Success or the tree's WRONG_THREAD, WRONG_SESSION, STALE_NODE, closed, WOULD_BLOCK (active frame), CALLBACK_FAILED or invalidation error. Equal presentation flags do not invalidate.
Note
No focus recovery, registration or routing is performed; never call router.focused from paint.
The documentation for this class was generated from the following file: