use super::{BoolExt as _, Dispatcher, FontSystem, Window}; use crate::{executor, platform}; use anyhow::Result; use cocoa::base::id; use objc::{class, msg_send, sel, sel_impl}; use std::{rc::Rc, sync::Arc}; pub struct App { dispatcher: Arc, fonts: Arc, } impl App { pub fn new() -> Self { Self { dispatcher: Arc::new(Dispatcher), fonts: Arc::new(FontSystem::new()), } } } impl platform::App for App { fn dispatcher(&self) -> Arc { self.dispatcher.clone() } fn activate(&self, ignoring_other_apps: bool) { unsafe { let app: id = msg_send![class!(NSApplication), sharedApplication]; let _: () = msg_send![app, activateIgnoringOtherApps: ignoring_other_apps.to_objc()]; } } fn open_window( &self, options: platform::WindowOptions, executor: Rc, ) -> Result> { Ok(Box::new(Window::open(options, executor, self.fonts())?)) } fn fonts(&self) -> Arc { self.fonts.clone() } }