xloop_android 0.1.0

android impl for xloop.
Documentation
use core::ffi;

use ndkm::Window as ANWin;

use super::Platform;

#[derive(Clone, Copy)]
pub struct WinRef<'a>(pub Option<&'a ANWin>, pub &'a Win);
impl<'a> types::WinRef<Platform> for WinRef<'a> {
	fn raw(&self) -> Option<WinRaw> {
		self.0.map(|anwin| WinRaw::from(anwin.as_sys() as *mut ffi::c_void))
	}
	fn show(&self) {
		// todo!() //send tend
	}
	fn close(&self) {
		// todo!() // send tend
	}
	fn fresh(&self, reason: &str) {
		self.1.dirty(reason);
	}
	fn size(&self) -> (u32, u32) {
		let Some(anwin) = &self.0 else { return (0, 0) };
		let ret = (anwin.width() as _, anwin.height() as _);
		log::warn!("get size {}{}", ret.0, ret.1);
		ret
	}
	fn density(&self) -> f32 {
		self.1.scale_factor.unwrap_or(1.0)
	}
}

#[derive(Debug)]
pub struct WinHandle(pub String);
impl types::WinHandle<Platform> for WinHandle {
	fn with(&self, mut fun: impl FnMut(WinRef<'_>)) {
		with_wins(|wins| {
			for (_, win) in wins.iter().filter(|(_, win)| win.key_ == self.0) {
				fun(win.win_ref());
				break;
			}
		});
	}
}

mod event;
pub use event::*;

mod activity;
pub use activity::*;

mod wins;
pub use wins::*;

mod raw;
pub use raw::*;