widgetkit_runtime/
widget.rs1use crate::{context::{DisposeCtx, MountCtx, RenderCtx, StartCtx, StopCtx, UpdateCtx}, event::Event};
2use widgetkit_render::Canvas;
3
4pub trait Widget: Send + Sized + 'static {
5 type State;
6 type Message: Send + 'static;
7
8 fn mount(&mut self, ctx: &mut MountCtx<Self>) -> Self::State;
9
10 fn start(&mut self, _state: &mut Self::State, _ctx: &mut StartCtx<Self>) {}
11
12 fn update(&mut self, _state: &mut Self::State, _event: Event<Self::Message>, _ctx: &mut UpdateCtx<Self>) {}
13
14 fn render(&self, _state: &Self::State, _canvas: &mut Canvas, _ctx: &RenderCtx<Self>) {}
15
16 fn stop(&mut self, _state: &mut Self::State, _ctx: &mut StopCtx<Self>) {}
17
18 fn dispose(&mut self, _state: Self::State, _ctx: &mut DisposeCtx<Self>) {}
19}