Skip to main content

LayoutCtx

Struct LayoutCtx 

Source
#[non_exhaustive]
pub struct LayoutCtx<'a> { pub container: Rect, pub children: &'a [El], pub measure: &'a dyn Fn(&El) -> (f32, f32), pub rect_of_key: &'a dyn Fn(&str) -> Option<Rect>, pub rect_of_id: &'a dyn Fn(&str) -> Option<Rect>, }
Expand description

Context handed to a LayoutFn. Marked #[non_exhaustive] so future fields (intrinsic-at-width, scroll context, …) can be added without breaking author code that currently reads container / children / measure.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§container: Rect

Inner rect of the parent (after padding) — the area available for child placement. Children may be positioned anywhere; the library does not clamp returned rects to this region.

§children: &'a [El]

Direct children of the node, in source order. Read-only — return positions through your Vec<Rect>.

§measure: &'a dyn Fn(&El) -> (f32, f32)

Intrinsic (width, height) for any child. Wrapped text returns its unwrapped width here; if you need width-dependent wrapping you’ll need to size the child with Fixed / Fill instead.

§rect_of_key: &'a dyn Fn(&str) -> Option<Rect>

Look up any keyed node’s laid-out rect. Returns None when the key is absent from the tree, when the node hasn’t been laid out yet (siblings later in source order), or when the key was used on a node without a recorded rect. Used by widgets like crate::widgets::popover::popover to position children relative to elements outside their own subtree.

§rect_of_id: &'a dyn Fn(&str) -> Option<Rect>

Look up a node’s laid-out rect by its computed_id. Same semantics as Self::rect_of_key but skips the key → computed_id translation — useful for runtime-synthesized layers (tooltips, focus rings) that anchor to a node the library already knows by id.

Auto Trait Implementations§

§

impl<'a> Freeze for LayoutCtx<'a>

§

impl<'a> !RefUnwindSafe for LayoutCtx<'a>

§

impl<'a> !Send for LayoutCtx<'a>

§

impl<'a> !Sync for LayoutCtx<'a>

§

impl<'a> Unpin for LayoutCtx<'a>

§

impl<'a> UnsafeUnpin for LayoutCtx<'a>

§

impl<'a> !UnwindSafe for LayoutCtx<'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> 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, 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.