diff --git a/cidre/pomace/ui/ui.h b/cidre/pomace/ui/ui.h index a5d86cb9..f6322a04 100644 --- a/cidre/pomace/ui/ui.h +++ b/cidre/pomace/ui/ui.h @@ -10,7 +10,9 @@ NS_ASSUME_NONNULL_BEGIN Class UI_DEVICE; +Class UI_APPLICATION; Class UI_VIEW; +Class UI_WINDOW; Class UI_SCENE; Class UI_SCENE_CONFIGURATION; Class UI_COLOR; @@ -32,8 +34,10 @@ static void ui_initializer(void) UI_VIEW = NSClassFromString(@"UIView"); UI_SCENE_CONFIGURATION = NSClassFromString(@"UISceneConfiguration"); UI_COLOR = [UIColor class]; - UI_RESPONDER = NSClassFromString(@"UIResponder");//[UIResponder class]; - UI_VIEW_CONTROLLER = NSClassFromString(@"UIViewController");//[UIViewController class]; + UI_RESPONDER = NSClassFromString(@"UIResponder"); + UI_VIEW_CONTROLLER = NSClassFromString(@"UIViewController"); + UI_APPLICATION = NSClassFromString(@"UIApplication"); + UI_WINDOW = NSClassFromString(@"UIWindow"); UI_IMAGE = [UIImage class]; NS_TEXT_ATTACHMENT = [NSTextAttachment class]; diff --git a/cidre/src/ui.rs b/cidre/src/ui.rs index 8d9d19d5..cf3115ac 100644 --- a/cidre/src/ui.rs +++ b/cidre/src/ui.rs @@ -1,3 +1,8 @@ +mod application; +pub use application::App; +pub use application::AppDelegate; +pub use application::AppDelegateImpl; + mod device; pub use device::notifications as device_notifications; pub use device::BatteryState as DeviceBatteryState; @@ -5,11 +10,14 @@ pub use device::Device; pub use device::Orientation as DeviceOrientation; pub use device::UserInterfaceIdiom; +mod responder; +pub use responder::Responder; + mod view; pub use view::View; -mod responder; -pub use responder::Responder; +mod window; +pub use window::Window; mod view_controller; pub use view_controller::ViewController; @@ -40,6 +48,11 @@ pub use scene_session::SceneSession; mod scene_options; pub use scene_options::SceneConnectionOpts; +mod window_scene; +pub use window_scene::WindowScene; +pub use window_scene::WindowSceneDelegate; +pub use window_scene::WindowSceneDelegateImpl; + pub fn app_main( principal_class_name: Option<&crate::ns::String>, delegate_class_name: Option<&crate::ns::String>, diff --git a/cidre/src/ui/application.rs b/cidre/src/ui/application.rs new file mode 100644 index 00000000..7359692e --- /dev/null +++ b/cidre/src/ui/application.rs @@ -0,0 +1,19 @@ +use crate::{arc, define_obj_type, objc, ui}; + +#[objc::protocol(UIApplication)] +pub trait AppDelegate { + #[objc::optional] + #[objc::msg_send(applicationDidFinishLaunching:)] + fn app_did_finish_launching(&mut self, app: &App); +} + +define_obj_type!( + pub App(ui::Responder), + UI_APPLICATION +); + +impl App {} + +extern "C" { + static UI_APPLICATION: &'static objc::Class; +} diff --git a/cidre/src/ui/scene.rs b/cidre/src/ui/scene.rs index 418dc518..f83f9097 100644 --- a/cidre/src/ui/scene.rs +++ b/cidre/src/ui/scene.rs @@ -1,4 +1,4 @@ -use crate::{arc, define_cls, define_obj_type, ns, objc, ui}; +use crate::{define_cls, define_obj_type, ns, objc, ui}; define_obj_type!( pub Scene(ui::Responder) diff --git a/cidre/src/ui/window.rs b/cidre/src/ui/window.rs new file mode 100644 index 00000000..1f0327f1 --- /dev/null +++ b/cidre/src/ui/window.rs @@ -0,0 +1,19 @@ +use crate::{arc, define_obj_type, objc, ui}; + +define_obj_type!( + pub Window(ui::View), + UI_WINDOW +); + +impl Window { + #[objc::msg_send(rootViewController)] + pub fn root_vc(&self) -> Option<&ui::ViewController>; + + #[objc::msg_send(setRootViewController:)] + pub fn set_root_vc(&mut self, val: Option<&ui::ViewController>); +} + +#[link(name = "ui", kind = "static")] +extern "C" { + static UI_WINDOW: &'static objc::Class; +} diff --git a/cidre/src/ui/window_scene.rs b/cidre/src/ui/window_scene.rs new file mode 100644 index 00000000..6a78339e --- /dev/null +++ b/cidre/src/ui/window_scene.rs @@ -0,0 +1,14 @@ +use crate::{define_obj_type, objc, ui}; + +define_obj_type!( + pub WindowScene(ui::Scene) +); + +#[objc::protocol(UIWindowSceneDelegate)] +pub trait WindowSceneDelegate { + #[objc::msg_send(window)] + fn window(&self) -> Option<&ui::Window>; + + #[objc::msg_send(setWindow:)] + fn set_window(&mut self, val: Option<&ui::Window>); +}