mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 05:21:31 +11:00
Add example demonstrating min/max window dimension constraints.
This commit is contained in:
parent
e3fce3d5ec
commit
f8666a05fb
31
examples/constraints.rs
Normal file
31
examples/constraints.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
#[cfg(target_os = "android")]
|
||||
#[macro_use]
|
||||
extern crate android_glue;
|
||||
|
||||
extern crate winit;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
android_start!(main);
|
||||
|
||||
fn resize_callback(width: u32, height: u32) {
|
||||
println!("Window resized to {}x{}", width, height);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let window = winit::WindowBuilder::new()
|
||||
.with_title("A fantastic window!")
|
||||
.with_window_resize_callback(resize_callback)
|
||||
.with_min_dimensions(400, 200)
|
||||
.with_max_dimensions(800, 400)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
for event in window.wait_events() {
|
||||
println!("{:?}", event);
|
||||
|
||||
match event {
|
||||
winit::Event::Closed => break,
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue