Files
archived-tao/examples/window.rs
Hamir Mahal c49b83a11d style: simplify string formatting for readability (#987)
* style: simplify string formatting for readability

* fix: formatting in `src/platform` directories
2024-10-11 04:59:19 +03:00

53 lines
1.2 KiB
Rust

// Copyright 2014-2021 The winit contributors
// Copyright 2021-2023 Tauri Programme within The Commons Conservancy
// SPDX-License-Identifier: Apache-2.0
use tao::{
event::{Event, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
};
#[allow(clippy::single_match)]
fn main() {
let event_loop = EventLoop::new();
let mut window = Some(
WindowBuilder::new()
.with_title("A fantastic window!")
.with_inner_size(tao::dpi::LogicalSize::new(300.0, 300.0))
.with_min_inner_size(tao::dpi::LogicalSize::new(200.0, 200.0))
.build(&event_loop)
.unwrap(),
);
event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
println!("{event:?}");
match event {
Event::WindowEvent {
event: WindowEvent::CloseRequested,
window_id: _,
..
} => {
// drop the window to fire the `Destroyed` event
window = None;
}
Event::WindowEvent {
event: WindowEvent::Destroyed,
window_id: _,
..
} => {
*control_flow = ControlFlow::Exit;
}
Event::MainEventsCleared => {
if let Some(w) = &window {
w.request_redraw();
}
}
_ => (),
}
});
}