1 | use core::ffi::c_void;
|
2 | use core::ptr::NonNull;
|
3 |
|
4 | /// Raw display handle for UIKit.
|
5 | #[non_exhaustive ]
|
6 | #[derive (Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
7 | pub struct UiKitDisplayHandle {}
|
8 |
|
9 | impl UiKitDisplayHandle {
|
10 | /// Create a new empty display handle.
|
11 | ///
|
12 | ///
|
13 | /// # Example
|
14 | ///
|
15 | /// ```
|
16 | /// # use raw_window_handle::UiKitDisplayHandle;
|
17 | /// let handle = UiKitDisplayHandle::new();
|
18 | /// ```
|
19 | pub fn new() -> Self {
|
20 | Self {}
|
21 | }
|
22 | }
|
23 |
|
24 | /// Raw window handle for UIKit.
|
25 | #[non_exhaustive ]
|
26 | #[derive (Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
27 | pub struct UiKitWindowHandle {
|
28 | /// A pointer to an `UIView` object.
|
29 | pub ui_view: NonNull<c_void>,
|
30 | /// A pointer to an `UIViewController` object, if the view has one.
|
31 | pub ui_view_controller: Option<NonNull<c_void>>,
|
32 | }
|
33 |
|
34 | impl UiKitWindowHandle {
|
35 | /// Create a new handle to a view.
|
36 | ///
|
37 | ///
|
38 | /// # Example
|
39 | ///
|
40 | /// ```
|
41 | /// # use core::ptr::NonNull;
|
42 | /// # use raw_window_handle::UiKitWindowHandle;
|
43 | /// # type UIView = ();
|
44 | /// #
|
45 | /// let view: &UIView;
|
46 | /// # view = &();
|
47 | /// let mut handle = UiKitWindowHandle::new(NonNull::from(view).cast());
|
48 | /// // Optionally set the view controller.
|
49 | /// handle.ui_view_controller = None;
|
50 | /// ```
|
51 | pub fn new(ui_view: NonNull<c_void>) -> Self {
|
52 | Self {
|
53 | ui_view,
|
54 | ui_view_controller: None,
|
55 | }
|
56 | }
|
57 | }
|
58 | |