pub trait Widget: Sized + 'static {
type Ret: AsEntity;
type Data: Node;
// Required method
fn on_build(&mut self, state: &mut State, entity: Entity) -> Self::Ret;
// Provided methods
fn widget_name(&self) -> String { ... }
fn build<F>(
self,
state: &mut State,
parent: impl AsEntity,
builder: F,
) -> Self::Ret
where F: FnMut(Builder<'_, Self>) -> Builder<'_, Self>,
Self: Sized + 'static { ... }
fn bind<L, F>(self, lens: L, converter: F) -> Wrapper<L, Self>
where L: Lens,
F: 'static + Fn(&<L as Lens>::Target) -> Self::Data { ... }
fn bind2<L>(self, lens: L) -> LensWrap<L, Self>
where L: Lens { ... }
fn on_update(
&mut self,
state: &mut State,
entity: Entity,
data: &Self::Data,
) { ... }
fn on_event(&mut self, state: &mut State, entity: Entity, event: &mut Event) { ... }
fn on_style(
&mut self,
state: &mut State,
entity: Entity,
property: (String, PropType),
) { ... }
fn on_draw(
&mut self,
state: &mut State,
entity: Entity,
canvas: &mut Canvas<OpenGl>,
) { ... }
}Required Associated Types§
Required Methods§
Provided Methods§
fn widget_name(&self) -> String
Sourcefn build<F>(
self,
state: &mut State,
parent: impl AsEntity,
builder: F,
) -> Self::Ret
fn build<F>( self, state: &mut State, parent: impl AsEntity, builder: F, ) -> Self::Ret
Adds the widget into state and returns the associated type Ret - an entity id or a tuple of entity ids
fn bind<L, F>(self, lens: L, converter: F) -> Wrapper<L, Self>
fn bind2<L>(self, lens: L) -> LensWrap<L, Self>where
L: Lens,
fn on_update(&mut self, state: &mut State, entity: Entity, data: &Self::Data)
fn on_event(&mut self, state: &mut State, entity: Entity, event: &mut Event)
fn on_style( &mut self, state: &mut State, entity: Entity, property: (String, PropType), )
fn on_draw( &mut self, state: &mut State, entity: Entity, canvas: &mut Canvas<OpenGl>, )
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.