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