From 05af8d00d4c0f7b8e0ece85224fd90a92da86da8 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 19 May 2020 17:15:44 +0200 Subject: Draft new `iced_graphics` crate :tada: --- wgpu/src/widget/canvas/program.rs | 85 --------------------------------------- 1 file changed, 85 deletions(-) delete mode 100644 wgpu/src/widget/canvas/program.rs (limited to 'wgpu/src/widget/canvas/program.rs') diff --git a/wgpu/src/widget/canvas/program.rs b/wgpu/src/widget/canvas/program.rs deleted file mode 100644 index 725d9d72..00000000 --- a/wgpu/src/widget/canvas/program.rs +++ /dev/null @@ -1,85 +0,0 @@ -use crate::canvas::{Cursor, Event, Geometry}; -use iced_native::{mouse, Rectangle}; - -/// The state and logic of a [`Canvas`]. -/// -/// A [`Program`] can mutate internal state and produce messages for an -/// application. -/// -/// [`Canvas`]: struct.Canvas.html -/// [`Program`]: trait.Program.html -pub trait 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. - /// - /// [`Program`]: trait.Program.html - /// [`Canvas`]: struct.Canvas.html - /// [`Event`]: enum.Event.html - fn update( - &mut self, - _event: Event, - _bounds: Rectangle, - _cursor: Cursor, - ) -> Option { - 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`]. - /// - /// [`Program`]: trait.Program.html - /// [`Geometry`]: struct.Geometry.html - /// [`Frame`]: struct.Frame.html - /// [`Cache`]: struct.Cache.html - fn draw(&self, bounds: Rectangle, cursor: Cursor) -> Vec; - - /// 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`]. - /// - /// [`Program`]: trait.Program.html - /// [`Canvas`]: struct.Canvas.html - fn mouse_interaction( - &self, - _bounds: Rectangle, - _cursor: Cursor, - ) -> mouse::Interaction { - mouse::Interaction::default() - } -} - -impl Program for &mut T -where - T: Program, -{ - fn update( - &mut self, - event: Event, - bounds: Rectangle, - cursor: Cursor, - ) -> Option { - T::update(self, event, bounds, cursor) - } - - fn draw(&self, bounds: Rectangle, cursor: Cursor) -> Vec { - T::draw(self, bounds, cursor) - } - - fn mouse_interaction( - &self, - bounds: Rectangle, - cursor: Cursor, - ) -> mouse::Interaction { - T::mouse_interaction(self, bounds, cursor) - } -} -- cgit