Skip to main content

WidgetPod

Struct WidgetPod 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn id(&self) -> WidgetId

This pod’s stable identity.

Source

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.

Source

pub fn debug_label(&self) -> Option<&str>

The human name attached for tooling, if any. None by default.

Source

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.

Source

pub fn clear_debug_label(&mut self)

Drop any attached debug label.

Source

pub fn widget(&self) -> &dyn Widget

Shared access to the boxed widget.

Source

pub fn widget_mut(&mut self) -> &mut dyn Widget

Mutable access to the boxed widget.

Source

pub fn origin(&self) -> Point

The widget’s origin in its parent’s coordinate space.

Source

pub fn size(&self) -> Size

The widget’s resolved size (valid after a layout pass).

Source

pub fn set_layout(&mut self, origin: Point, size: Size)

Record the geometry produced by a layout pass.

Source

pub fn flags(&self) -> ChangeFlags

The pending pass flags for this pod.

Source

pub fn merge_flags(&mut self, flags: ChangeFlags)

Merge additional pending flags (e.g. from a rebuild).

Source

pub fn clear_flags(&mut self)

Clear all pending flags (after the corresponding passes have run).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.