pub trait Widget {
Show 18 methods
// Provided methods
fn event(&mut self, _ctx: &mut EventCtx, _event: &Event) { ... }
fn command(&mut self, _ctx: &mut EventCtx, _command: &Command<'_>) { ... }
fn debug_name(&self) -> &'static str { ... }
fn diagnostics(&self, _ctx: &mut WidgetDiagnosticsCtx) { ... }
fn measure(
&mut self,
_ctx: &mut MeasureCtx,
constraints: Constraints,
) -> Size { ... }
fn intrinsic_size(
&mut self,
ctx: &mut MeasureCtx,
axis: Axis,
available_cross: f32,
) -> IntrinsicSize { ... }
fn arrange(&mut self, _ctx: &mut ArrangeCtx, _bounds: Rect) { ... }
fn paint(&self, _ctx: &mut PaintCtx) { ... }
fn layer_options(&self) -> LayerOptions { ... }
fn layer_properties(&self) -> LayerProperties { ... }
fn stack_host_options(&self) -> Option<StackHostOptions> { ... }
fn stack_surface_options(&self) -> Option<StackSurfaceOptions> { ... }
fn overlay_options(&self) -> Option<OverlayOptions> { ... }
fn semantics(&self, _ctx: &mut SemanticsCtx) { ... }
fn accepts_focus(&self) -> bool { ... }
fn focus_changed(&mut self, _ctx: &mut EventCtx, _focused: bool) { ... }
fn visit_children(&self, _visitor: &mut dyn WidgetPodVisitor) { ... }
fn visit_children_mut(&mut self, _visitor: &mut dyn WidgetPodMutVisitor) { ... }
}Provided Methods§
fn event(&mut self, _ctx: &mut EventCtx, _event: &Event)
Sourcefn command(&mut self, _ctx: &mut EventCtx, _command: &Command<'_>)
fn command(&mut self, _ctx: &mut EventCtx, _command: &Command<'_>)
Receive a typed command addressed directly to this widget. Commands are target-only and do not capture or bubble through the widget tree.
fn debug_name(&self) -> &'static str
Sourcefn diagnostics(&self, _ctx: &mut WidgetDiagnosticsCtx)
fn diagnostics(&self, _ctx: &mut WidgetDiagnosticsCtx)
Publish widget-specific state for an inspector snapshot.
The runtime only calls this while explicitly capturing a snapshot, so normal event, layout, and paint passes pay no cost for this hook.
fn measure(&mut self, _ctx: &mut MeasureCtx, constraints: Constraints) -> Size
Sourcefn intrinsic_size(
&mut self,
ctx: &mut MeasureCtx,
axis: Axis,
available_cross: f32,
) -> IntrinsicSize
fn intrinsic_size( &mut self, ctx: &mut MeasureCtx, axis: Axis, available_cross: f32, ) -> IntrinsicSize
Report the smallest and preferred extent along one axis.
The conservative default treats the ordinary natural measurement as unbreakable. Text and other shrinkable widgets can override this to expose a smaller minimum without changing the normal measure contract.
fn arrange(&mut self, _ctx: &mut ArrangeCtx, _bounds: Rect)
fn paint(&self, _ctx: &mut PaintCtx)
fn layer_options(&self) -> LayerOptions
fn layer_properties(&self) -> LayerProperties
fn stack_host_options(&self) -> Option<StackHostOptions>
fn stack_surface_options(&self) -> Option<StackSurfaceOptions>
Sourcefn overlay_options(&self) -> Option<OverlayOptions>
fn overlay_options(&self) -> Option<OverlayOptions>
Describe this widget as the logical owner of a presented overlay.
The overlay’s rendered surfaces may be retained descendants. Returning options here lets the window runtime coordinate nesting, focus, dismissal, modality, and diagnostics independently of paint ownership.
fn semantics(&self, _ctx: &mut SemanticsCtx)
fn accepts_focus(&self) -> bool
fn focus_changed(&mut self, _ctx: &mut EventCtx, _focused: bool)
Sourcefn visit_children(&self, _visitor: &mut dyn WidgetPodVisitor)
fn visit_children(&self, _visitor: &mut dyn WidgetPodVisitor)
Visit this widget’s logical children.
The children do not need to correspond to every piece of state or every visual element a widget owns internally. A widget may expose retained local children, generated/virtual children, remote children represented by local pods, or only the subset that should cooperate with the SUI runtime for this pass.
Sourcefn visit_children_mut(&mut self, _visitor: &mut dyn WidgetPodMutVisitor)
fn visit_children_mut(&mut self, _visitor: &mut dyn WidgetPodMutVisitor)
Mutably visit this widget’s logical children.
This is the mutable counterpart to Widget::visit_children; SUI uses
it as a cooperation point for the retained runtime, not as ownership of
a widget’s complete internal model.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".