#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.container: RectInner 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> 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<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.