2020-10-20 19:02:45 -05:00
|
|
|
use baseview::{Event, Window, WindowHandler, WindowScalePolicy};
|
2020-09-02 16:22:49 -05:00
|
|
|
|
2020-10-20 21:31:44 +02:00
|
|
|
struct OpenWindowExample;
|
2020-09-02 16:22:49 -05:00
|
|
|
|
2020-10-20 21:31:44 +02:00
|
|
|
impl WindowHandler for OpenWindowExample {
|
2020-09-07 21:36:54 -05:00
|
|
|
type Message = ();
|
2020-09-03 11:38:22 -05:00
|
|
|
|
2020-09-11 16:49:55 +02:00
|
|
|
fn on_frame(&mut self) {}
|
2020-09-05 14:41:26 -05:00
|
|
|
|
2020-09-11 18:18:39 +02:00
|
|
|
fn on_event(&mut self, _window: &mut Window, event: Event) {
|
2020-09-03 11:38:22 -05:00
|
|
|
match event {
|
2020-09-11 10:21:05 -05:00
|
|
|
Event::Mouse(e) => println!("Mouse event: {:?}", e),
|
|
|
|
Event::Keyboard(e) => println!("Keyboard event: {:?}", e),
|
2020-09-11 12:38:06 -05:00
|
|
|
Event::Window(e) => println!("Window event: {:?}", e),
|
2020-09-02 16:22:49 -05:00
|
|
|
}
|
|
|
|
}
|
2020-09-03 11:38:22 -05:00
|
|
|
|
2020-09-11 16:49:55 +02:00
|
|
|
fn on_message(&mut self, _window: &mut Window, _message: Self::Message) {}
|
2020-09-02 16:23:03 -05:00
|
|
|
}
|
2020-09-11 18:25:50 +02:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let window_open_options = baseview::WindowOpenOptions {
|
|
|
|
title: "baseview".into(),
|
2020-10-20 19:02:45 -05:00
|
|
|
size: baseview::Size::new(512.0, 512.0),
|
|
|
|
scale: WindowScalePolicy::SystemScaleFactor,
|
2020-09-11 18:25:50 +02:00
|
|
|
parent: baseview::Parent::None,
|
|
|
|
};
|
|
|
|
|
2020-10-20 21:31:44 +02:00
|
|
|
let handle = Window::open(window_open_options, |_| OpenWindowExample);
|
2020-09-11 18:25:50 +02:00
|
|
|
handle.app_run_blocking();
|
|
|
|
}
|