pub struct ReserveLayout;Expand description
Reserve at least the size of a sample child, then lay the content out inside it.
The problem it solves: a numeric readout beside a slider changes width as the value changes
(1 is narrower than 8 in a proportional font, and 9 → 10 adds a whole glyph), so the
row reflows on every drag and the control you are aiming at moves. A hardcoded width “fixes”
that until the reader raises their accessibility text size, at which point the number is
clipped.
Reserving a sample measures a real piece in the real font at the real size, so the reservation
scales with the text exactly as the content does. children[0] is the sample (built
transparent by Decorate::reserving, so it never paints and is placed at zero size);
children[1] is the content, which receives the full reserved bounds and aligns itself.
Trait Implementations§
Source§impl Layout for ReserveLayout
impl Layout for ReserveLayout
fn measure( &self, cx: &mut dyn LayoutOps, children: &[RNode], p: Proposal, ) -> Size
fn place(&self, cx: &mut dyn LayoutOps, children: &[RNode], bounds: Rect)
Source§fn baseline(
&self,
_cx: &mut dyn LayoutOps,
_children: &[RNode],
_size: Size,
) -> Option<f64>
fn baseline( &self, _cx: &mut dyn LayoutOps, _children: &[RNode], _size: Size, ) -> Option<f64>
size (docs/baseline.md). None (the default) means the node has no baseline to
offer, so a baseline-aligned parent falls back to box alignment for it. Read moreAuto Trait Implementations§
impl Freeze for ReserveLayout
impl RefUnwindSafe for ReserveLayout
impl Send for ReserveLayout
impl Sync for ReserveLayout
impl Unpin for ReserveLayout
impl UnsafeUnpin for ReserveLayout
impl UnwindSafe for ReserveLayout
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more