2016-03-26 18:07:52 +01:00
|
|
|
extern crate winit;
|
2015-01-12 16:22:37 -08:00
|
|
|
|
2019-02-05 10:30:33 -05:00
|
|
|
use winit::window::{WindowBuilder, MouseCursor};
|
|
|
|
use winit::event::{Event, WindowEvent, ElementState, KeyboardInput};
|
|
|
|
use winit::event_loop::{EventLoop, ControlFlow};
|
2015-01-12 16:22:37 -08:00
|
|
|
|
2015-12-26 16:38:00 +02:00
|
|
|
fn main() {
|
2019-02-05 10:30:33 -05:00
|
|
|
let event_loop = EventLoop::new();
|
2017-01-28 15:45:01 +01:00
|
|
|
|
2019-02-05 10:30:33 -05:00
|
|
|
let window = WindowBuilder::new().build(&event_loop).unwrap();
|
2015-12-26 16:38:00 +02:00
|
|
|
window.set_title("A fantastic window!");
|
2015-01-12 16:22:37 -08:00
|
|
|
|
|
|
|
let mut cursor_idx = 0;
|
2015-12-26 16:38:00 +02:00
|
|
|
|
2019-02-05 10:30:33 -05:00
|
|
|
event_loop.run(move |event, _, control_flow| {
|
2015-06-16 13:48:08 +02:00
|
|
|
match event {
|
2017-04-22 13:52:35 -07:00
|
|
|
Event::WindowEvent { event: WindowEvent::KeyboardInput { input: KeyboardInput { state: ElementState::Pressed, .. }, .. }, .. } => {
|
2019-02-05 10:30:33 -05:00
|
|
|
println!("Setting cursor to \"{:?}\"", CURSORS[cursor_idx]);
|
|
|
|
window.set_cursor(CURSORS[cursor_idx]);
|
|
|
|
if cursor_idx < CURSORS.len() - 1 {
|
2015-06-16 13:48:08 +02:00
|
|
|
cursor_idx += 1;
|
|
|
|
} else {
|
|
|
|
cursor_idx = 0;
|
|
|
|
}
|
|
|
|
},
|
2018-04-24 16:20:40 -04:00
|
|
|
Event::WindowEvent { event: WindowEvent::CloseRequested, .. } => {
|
2019-02-05 10:30:33 -05:00
|
|
|
*control_flow = ControlFlow::Exit;
|
|
|
|
return;
|
2017-01-28 15:45:01 +01:00
|
|
|
},
|
|
|
|
_ => ()
|
2015-06-16 13:48:08 +02:00
|
|
|
}
|
2017-01-28 15:45:01 +01:00
|
|
|
});
|
2015-01-12 16:22:37 -08:00
|
|
|
}
|
2019-02-05 10:30:33 -05:00
|
|
|
|
|
|
|
const CURSORS: &[MouseCursor] = &[
|
|
|
|
MouseCursor::Default, MouseCursor::Crosshair, MouseCursor::Hand,
|
|
|
|
MouseCursor::Arrow, MouseCursor::Move, MouseCursor::Text,
|
|
|
|
MouseCursor::Wait, MouseCursor::Help, MouseCursor::Progress,
|
|
|
|
MouseCursor::NotAllowed, MouseCursor::ContextMenu, MouseCursor::Cell,
|
|
|
|
MouseCursor::VerticalText, MouseCursor::Alias, MouseCursor::Copy,
|
|
|
|
MouseCursor::NoDrop, MouseCursor::Grab, MouseCursor::Grabbing,
|
|
|
|
MouseCursor::AllScroll, MouseCursor::ZoomIn, MouseCursor::ZoomOut,
|
|
|
|
MouseCursor::EResize, MouseCursor::NResize, MouseCursor::NeResize,
|
|
|
|
MouseCursor::NwResize, MouseCursor::SResize, MouseCursor::SeResize,
|
|
|
|
MouseCursor::SwResize, MouseCursor::WResize, MouseCursor::EwResize,
|
|
|
|
MouseCursor::NsResize, MouseCursor::NeswResize, MouseCursor::NwseResize,
|
|
|
|
MouseCursor::ColResize, MouseCursor::RowResize
|
|
|
|
];
|