Skip to content

Commit

Permalink
continue on ui
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Dec 30, 2024
1 parent 85fbbe5 commit 1ab08a5
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 5 deletions.
8 changes: 6 additions & 2 deletions cidre/pomace/ui/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
Expand Down
17 changes: 15 additions & 2 deletions cidre/src/ui.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
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;
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;
Expand Down Expand Up @@ -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>,
Expand Down
19 changes: 19 additions & 0 deletions cidre/src/ui/application.rs
Original file line number Diff line number Diff line change
@@ -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<App>;
}
2 changes: 1 addition & 1 deletion cidre/src/ui/scene.rs
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
19 changes: 19 additions & 0 deletions cidre/src/ui/window.rs
Original file line number Diff line number Diff line change
@@ -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<Window>;
}
14 changes: 14 additions & 0 deletions cidre/src/ui/window_scene.rs
Original file line number Diff line number Diff line change
@@ -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>);
}

0 comments on commit 1ab08a5

Please # to comment.