pub struct LayoutBuilder<S>where
S: AppState,{
pub id: Option<WidgetNodeId>,
pub flex_grow: f32,
pub flex_shrink: f32,
/* private fields */
}Expand description
A closure-based widget that receives its parent’s BoxConstraints.
LayoutBuilder is the layout-aware counterpart of Builder. The closure
receives the constraints from the previous frame (or a fallback derived
from the viewport) so it can adapt its output to the available space.
§Example
ⓘ
let widget = LayoutBuilder::new(|ctx, view, constraints| {
let cols = if constraints.max_width > 600.0 { 3 } else { 1 };
build_grid(ctx, view, cols)
})
.flex_grow(1.0);Fields§
§id: Option<WidgetNodeId>Optional stable identity for constraint look-up across frames.
flex_grow: f32Flex grow factor.
flex_shrink: f32Flex shrink factor.
Implementations§
Source§impl<S> LayoutBuilder<S>where
S: AppState,
impl<S> LayoutBuilder<S>where
S: AppState,
pub fn new<F>(builder: F) -> LayoutBuilder<S>
pub fn id(self, id: WidgetNodeId) -> LayoutBuilder<S>
pub fn flex_grow(self, grow: f32) -> LayoutBuilder<S>
pub fn flex_shrink(self, shrink: f32) -> LayoutBuilder<S>
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for LayoutBuilder<S>
impl<S> !RefUnwindSafe for LayoutBuilder<S>
impl<S> Send for LayoutBuilder<S>
impl<S> Sync for LayoutBuilder<S>
impl<S> Unpin for LayoutBuilder<S>
impl<S> UnsafeUnpin for LayoutBuilder<S>
impl<S> !UnwindSafe for LayoutBuilder<S>
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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