Introduce Cursor type in canvas
This commit is contained in:
parent
5586034d66
commit
dc51080328
6 changed files with 169 additions and 108 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue