Trait gui::Widget

source ·
pub trait Widget<E, M>: Handleable<E, M> + Renderable + Object + Debug {
    // Required method
    fn type_id(&self) -> TypeId;

    // Provided methods
    fn data<'c, D>(&self, cap: &'c dyn Cap) -> &'c D
       where Self: Sized,
             D: 'static { ... }
    fn data_mut<'c, D>(&self, cap: &'c mut dyn MutCap<E, M>) -> &'c mut D
       where Self: Sized,
             D: 'static { ... }
}
Expand description

A widget as used by a Ui.

In addition to taking care of Id management and parent-child relationships, the Ui is responsible for dispatching events to widgets and rendering them. Hence, a widget usable for the Ui needs to implement Handleable, Renderable, and Object.

Required Methods§

source

fn type_id(&self) -> TypeId

Get the TypeId of self.

Provided Methods§

source

fn data<'c, D>(&self, cap: &'c dyn Cap) -> &'c D
where Self: Sized, D: 'static,

Retrieve a reference to a widget’s data.

§Panics

This function will panic if the data associated with the object is not of type D.

source

fn data_mut<'c, D>(&self, cap: &'c mut dyn MutCap<E, M>) -> &'c mut D
where Self: Sized, D: 'static,

Retrieve a mutable reference to a widget’s data.

§Panics

This function will panic if the data associated with the object is not of type D.

Implementations§

source§

impl<E, M> dyn Widget<E, M>
where E: 'static, M: 'static,

source

pub fn is<T: Widget<E, M>>(&self) -> bool

Check if the widget is of type T.

source

pub fn downcast_ref<T: Widget<E, M>>(&self) -> Option<&T>

Downcast the widget reference to type T.

source

pub fn downcast_mut<T: Widget<E, M>>(&mut self) -> Option<&mut T>

Downcast the widget reference to type T.

Implementors§