From 6d248719f35b850a9df1bdb3b87b5415e8f063a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Mon, 2 Sep 2019 04:56:26 +0200 Subject: [PATCH] Implement conversion for `CursorIcon` in `winit` --- src/input/keyboard/event.rs | 2 +- src/mouse_cursor.rs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/input/keyboard/event.rs b/src/input/keyboard/event.rs index 1c760fd3..5acd46c0 100644 --- a/src/input/keyboard/event.rs +++ b/src/input/keyboard/event.rs @@ -14,5 +14,5 @@ pub enum Event { }, /// A unicode character was received. - ReceivedCharacter(char), + CharacterReceived(char), } diff --git a/src/mouse_cursor.rs b/src/mouse_cursor.rs index f6a68c54..4ef6361a 100644 --- a/src/mouse_cursor.rs +++ b/src/mouse_cursor.rs @@ -19,3 +19,17 @@ pub enum MouseCursor { /// The cursor is grabbing a widget. Grabbing, } + +#[cfg(feature = "winit")] +impl From for winit::window::CursorIcon { + fn from(mouse_cursor: MouseCursor) -> winit::window::CursorIcon { + match mouse_cursor { + MouseCursor::OutOfBounds => winit::window::CursorIcon::Default, + MouseCursor::Idle => winit::window::CursorIcon::Default, + MouseCursor::Pointer => winit::window::CursorIcon::Hand, + MouseCursor::Working => winit::window::CursorIcon::Progress, + MouseCursor::Grab => winit::window::CursorIcon::Grab, + MouseCursor::Grabbing => winit::window::CursorIcon::Grabbing, + } + } +}