2019-06-22 01:33:15 +10:00
|
|
|
use winit::{
|
|
|
|
event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent},
|
|
|
|
event_loop::{ControlFlow, EventLoop},
|
|
|
|
window::WindowBuilder,
|
|
|
|
};
|
2018-06-12 08:47:50 +10:00
|
|
|
|
|
|
|
fn main() {
|
2019-02-06 02:30:33 +11:00
|
|
|
let event_loop = EventLoop::new();
|
2018-06-12 08:47:50 +10:00
|
|
|
|
|
|
|
let mut resizable = false;
|
|
|
|
|
2019-02-06 02:30:33 +11:00
|
|
|
let window = WindowBuilder::new()
|
2018-06-12 08:47:50 +10:00
|
|
|
.with_title("Hit space to toggle resizability.")
|
2019-05-30 11:29:54 +10:00
|
|
|
.with_inner_size((400, 200).into())
|
2018-06-12 08:47:50 +10:00
|
|
|
.with_resizable(resizable)
|
2019-02-06 02:30:33 +11:00
|
|
|
.build(&event_loop)
|
2018-06-12 08:47:50 +10:00
|
|
|
.unwrap();
|
|
|
|
|
2019-02-06 02:30:33 +11:00
|
|
|
event_loop.run(move |event, _, control_flow| {
|
|
|
|
*control_flow = ControlFlow::Wait;
|
2018-06-12 08:47:50 +10:00
|
|
|
match event {
|
2019-06-25 02:14:55 +10:00
|
|
|
Event::WindowEvent { event, .. } => match event {
|
|
|
|
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
|
|
|
|
WindowEvent::KeyboardInput {
|
|
|
|
input:
|
|
|
|
KeyboardInput {
|
|
|
|
virtual_keycode: Some(VirtualKeyCode::Space),
|
|
|
|
state: ElementState::Released,
|
|
|
|
..
|
|
|
|
},
|
|
|
|
..
|
|
|
|
} => {
|
|
|
|
resizable = !resizable;
|
|
|
|
println!("Resizable: {}", resizable);
|
|
|
|
window.set_resizable(resizable);
|
2018-06-12 08:47:50 +10:00
|
|
|
}
|
2019-06-25 02:14:55 +10:00
|
|
|
_ => (),
|
2018-06-12 08:47:50 +10:00
|
|
|
},
|
|
|
|
_ => (),
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|