Remove Drawable and rename State to Program
This commit is contained in:
parent
7f1e7aea07
commit
2539042b71
11 changed files with 202 additions and 304 deletions
22
wgpu/src/widget/canvas/program.rs
Normal file
22
wgpu/src/widget/canvas/program.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
use crate::canvas::{Event, Geometry, Size};
|
||||
|
||||
pub trait Program<Message> {
|
||||
fn update(&mut self, _event: Event, _bounds: Size) -> Option<Message> {
|
||||
None
|
||||
}
|
||||
|
||||
fn draw(&self, bounds: Size) -> Vec<Geometry>;
|
||||
}
|
||||
|
||||
impl<T, Message> Program<Message> for &mut T
|
||||
where
|
||||
T: Program<Message>,
|
||||
{
|
||||
fn update(&mut self, event: Event, bounds: Size) -> Option<Message> {
|
||||
T::update(self, event, bounds)
|
||||
}
|
||||
|
||||
fn draw(&self, bounds: Size) -> Vec<Geometry> {
|
||||
T::draw(self, bounds)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue