pub trait Widget: Send + Sync {
// Provided methods
fn children(&self) -> Children<'_> { ... }
fn layout(&self, ctx: &LayoutCtx<'_>) -> Size { ... }
fn paint(&self, ctx: &mut PaintCtx<'_>) { ... }
fn flex_factor(&self) -> f32 { ... }
fn into_element(self) -> Element
where Self: Sized + 'static { ... }
}Provided Methods§
Sourcefn layout(&self, ctx: &LayoutCtx<'_>) -> Size
fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
Measure under ctx.constraints and return a size within them.
Defaults: leaf → smallest allowed size; One → the child’s size;
Many → stack-like (max of children) — real containers override.
Sourcefn paint(&self, ctx: &mut PaintCtx<'_>)
fn paint(&self, ctx: &mut PaintCtx<'_>)
Record draw commands for ctx.rect.
Defaults: leaf → nothing; One → paint the child in this rect;
Many → stack-like (all children in this rect) — containers that
position children override.
Sourcefn flex_factor(&self) -> f32
fn flex_factor(&self) -> f32
Flex weight inside Row/Column. Wrappers are transparent by default.
Sourcefn into_element(self) -> Elementwhere
Self: Sized + 'static,
fn into_element(self) -> Elementwhere
Self: Sized + 'static,
Wrap this widget in an Element so it can be returned from
Component::build().
Trait Implementations§
Source§impl Widget for Box<dyn Widget>
Box<dyn Widget> is itself a Widget (D093) — builders accepting
impl Widget take boxed children without adapter structs. Fully
transparent delegation: no extra tree node, no behavior change.
impl Widget for Box<dyn Widget>
Box<dyn Widget> is itself a Widget (D093) — builders accepting
impl Widget take boxed children without adapter structs. Fully
transparent delegation: no extra tree node, no behavior change.
Source§fn children(&self) -> Children<'_>
fn children(&self) -> Children<'_>
Source§fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
fn layout(&self, ctx: &LayoutCtx<'_>) -> Size
ctx.constraints and return a size within them. Read moreSource§fn flex_factor(&self) -> f32
fn flex_factor(&self) -> f32
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl Widget for Box<dyn Widget>
Box<dyn Widget> is itself a Widget (D093) — builders accepting
impl Widget take boxed children without adapter structs. Fully
transparent delegation: no extra tree node, no behavior change.
impl Widget for Box<dyn Widget>
Box<dyn Widget> is itself a Widget (D093) — builders accepting
impl Widget take boxed children without adapter structs. Fully
transparent delegation: no extra tree node, no behavior change.