2019-08-08 05:19:04 +03:00
|
|
|
use failure::Fallible;
|
2019-08-09 02:11:35 +03:00
|
|
|
use window::*;
|
2019-08-08 07:18:30 +03:00
|
|
|
|
|
|
|
struct MyWindow {
|
|
|
|
allow_close: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl WindowCallbacks for MyWindow {
|
|
|
|
fn can_close(&mut self) -> bool {
|
|
|
|
eprintln!("can I close?");
|
|
|
|
if self.allow_close {
|
|
|
|
terminate_message_loop();
|
|
|
|
true
|
|
|
|
} else {
|
|
|
|
self.allow_close = true;
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-08 05:19:04 +03:00
|
|
|
|
|
|
|
fn main() -> Fallible<()> {
|
2019-08-08 07:18:30 +03:00
|
|
|
let win = Window::new_window(
|
|
|
|
"myclass",
|
|
|
|
"the title",
|
|
|
|
800,
|
|
|
|
600,
|
|
|
|
Box::new(MyWindow { allow_close: false }),
|
|
|
|
)?;
|
2019-08-08 05:19:04 +03:00
|
|
|
|
|
|
|
win.show();
|
|
|
|
|
2019-08-08 07:18:30 +03:00
|
|
|
run_message_loop()
|
2019-08-08 05:19:04 +03:00
|
|
|
}
|