1
0
Fork 0
baseview/examples/open_window.rs

41 lines
1.2 KiB
Rust
Raw Normal View History

2020-10-18 05:35:39 +11:00
use baseview::{Event, Window, WindowHandler, WindowSize, WindowScalePolicy};
2020-09-03 07:23:03 +10:00
struct MyProgram {}
2020-09-08 12:36:54 +10:00
impl WindowHandler for MyProgram {
type Message = ();
fn build(_window: &mut Window) -> Self {
Self {}
}
fn on_frame(&mut self) {}
fn on_event(&mut self, _window: &mut Window, event: Event) {
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),
}
}
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-18 05:35:39 +11:00
size: WindowSize::MinMaxLogical {
2020-10-18 06:01:03 +11:00
initial_size: baseview::Size::new(512, 512),
min_size: baseview::Size::new(200, 200),
max_size: baseview::Size::new(1024, 1024),
2020-10-18 05:35:39 +11:00
keep_aspect: false,
},
scale: WindowScalePolicy::TrySystemScaleFactor,
2020-09-12 02:25:50 +10:00
parent: baseview::Parent::None,
};
2020-10-16 05:17:03 +11:00
let (handle, _window_info) = Window::open::<MyProgram>(window_open_options).unwrap();
2020-09-12 02:25:50 +10:00
handle.app_run_blocking();
}