Skip to main content

BuildCx

Struct BuildCx 

Source
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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn theme(&self) -> &Theme

The active runtime theme for this frame.

Source

pub fn palette(&self) -> &Palette

Shorthand for self.theme().palette().

Source

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.

Source

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§

Source§

impl<'a> Clone for BuildCx<'a>

Source§

fn clone(&self) -> BuildCx<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for BuildCx<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.