pub struct WidgetPod { /* private fields */ }Expand description
A retained widget plus its layout results and dirty state: where it was placed
(origin), how big it is (size), and which passes are pending (flags).
Implementations§
Source§impl WidgetPod
impl WidgetPod
Sourcepub const ERASED_TYPE_NAME: &'static str = "<erased dyn Widget>"
pub const ERASED_TYPE_NAME: &'static str = "<erased dyn Widget>"
The type_name recorded for a pod built from an already type-erased widget.
Sourcepub fn new(id: WidgetId, widget: Box<dyn Widget>) -> Self
pub fn new(id: WidgetId, widget: Box<dyn Widget>) -> Self
Wrap a freshly built, already type-erased widget; it starts dirty for layout
and paint. type_name reports
ERASED_TYPE_NAME; prefer WidgetPod::new_typed
where the concrete type is in scope.
Sourcepub fn new_typed<W: Widget>(id: WidgetId, widget: W) -> Self
pub fn new_typed<W: Widget>(id: WidgetId, widget: W) -> Self
Wrap a freshly built widget whose concrete type is in scope, recording its
core::any::type_name.
Pass the widget itself, never a Box<dyn Widget>: the blanket
Widget for Box<dyn Widget> impl would compile but record the box’s type name
and double-box the widget, breaking the downcast to the view’s element type.
Sourcepub fn type_name(&self) -> &'static str
pub fn type_name(&self) -> &'static str
The concrete widget type’s name, or ERASED_TYPE_NAME.
Recorded at construction, sound because a root pod’s element type is fixed by
RenderRoot<State, V>; a swappable ChildPod asks the live widget
(Widget::type_name). Diagnostic only: never parse or match on it.
Sourcepub fn debug_label(&self) -> Option<&str>
pub fn debug_label(&self) -> Option<&str>
The human name attached for tooling, if any. None by default.
Sourcepub fn set_debug_label(&mut self, label: impl Into<Cow<'static, str>>)
pub fn set_debug_label(&mut self, label: impl Into<Cow<'static, str>>)
Attach a human name for tooling; nothing in build/layout/paint reads it.
Sourcepub fn clear_debug_label(&mut self)
pub fn clear_debug_label(&mut self)
Drop any attached debug label.
Sourcepub fn widget_mut(&mut self) -> &mut dyn Widget
pub fn widget_mut(&mut self) -> &mut dyn Widget
Mutable access to the boxed widget.
Sourcepub fn set_layout(&mut self, origin: Point, size: Size)
pub fn set_layout(&mut self, origin: Point, size: Size)
Record the geometry produced by a layout pass.
Sourcepub fn flags(&self) -> ChangeFlags
pub fn flags(&self) -> ChangeFlags
The pending pass flags for this pod.
Sourcepub fn merge_flags(&mut self, flags: ChangeFlags)
pub fn merge_flags(&mut self, flags: ChangeFlags)
Merge additional pending flags (e.g. from a rebuild).
Sourcepub fn clear_flags(&mut self)
pub fn clear_flags(&mut self)
Clear all pending flags (after the corresponding passes have run).