pub trait Program<Message, Theme = Theme, 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,
) -> (Status, Option<Message>) { ... }
fn mouse_interaction(
&self,
_state: &Self::State,
_bounds: Rectangle,
_cursor: Cursor,
) -> Interaction { ... }
}
Expand description
The state and logic of a Canvas
.
A Program
can mutate internal state and produce messages for an
application.
The internal state mutated by the Program
.
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 a Message
to notify an application
of any meaningful interactions.
By default, this method does and returns nothing.
Returns the current mouse interaction of the Program
.
The interaction returned will be in effect even if the cursor position
is out of bounds of the program’s Canvas
.