Implement composable, type-safe renderer fallback

This commit is contained in:
Héctor Ramón Jiménez 2024-03-21 22:27:17 +01:00
parent 7e4ae8450e
commit 3645d34d6a
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
35 changed files with 1474 additions and 1210 deletions

View file

@ -37,22 +37,15 @@ where
(event::Status::Ignored, None)
}
/// Draws the state of the [`Program`], producing a bunch of [`Geometry`].
///
/// [`Geometry`] can be easily generated with a [`Frame`] or stored in a
/// [`Cache`].
///
/// [`Geometry`]: crate::canvas::Geometry
/// [`Frame`]: crate::canvas::Frame
/// [`Cache`]: crate::canvas::Cache
/// Draws the state of the [`Program`] with the given [`Renderer`].
fn draw(
&self,
state: &Self::State,
renderer: &Renderer,
renderer: &mut Renderer,
theme: &Theme,
bounds: Rectangle,
cursor: mouse::Cursor,
) -> Vec<Renderer::Geometry>;
);
/// Returns the current mouse interaction of the [`Program`].
///
@ -90,12 +83,12 @@ where
fn draw(
&self,
state: &Self::State,
renderer: &Renderer,
renderer: &mut Renderer,
theme: &Theme,
bounds: Rectangle,
cursor: mouse::Cursor,
) -> Vec<Renderer::Geometry> {
T::draw(self, state, renderer, theme, bounds, cursor)
) {
T::draw(self, state, renderer, theme, bounds, cursor);
}
fn mouse_interaction(