1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! A wrapper around various pieces of the iOS13+ UIScene API.
//!
//! This is required for things like having multiple instances of your app in the app switcher on
//! iPad. In general, you probably won't need to tweak this though.

use core_graphics::geometry::CGRect;

use objc::runtime::Object;
use objc::{class, msg_send, sel, sel_impl};
use objc_id::Id;

use crate::foundation::id;
use crate::geometry::Rect;

mod delegate;
pub(crate) use delegate::*;

mod config;
pub use config::SceneConfig;

mod enums;
pub use enums::*;

mod traits;
pub use traits::*;

mod options;
pub use options::*;

mod session;
pub use session::*;

#[derive(Debug)]
pub struct Scene(pub Id<Object>);

impl Scene {
    pub fn with(scene: id) -> Self {
        Scene(unsafe { Id::from_ptr(scene) })
    }

    // This is temporary - I'm not wrapping `coordinateSpace` until I'm happy with the ergonomics
    // of everything.
    pub fn get_bounds(&self) -> Rect {
        unsafe {
            let coordinate_space: id = msg_send![&*self.0, coordinateSpace];
            let rect: CGRect = msg_send![coordinate_space, bounds];
            rect
        }
        .into()
    }

    pub fn into_inner(mut self) -> id {
        &mut *self.0
    }
}