2020-05-26 04:04:48 +10:00
|
|
|
use std::ffi::c_void;
|
|
|
|
|
2020-05-26 08:28:38 +10:00
|
|
|
#[cfg(target_os = "windows")]
|
|
|
|
mod win;
|
|
|
|
#[cfg(target_os = "windows")]
|
|
|
|
pub use win::*;
|
2020-05-26 12:10:32 +10:00
|
|
|
|
2020-05-26 08:28:38 +10:00
|
|
|
#[cfg(target_os = "linux")]
|
2020-05-26 05:35:33 +10:00
|
|
|
mod x11;
|
2020-05-26 12:10:32 +10:00
|
|
|
#[cfg(target_os = "linux")]
|
2020-06-01 04:29:32 +10:00
|
|
|
pub use crate::x11::*;
|
2020-05-26 12:10:32 +10:00
|
|
|
|
2020-05-26 08:28:38 +10:00
|
|
|
#[cfg(target_os = "macos")]
|
2020-05-26 07:14:42 +10:00
|
|
|
mod macos;
|
2020-05-26 08:28:38 +10:00
|
|
|
#[cfg(target_os = "macos")]
|
2020-05-26 12:10:32 +10:00
|
|
|
pub use macos::*;
|
2020-05-26 07:14:42 +10:00
|
|
|
|
2020-09-04 02:38:22 +10:00
|
|
|
mod event;
|
|
|
|
pub use event::*;
|
2020-09-03 07:22:49 +10:00
|
|
|
|
2020-05-26 04:04:48 +10:00
|
|
|
pub enum Parent {
|
|
|
|
None,
|
|
|
|
AsIfParented,
|
2020-05-26 05:35:03 +10:00
|
|
|
WithParent(*mut c_void),
|
2020-05-26 04:04:48 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct WindowOpenOptions<'a> {
|
|
|
|
pub title: &'a str,
|
|
|
|
|
|
|
|
pub width: usize,
|
|
|
|
pub height: usize,
|
|
|
|
|
2020-05-26 05:35:03 +10:00
|
|
|
pub parent: Parent,
|
2020-05-26 04:04:48 +10:00
|
|
|
}
|
2020-09-04 01:54:23 +10:00
|
|
|
|
2020-09-06 02:19:09 +10:00
|
|
|
pub trait AppWindow {
|
2020-09-04 02:38:22 +10:00
|
|
|
type AppMessage;
|
|
|
|
|
2020-09-06 06:22:23 +10:00
|
|
|
fn create_context(&mut self, window: RawWindow, window_info: &WindowInfo);
|
2020-09-06 05:41:26 +10:00
|
|
|
fn draw(&mut self);
|
2020-09-04 02:38:22 +10:00
|
|
|
fn on_event(&mut self, event: Event);
|
|
|
|
fn on_app_message(&mut self, message: Self::AppMessage);
|
2020-09-04 01:54:23 +10:00
|
|
|
}
|
2020-09-06 06:22:23 +10:00
|
|
|
|
|
|
|
/// A wrapper for a `RawWindowHandle`. Some context creators expect an `&impl HasRawWindowHandle`.
|
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
|
|
pub struct RawWindow {
|
|
|
|
pub raw_window_handle: raw_window_handle::RawWindowHandle,
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe impl raw_window_handle::HasRawWindowHandle for RawWindow {
|
|
|
|
fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle {
|
|
|
|
self.raw_window_handle
|
|
|
|
}
|
|
|
|
}
|