extern crate xloop_types as types; pub mod app; pub mod error; pub mod win; pub mod prelude {} #[derive(Debug)] pub struct Platform; impl types::Platform for Platform { type Error = error::Error; type AppRef<'a> = app::AppRef<'a>; type AppHandle = app::AppHandle; type AppProxy = app::AppProxy; type WinRef<'a> = win::WinRef<'a>; type WinHandle = win::WinHandle; type WinRaw = win::WinRaw; type EvtMouse<'a> = win::WinEvent<'a>; type EvtWheel<'a> = win::WinEvent<'a>; type EvtKey<'a> = win::WinEvent<'a>; type EvtTouch<'a> = win::WinEvent<'a>; type EvtCommit<'a> = &'a types::EvtCommit; fn run(delegate: impl types::AppDelegate + 'static) -> Result, Self::Error> { app::with_app(Some(std::rc::Rc::new(delegate)), |_| {}); use types::AppHandle as _; unsafe { app::AppHandle::singleton().ok_or(error::Error)?.run() }; Ok(None) } fn win(_key: impl AsRef, delegate: impl types::WinDelegate + 'static) -> Result { unsafe { win::WinHandle::new(_key, delegate).ok_or(error::Error) } } fn log(level: log::LevelFilter) { env_logger::builder().filter_level(level).init(); } fn read(path: impl AsRef) -> Option> { let base = app::app_path()?; let file = base.join(path); let bytes = std::fs::read(file).ok()?; Some(bytes) } } #[inline(always)] const fn loword(x: u32) -> u16 { (x & 0xffff) as u16 } #[inline(always)] const fn hiword(x: u32) -> u16 { ((x >> 16) & 0xffff) as u16 }