1use crate::{api, arc, define_obj_type, ns, objc};
2
3#[cfg(all(
4 feature = "blocks",
5 any(
6 all(feature = "app", target_os = "macos"),
7 all(
8 feature = "ui",
9 any(target_os = "ios", target_os = "tvos", target_os = "visionos")
10 )
11 )
12))]
13use crate::blocks;
14#[cfg(all(
15 feature = "ui",
16 any(target_os = "ios", target_os = "tvos", target_os = "visionos")
17))]
18use crate::ui;
19
20#[doc(alias = "SCRecordingEditorMode")]
21#[cfg(target_os = "tvos")]
22#[derive(Debug, Copy, Clone, Eq, PartialEq)]
23#[repr(isize)]
24pub enum Mode {
26 #[doc(alias = "SCRecordingEditorModePreview")]
28 Preview,
29 #[doc(alias = "SCRecordingEditorModeShare")]
31 Share,
32}
33
34#[doc(alias = "SCRecordingEditorDelegate")]
35#[objc::protocol(SCRecordingEditorDelegate)]
37pub trait Delegate: objc::Obj {
38 #[objc::optional]
40 #[objc::msg_send(recordingEditorDidDismiss:)]
41 fn recording_editor_did_dismiss(&mut self, editor: &mut RecordingEditor);
42
43 #[objc::optional]
45 #[objc::msg_send(recordingEditor:didFailWithError:)]
46 fn recording_editor_did_fail_with_err(
47 &mut self,
48 editor: &mut RecordingEditor,
49 error: &ns::Error,
50 );
51}
52
53define_obj_type!(pub AnyDelegate(ns::Id));
54impl Delegate for AnyDelegate {}
55
56define_obj_type!(
57 #[doc(alias = "SCRecordingEditor")]
59 pub RecordingEditor(ns::Id)
60);
61
62impl arc::A<RecordingEditor> {
63 #[objc::msg_send(initWithURL:)]
65 #[api::available(
66 macos = 27.0,
67 maccatalyst = 27.0,
68 ios = 27.0,
69 visionos = 27.0,
70 tvos = 27.0
71 )]
72 pub fn init_with_url(self, url: &ns::Url) -> arc::Retained<RecordingEditor>;
73}
74
75impl RecordingEditor {
76 #[api::available(
77 macos = 27.0,
78 maccatalyst = 27.0,
79 ios = 27.0,
80 visionos = 27.0,
81 tvos = 27.0
82 )]
83 crate::define_cls!(SC_RECORDING_EDITOR);
84
85 #[inline]
86 #[api::available(
91 macos = 27.0,
92 maccatalyst = 27.0,
93 ios = 27.0,
94 visionos = 27.0,
95 tvos = 27.0
96 )]
97 pub fn with_url(url: &ns::Url) -> Option<arc::R<Self>> {
98 #[cfg(any(
99 feature = "macos_27_0",
100 feature = "maccatalyst_27_0",
101 feature = "ios_27_0",
102 feature = "tvos_27_0",
103 feature = "visionos_27_0"
104 ))]
105 {
106 Some(Self::alloc().init_with_url(url))
107 }
108
109 #[cfg(not(any(
110 feature = "macos_27_0",
111 feature = "maccatalyst_27_0",
112 feature = "ios_27_0",
113 feature = "tvos_27_0",
114 feature = "visionos_27_0"
115 )))]
116 {
117 Some(unsafe { Self::alloc()?.init_with_url(url) })
118 }
119 }
120
121 #[objc::msg_send(delegate)]
123 #[api::available(
124 macos = 27.0,
125 maccatalyst = 27.0,
126 ios = 27.0,
127 visionos = 27.0,
128 tvos = 27.0
129 )]
130 pub fn delegate(&self) -> Option<arc::R<AnyDelegate>>;
131
132 #[objc::msg_send(setDelegate:)]
134 #[api::available(
135 macos = 27.0,
136 maccatalyst = 27.0,
137 ios = 27.0,
138 visionos = 27.0,
139 tvos = 27.0
140 )]
141 pub fn set_delegate<D: Delegate>(&mut self, val: Option<&D>);
142
143 #[cfg(all(feature = "blocks", feature = "app", target_os = "macos"))]
144 #[objc::msg_send(presentFromWindow:completionHandler:)]
146 #[api::available(macos = 27.0)]
147 pub fn present_from_window_ch(
148 &mut self,
149 window: &ns::Window,
150 handler: Option<&mut blocks::ErrCh>,
151 );
152
153 #[cfg(all(
154 feature = "blocks",
155 feature = "async",
156 feature = "app",
157 target_os = "macos"
158 ))]
159 #[api::available(macos = 27.0)]
161 pub async fn present_from_window(
162 &mut self,
163 window: &ns::Window,
164 ) -> Result<(), arc::R<ns::Error>> {
165 let (future, mut block) = blocks::ok();
166 #[cfg(feature = "macos_27_0")]
167 {
168 self.present_from_window_ch(window, Some(&mut block));
169 }
170
171 #[cfg(not(feature = "macos_27_0"))]
172 {
173 unsafe { self.present_from_window_ch(window, Some(&mut block)) };
174 }
175 future.await
176 }
177
178 #[cfg(all(
179 feature = "blocks",
180 feature = "ui",
181 any(target_os = "ios", target_os = "tvos", target_os = "visionos")
182 ))]
183 #[objc::msg_send(presentFromWindowScene:completionHandler:)]
185 #[api::available(ios = 27.0, maccatalyst = 27.0, visionos = 27.0, tvos = 27.0)]
186 pub fn present_from_window_scene_ch(
187 &mut self,
188 window_scene: &ui::WindowScene,
189 handler: Option<&mut blocks::ErrCh>,
190 );
191
192 #[cfg(all(
193 feature = "blocks",
194 feature = "async",
195 feature = "ui",
196 any(target_os = "ios", target_os = "tvos", target_os = "visionos")
197 ))]
198 #[api::available(ios = 27.0, maccatalyst = 27.0, visionos = 27.0, tvos = 27.0)]
200 pub async fn present_from_window_scene(
201 &mut self,
202 window_scene: &ui::WindowScene,
203 ) -> Result<(), arc::R<ns::Error>> {
204 let (future, mut block) = blocks::ok();
205 unsafe { self.present_from_window_scene_ch(window_scene, Some(&mut block)) };
206 future.await
207 }
208
209 #[cfg(all(feature = "blocks", feature = "ui", target_os = "tvos"))]
210 #[objc::msg_send(presentFromWindowScene:mode:completionHandler:)]
212 #[api::available(tvos = 27.0)]
213 pub fn present_from_window_scene_mode_ch(
214 &mut self,
215 window_scene: &ui::WindowScene,
216 mode: Mode,
217 handler: Option<&mut blocks::ErrCh>,
218 );
219
220 #[cfg(all(
221 feature = "blocks",
222 feature = "async",
223 feature = "ui",
224 target_os = "tvos"
225 ))]
226 #[api::available(tvos = 27.0)]
228 pub async fn present_from_window_scene_mode(
229 &mut self,
230 window_scene: &ui::WindowScene,
231 mode: Mode,
232 ) -> Result<(), arc::R<ns::Error>> {
233 let (future, mut block) = blocks::ok();
234 unsafe { self.present_from_window_scene_mode_ch(window_scene, mode, Some(&mut block)) };
235 future.await
236 }
237}
238
239unsafe extern "C" {
240 static SC_RECORDING_EDITOR: &'static objc::Class<RecordingEditor>;
241}