Introduce Cursor type in canvas

This commit is contained in:
Héctor Ramón Jiménez 2020-04-29 04:25:49 +02:00
parent 5586034d66
commit dc51080328
6 changed files with 169 additions and 108 deletions

View file

@ -1,14 +1,19 @@
use crate::canvas::{Event, Geometry, Size};
use iced_native::MouseCursor;
use crate::canvas::{Cursor, Event, Geometry};
use iced_native::{MouseCursor, Rectangle};
pub trait Program<Message> {
fn update(&mut self, _event: Event, _bounds: Size) -> Option<Message> {
fn update(
&mut self,
_event: Event,
_bounds: Rectangle,
_cursor: Cursor,
) -> Option<Message> {
None
}
fn draw(&self, bounds: Size) -> Vec<Geometry>;
fn draw(&self, bounds: Rectangle, cursor: Cursor) -> Vec<Geometry>;
fn mouse_cursor(&self, _bounds: Size) -> MouseCursor {
fn mouse_cursor(&self, _bounds: Rectangle, _cursor: Cursor) -> MouseCursor {
MouseCursor::default()
}
}
@ -17,15 +22,20 @@ 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 update(
&mut self,
event: Event,
bounds: Rectangle,
cursor: Cursor,
) -> Option<Message> {
T::update(self, event, bounds, cursor)
}
fn draw(&self, bounds: Size) -> Vec<Geometry> {
T::draw(self, bounds)
fn draw(&self, bounds: Rectangle, cursor: Cursor) -> Vec<Geometry> {
T::draw(self, bounds, cursor)
}
fn mouse_cursor(&self, bounds: Size) -> MouseCursor {
T::mouse_cursor(self, bounds)
fn mouse_cursor(&self, bounds: Rectangle, cursor: Cursor) -> MouseCursor {
T::mouse_cursor(self, bounds, cursor)
}
}