Implement conversion for CursorIcon in winit

This commit is contained in:
Héctor Ramón Jiménez 2019-09-02 04:56:26 +02:00
parent cc6d5b8ec7
commit 6d248719f3
2 changed files with 15 additions and 1 deletions

View File

@ -14,5 +14,5 @@ pub enum Event {
}, },
/// A unicode character was received. /// A unicode character was received.
ReceivedCharacter(char), CharacterReceived(char),
} }

View File

@ -19,3 +19,17 @@ pub enum MouseCursor {
/// The cursor is grabbing a widget. /// The cursor is grabbing a widget.
Grabbing, Grabbing,
} }
#[cfg(feature = "winit")]
impl From<MouseCursor> 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,
}
}
}