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: where it 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.

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. type_name reports ERASED_TYPE_NAME; prefer WidgetPod::new_typed where the concrete type is in scope.

Source

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.

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.

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.

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; nothing in build/layout/paint 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.