Remove Layer trait and simplify Canvas
This commit is contained in:
parent
bb424e54c5
commit
592cc68506
9 changed files with 181 additions and 174 deletions
20
wgpu/src/widget/canvas/state.rs
Normal file
20
wgpu/src/widget/canvas/state.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use crate::canvas::{Event, Geometry, Size};
|
||||
|
||||
pub trait State {
|
||||
fn update(&mut self, _event: Event, _bounds: Size) {}
|
||||
|
||||
fn draw(&self, bounds: Size) -> Vec<Geometry>;
|
||||
}
|
||||
|
||||
impl<T> State for &mut T
|
||||
where
|
||||
T: State,
|
||||
{
|
||||
fn update(&mut self, event: Event, bounds: Size) {
|
||||
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