summaryrefslogtreecommitdiffstats
path: root/wgpu/src/widget/canvas/state.rs
diff options
context:
space:
mode:
Diffstat (limited to 'wgpu/src/widget/canvas/state.rs')
-rw-r--r--wgpu/src/widget/canvas/state.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/wgpu/src/widget/canvas/state.rs b/wgpu/src/widget/canvas/state.rs
new file mode 100644
index 00000000..8388f94d
--- /dev/null
+++ b/wgpu/src/widget/canvas/state.rs
@@ -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)
+ }
+}