Remove window resize call in timer example (#938)

* Remove window resize call in timer example

* Move timer_length to separate variable

* Re-add _window
This commit is contained in:
Osspial 2019-06-19 22:06:09 -04:00 committed by GitHub
parent de2f0740f7
commit 06244dd492
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,16 +12,17 @@ fn main() {
.build(&event_loop)
.unwrap();
let timer_length = Duration::new(1, 0);
event_loop.run(move |event, _, control_flow| {
println!("{:?}", event);
match event {
Event::NewEvents(StartCause::Init) =>
*control_flow = ControlFlow::WaitUntil(Instant::now() + Duration::new(1, 0)),
*control_flow = ControlFlow::WaitUntil(Instant::now() + timer_length),
Event::NewEvents(StartCause::ResumeTimeReached{..}) => {
*control_flow = ControlFlow::WaitUntil(Instant::now() + Duration::new(1, 0));
*control_flow = ControlFlow::WaitUntil(Instant::now() + timer_length);
println!("\nTimer\n");
_window.set_inner_size(winit::dpi::LogicalSize::new(300.0, 300.0));
},
Event::WindowEvent {
event: WindowEvent::CloseRequested,