pub struct WidgetPod { /* private fields */ }Expand description
A retained widget plus its layout results and dirty state.
The “pod” wraps the boxed widget with the bookkeeping the framework owns:
where the widget 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, where the concrete type is no longer nameable.
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.
The concrete type is gone by the time the box arrives, so
type_name reports
ERASED_TYPE_NAME. Prefer
WidgetPod::new_typed where the concrete type is still 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 still in scope,
recording its core::any::type_name for introspection.
Pass the widget itself, never an already-boxed Box<dyn Widget>: the
blanket Widget for Box<dyn Widget> impl would make that compile while
recording the box’s own type name and double-boxing the widget (which
breaks the downcast back to the originating view’s element type). Use
WidgetPod::new for the erased case.
Sourcepub fn type_name(&self) -> &'static str
pub fn type_name(&self) -> &'static str
The concrete widget type’s name, or
ERASED_TYPE_NAME when the pod was built
from an already-erased box.
Recorded at construction, which is sound here because a root pod’s
element type is fixed by RenderRoot<State, V>’s V and cannot swap
under it. A ChildPod, whose widget can be swapped by a rebuild,
asks the live widget instead (Widget::type_name).
Diagnostic only: type_name’s output is not a stable contract across
compiler versions, so 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 (an inspector shows it beside the type name). Purely descriptive — nothing in the build/layout/paint path 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).