Add a WindowBuilder::with_window_resize_callback method.

This allows for passing the window_resize_callback fn during the window
building stage. More importantly, this allows setting the callback
without the need for mutable access to the Window, making it possible
to set the callback in the downstream glium crate.

This may solve tomaka/glium#1232 for most folk.
This commit is contained in:
mitchmindtree 2016-11-11 22:08:46 +11:00
parent 97da37ef04
commit eb18b3d8b6
3 changed files with 27 additions and 4 deletions

View file

@ -12,9 +12,11 @@ fn resize_callback(width: u32, height: u32) {
}
fn main() {
let mut window = winit::WindowBuilder::new().build().unwrap();
window.set_title("A fantastic window!");
window.set_window_resize_callback(Some(resize_callback as fn(u32, u32)));
let window = winit::WindowBuilder::new()
.with_title("A fantastic window!")
.with_window_resize_callback(resize_callback)
.build()
.unwrap();
for event in window.wait_events() {
println!("{:?}", event);