2020-09-08 12:36:54 +10:00
|
|
|
use baseview::{Event, Window, WindowHandler};
|
2020-09-03 07:22:49 +10:00
|
|
|
|
2020-09-03 07:23:03 +10:00
|
|
|
struct MyProgram {}
|
2020-09-03 07:22:49 +10:00
|
|
|
|
2020-09-08 12:36:54 +10:00
|
|
|
impl WindowHandler for MyProgram {
|
|
|
|
type Message = ();
|
2020-09-04 02:38:22 +10:00
|
|
|
|
2020-09-12 00:49:55 +10:00
|
|
|
fn build(_window: &mut Window) -> Self {
|
2020-09-06 08:29:36 +10:00
|
|
|
Self {}
|
2020-09-04 01:54:23 +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),
|
|
|
|
Event::Window(e) => println!("Window event: {:?}", e),
|
|
|
|
Event::FileDrop(e) => println!("File drop 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(),
|
|
|
|
width: 512,
|
|
|
|
height: 512,
|
|
|
|
parent: baseview::Parent::None,
|
|
|
|
};
|
|
|
|
|
|
|
|
let handle = Window::open::<MyProgram>(window_open_options);
|
|
|
|
handle.app_run_blocking();
|
|
|
|
}
|