1
0
Fork 0
baseview/src/lib.rs

71 lines
1.4 KiB
Rust
Raw Normal View History

use raw_window_handle::RawWindowHandle;
2020-05-26 04:04:48 +10:00
#[cfg(target_os = "windows")]
mod win;
#[cfg(target_os = "windows")]
pub use win::*;
#[cfg(target_os = "linux")]
2020-05-26 05:35:33 +10:00
mod x11;
#[cfg(target_os = "linux")]
2020-06-01 04:29:32 +10:00
pub use crate::x11::*;
#[cfg(target_os = "macos")]
2020-05-26 07:14:42 +10:00
mod macos;
#[cfg(target_os = "macos")]
pub use macos::*;
2020-05-26 07:14:42 +10:00
mod event;
2020-09-12 01:21:05 +10:00
mod keyboard;
mod mouse_cursor;
2020-10-16 05:17:03 +11:00
mod window_info;
pub use event::*;
2020-09-12 01:21:05 +10:00
pub use keyboard::*;
pub use mouse_cursor::MouseCursor;
2020-10-16 05:17:03 +11:00
pub use window_info::WindowInfo;
2020-05-26 04:04:48 +10:00
pub enum Parent {
None,
AsIfParented,
WithParent(RawWindowHandle),
2020-05-26 04:04:48 +10:00
}
unsafe impl Send for Parent {}
pub struct WindowOpenOptions {
pub title: String,
2020-05-26 04:04:48 +10:00
2020-10-16 05:17:03 +11:00
/// The logical width of the window
pub width: u32,
/// The logical height of the window
pub height: u32,
/// The dpi scale factor. This will used in conjunction with the dpi scale
/// factor of the system.
pub scale: f64,
2020-05-26 04:04:48 +10:00
2020-05-26 05:35:03 +10:00
pub parent: Parent,
2020-05-26 04:04:48 +10:00
}
2020-10-16 05:17:03 +11:00
pub struct WindowHandle {
thread: std::thread::JoinHandle<()>,
}
impl WindowHandle {
pub fn app_run_blocking(self) {
let _ = self.thread.join();
}
}
type WindowOpenResult = Result<WindowInfo, ()>;
2020-09-08 12:36:54 +10:00
pub trait WindowHandler {
type Message;
fn build(window: &mut Window) -> Self;
fn on_frame(&mut self);
fn on_event(&mut self, window: &mut Window, event: Event);
2020-09-08 12:36:54 +10:00
fn on_message(&mut self, window: &mut Window, message: Self::Message);
2020-09-06 06:22:23 +10:00
}