pub trait Widget {
Show 13 methods
// Provided methods
fn style(&self) -> Style { ... }
fn children(&self) -> &[Element] { ... }
fn expand(&self, _cx: &mut BuildCx<'_>) { ... }
fn layer(&self) -> Option<Layer> { ... }
fn inert(&self) -> bool { ... }
fn focus(&self) -> Option<Focus> { ... }
fn provide(&self) -> Option<&dyn Any> { ... }
fn measure(
&self,
_known: Size<Option<f32>>,
_available: Size<AvailableSpace>,
_text: &Text,
) -> Size<f32> { ... }
fn measure_key(&self) -> u64 { ... }
fn scroll(
&self,
_state: &mut State,
_at: Placement,
_now: Instant,
) -> Option<(f32, f32)> { ... }
fn clips(&self) -> bool { ... }
fn paint(&self, _cx: &mut PaintCx<'_>) { ... }
fn event(&self, _ev: &Event, _cx: &mut EventCx<'_>) { ... }
}Expand description
Primitive building block. Composite widgets are plain functions returning
Element; implement this only for new layout/paint/input behavior.
Provided Methods§
fn style(&self) -> Style
fn children(&self) -> &[Element]
Sourcefn expand(&self, _cx: &mut BuildCx<'_>)
fn expand(&self, _cx: &mut BuildCx<'_>)
Runs before children with this node’s id, state slot and providers;
lets a widget build its subtree from framework-owned state.
Sourcefn layer(&self) -> Option<Layer>
fn layer(&self) -> Option<Layer>
Takes this subtree out of the layout flow: it covers Layer’s box,
isn’t clipped by ancestors, paints above and gets input before the
rest of the tree.
Sourcefn focus(&self) -> Option<Focus>
fn focus(&self) -> Option<Focus>
Lets Tab move keyboard focus here. The focused widget gets keys first
and handles Enter, Space or arrows when EventCx::focused.
Sourcefn provide(&self) -> Option<&dyn Any>
fn provide(&self) -> Option<&dyn Any>
Value made available to descendants through Scope::get.
Sourcefn measure(
&self,
_known: Size<Option<f32>>,
_available: Size<AvailableSpace>,
_text: &Text,
) -> Size<f32>
fn measure( &self, _known: Size<Option<f32>>, _available: Size<AvailableSpace>, _text: &Text, ) -> Size<f32>
Intrinsic size of a leaf (children-less) widget.
Sourcefn measure_key(&self) -> u64
fn measure_key(&self) -> u64
Hash of everything measure reads besides its arguments. Layout is
kept across rebuilds and a leaf is only re-measured when this changes,
so widgets whose size depends on their data must override it.
Sourcefn scroll(
&self,
_state: &mut State,
_at: Placement,
_now: Instant,
) -> Option<(f32, f32)>
fn scroll( &self, _state: &mut State, _at: Placement, _now: Instant, ) -> Option<(f32, f32)>
Children are clipped to at.clip and shifted by the returned offset,
as of frame time now.
fn paint(&self, _cx: &mut PaintCx<'_>)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".