pub struct AspectRatioLayout {
pub ratio: f64,
}Expand description
The aspect_ratio decorator (§5.2): the largest width / height == ratio box that fits what
the parent proposes, with the child given that whole box.
With one axis proposed it derives the other, which is what makes .grow_w().aspect_ratio(r)
take the width a container offers and compute the height from it: a canvas that keeps its
proportions as the window resizes.
Fields§
§ratio: f64Trait Implementations§
Source§impl Layout for AspectRatioLayout
impl Layout for AspectRatioLayout
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>
Where this node’s own first text baseline falls, measured from the top of a box of
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 AspectRatioLayout
impl RefUnwindSafe for AspectRatioLayout
impl Send for AspectRatioLayout
impl Sync for AspectRatioLayout
impl Unpin for AspectRatioLayout
impl UnsafeUnpin for AspectRatioLayout
impl UnwindSafe for AspectRatioLayout
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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