pub trait Program<Message, Theme = Theme, Renderer = Renderer<Renderer, Renderer>>where
Renderer: Renderer,{
type State: Default + 'static;
// Required method
fn draw(
&self,
state: &Self::State,
renderer: &Renderer,
theme: &Theme,
bounds: Rectangle,
cursor: Cursor,
) -> Vec<<Renderer as Renderer>::Geometry>;
// Provided methods
fn update(
&self,
_state: &mut Self::State,
_event: Event,
_bounds: Rectangle,
_cursor: Cursor,
) -> Option<Action<Message>> { ... }
fn mouse_interaction(
&self,
_state: &Self::State,
_bounds: Rectangle,
_cursor: Cursor,
) -> Interaction { ... }
}
Available on crate feature
canvas
only.Expand description
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn update(
&self,
_state: &mut Self::State,
_event: Event,
_bounds: Rectangle,
_cursor: Cursor,
) -> Option<Action<Message>>
fn update( &self, _state: &mut Self::State, _event: Event, _bounds: Rectangle, _cursor: Cursor, ) -> Option<Action<Message>>
Updates the State
of the Program
.
When a Program
is used in a Canvas
, the runtime will call this
method for each Event
.
This method can optionally return an Action
to either notify an
application of any meaningful interactions, capture the event, or
request a redraw.
By default, this method does and returns nothing.