pub struct BuildCx<'a> { /* private fields */ }Expand description
Per-frame, read-only context for App::build.
The runner snapshots the app’s crate::Theme before calling
build and exposes it through cx.theme() / cx.palette() so app
code can branch on the active palette (a custom widget that picks
between two non-token colors based on dark vs. light, for instance).
BuildCx is the explicit handle for this — token references inside
widgets resolve through the palette automatically and don’t need it.
Future fields like viewport metrics or frame phase will live here so
the API stays additive: adding a new accessor on BuildCx doesn’t
break apps that ignore the context.
Implementations§
Source§impl<'a> BuildCx<'a>
impl<'a> BuildCx<'a>
Sourcepub fn new(theme: &'a Theme) -> Self
pub fn new(theme: &'a Theme) -> Self
Construct a BuildCx borrowing the supplied theme. Hosts call
this once per frame after App::theme and before App::build.
Hosts that own a crate::state::UiState should chain
Self::with_ui_state so the app can read interaction state
(hover) during build via Self::hovered_key /
Self::is_hovering_within.
Sourcepub fn with_ui_state(self, ui_state: &'a UiState) -> Self
pub fn with_ui_state(self, ui_state: &'a UiState) -> Self
Attach the runtime’s crate::state::UiState so build-time
accessors (hovered_key, is_hovering_within) can answer.
When omitted, those accessors return None / false — useful
for headless rendering paths that don’t track interaction
state.
Sourcepub fn with_diagnostics(self, diagnostics: &'a HostDiagnostics) -> Self
pub fn with_diagnostics(self, diagnostics: &'a HostDiagnostics) -> Self
Attach a HostDiagnostics snapshot for this frame. Hosts call
this when they want apps to surface debug overlays (e.g. the
showcase status block); apps that don’t read diagnostics()
pay nothing for it. Headless render paths leave it None.
Sourcepub fn diagnostics(&self) -> Option<&HostDiagnostics>
pub fn diagnostics(&self) -> Option<&HostDiagnostics>
Per-frame diagnostic snapshot from the host (backend, frame
cadence, trigger reason, etc.), or None when the host did
not attach one. Apps display this in optional debug overlays.
Sourcepub fn hovered_key(&self) -> Option<&str>
pub fn hovered_key(&self) -> Option<&str>
Key of the leaf node currently under the pointer, or None
when nothing is hovered or this BuildCx was built without a
UiState (headless rendering paths).
Use for branching the build output on hover state without
mirroring it via App::on_event handlers — e.g., a sidebar
row that previews details in a side pane based on what’s
currently hovered.
For region-aware queries (parent stays “hot” while a child is
hovered), prefer Self::is_hovering_within.
Sourcepub fn is_hovering_within(&self, key: &str) -> bool
pub fn is_hovering_within(&self, key: &str) -> bool
True iff key’s node — or any descendant of it — is the
current hover target. Subtree-aware, matching the semantics of
crate::tree::El::hover_alpha. Returns false when this
BuildCx has no attached UiState or when key isn’t in the
current tree.
Reads the underlying tracker, not the eased subtree envelope — the boolean flips immediately on hit-test identity change.
Trait Implementations§
impl<'a> Copy for BuildCx<'a>
Auto Trait Implementations§
impl<'a> Freeze for BuildCx<'a>
impl<'a> !RefUnwindSafe for BuildCx<'a>
impl<'a> Send for BuildCx<'a>
impl<'a> Sync for BuildCx<'a>
impl<'a> Unpin for BuildCx<'a>
impl<'a> UnsafeUnpin for BuildCx<'a>
impl<'a> !UnwindSafe for BuildCx<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.