1mod event;
2#[cfg(target_os = "macos")]
3pub mod mac;
4pub mod current {
5 #[cfg(target_os = "macos")]
6 pub use super::mac::*;
7}
8
9use crate::{executor, geometry::rect::RectF};
10use anyhow::Result;
11use async_task::Runnable;
12pub use event::Event;
13use std::{path::PathBuf, rc::Rc, sync::Arc};
14
15pub trait Runner {
16 fn on_finish_launching<F: 'static + FnOnce()>(self, callback: F) -> Self where;
17 fn on_become_active<F: 'static + FnMut()>(self, callback: F) -> Self;
18 fn on_resign_active<F: 'static + FnMut()>(self, callback: F) -> Self;
19 fn on_event<F: 'static + FnMut(Event) -> bool>(self, callback: F) -> Self;
20 fn on_open_files<F: 'static + FnMut(Vec<PathBuf>)>(self, callback: F) -> Self;
21 fn run(self);
22}
23
24pub trait App {
25 fn dispatcher(&self) -> Arc<dyn Dispatcher>;
26 fn activate(&self, ignoring_other_apps: bool);
27 fn open_window(
28 &self,
29 options: WindowOptions,
30 executor: Rc<executor::Foreground>,
31 ) -> Result<Rc<dyn Window>>;
32}
33
34pub trait Dispatcher: Send + Sync {
35 fn is_main_thread(&self) -> bool;
36 fn run_on_main_thread(&self, task: Runnable);
37}
38
39pub trait Window {}
40
41pub struct WindowOptions<'a> {
42 pub bounds: RectF,
43 pub title: Option<&'a str>,
44}