2019-07-11 00:54:54 +02:00
|
|
|
use instant::Instant;
|
|
|
|
use std::time::Duration;
|
2020-09-09 17:58:30 -08:00
|
|
|
|
|
|
|
use simple_logger::SimpleLogger;
|
2019-06-21 11:33:15 -04:00
|
|
|
use winit::{
|
|
|
|
event::{Event, StartCause, WindowEvent},
|
|
|
|
event_loop::{ControlFlow, EventLoop},
|
|
|
|
window::WindowBuilder,
|
|
|
|
};
|
2019-02-05 10:30:33 -05:00
|
|
|
|
|
|
|
fn main() {
|
2020-09-09 17:58:30 -08:00
|
|
|
SimpleLogger::new().init().unwrap();
|
2019-02-05 10:30:33 -05:00
|
|
|
let event_loop = EventLoop::new();
|
|
|
|
|
|
|
|
let _window = WindowBuilder::new()
|
|
|
|
.with_title("A fantastic window!")
|
|
|
|
.build(&event_loop)
|
|
|
|
.unwrap();
|
|
|
|
|
2019-06-19 22:06:09 -04:00
|
|
|
let timer_length = Duration::new(1, 0);
|
|
|
|
|
2019-02-05 10:30:33 -05:00
|
|
|
event_loop.run(move |event, _, control_flow| {
|
2019-11-22 17:11:04 -07:00
|
|
|
println!("{:?}", event);
|
2019-02-05 10:30:33 -05:00
|
|
|
|
|
|
|
match event {
|
2019-06-21 11:33:15 -04:00
|
|
|
Event::NewEvents(StartCause::Init) => {
|
|
|
|
*control_flow = ControlFlow::WaitUntil(Instant::now() + timer_length)
|
2019-06-24 12:14:55 -04:00
|
|
|
}
|
2019-06-21 11:33:15 -04:00
|
|
|
Event::NewEvents(StartCause::ResumeTimeReached { .. }) => {
|
2019-06-19 22:06:09 -04:00
|
|
|
*control_flow = ControlFlow::WaitUntil(Instant::now() + timer_length);
|
2019-02-05 10:30:33 -05:00
|
|
|
println!("\nTimer\n");
|
2019-06-24 12:14:55 -04:00
|
|
|
}
|
2019-02-05 10:30:33 -05:00
|
|
|
Event::WindowEvent {
|
|
|
|
event: WindowEvent::CloseRequested,
|
|
|
|
..
|
|
|
|
} => *control_flow = ControlFlow::Exit,
|
2019-06-21 11:33:15 -04:00
|
|
|
_ => (),
|
2019-02-05 10:30:33 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|