1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct UIImagePickerControllerSourceType(pub NSInteger);
17impl UIImagePickerControllerSourceType {
18 #[deprecated = "Will be removed in a future release, use PHPicker."]
19 #[doc(alias = "UIImagePickerControllerSourceTypePhotoLibrary")]
20 pub const PhotoLibrary: Self = Self(0);
21 #[doc(alias = "UIImagePickerControllerSourceTypeCamera")]
22 pub const Camera: Self = Self(1);
23 #[deprecated = "Will be removed in a future release, use PHPicker."]
24 #[doc(alias = "UIImagePickerControllerSourceTypeSavedPhotosAlbum")]
25 pub const SavedPhotosAlbum: Self = Self(2);
26}
27
28unsafe impl Encode for UIImagePickerControllerSourceType {
29 const ENCODING: Encoding = NSInteger::ENCODING;
30}
31
32unsafe impl RefEncode for UIImagePickerControllerSourceType {
33 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36#[repr(transparent)]
39#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
40pub struct UIImagePickerControllerQualityType(pub NSInteger);
41impl UIImagePickerControllerQualityType {
42 #[doc(alias = "UIImagePickerControllerQualityTypeHigh")]
43 pub const TypeHigh: Self = Self(0);
44 #[doc(alias = "UIImagePickerControllerQualityTypeMedium")]
45 pub const TypeMedium: Self = Self(1);
46 #[doc(alias = "UIImagePickerControllerQualityTypeLow")]
47 pub const TypeLow: Self = Self(2);
48 #[doc(alias = "UIImagePickerControllerQualityType640x480")]
49 pub const Type640x480: Self = Self(3);
50 #[doc(alias = "UIImagePickerControllerQualityTypeIFrame1280x720")]
51 pub const TypeIFrame1280x720: Self = Self(4);
52 #[doc(alias = "UIImagePickerControllerQualityTypeIFrame960x540")]
53 pub const TypeIFrame960x540: Self = Self(5);
54}
55
56unsafe impl Encode for UIImagePickerControllerQualityType {
57 const ENCODING: Encoding = NSInteger::ENCODING;
58}
59
60unsafe impl RefEncode for UIImagePickerControllerQualityType {
61 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64#[repr(transparent)]
67#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
68pub struct UIImagePickerControllerCameraCaptureMode(pub NSInteger);
69impl UIImagePickerControllerCameraCaptureMode {
70 #[doc(alias = "UIImagePickerControllerCameraCaptureModePhoto")]
71 pub const Photo: Self = Self(0);
72 #[doc(alias = "UIImagePickerControllerCameraCaptureModeVideo")]
73 pub const Video: Self = Self(1);
74}
75
76unsafe impl Encode for UIImagePickerControllerCameraCaptureMode {
77 const ENCODING: Encoding = NSInteger::ENCODING;
78}
79
80unsafe impl RefEncode for UIImagePickerControllerCameraCaptureMode {
81 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
82}
83
84#[repr(transparent)]
87#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
88pub struct UIImagePickerControllerCameraDevice(pub NSInteger);
89impl UIImagePickerControllerCameraDevice {
90 #[doc(alias = "UIImagePickerControllerCameraDeviceRear")]
91 pub const Rear: Self = Self(0);
92 #[doc(alias = "UIImagePickerControllerCameraDeviceFront")]
93 pub const Front: Self = Self(1);
94}
95
96unsafe impl Encode for UIImagePickerControllerCameraDevice {
97 const ENCODING: Encoding = NSInteger::ENCODING;
98}
99
100unsafe impl RefEncode for UIImagePickerControllerCameraDevice {
101 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
102}
103
104#[repr(transparent)]
107#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
108pub struct UIImagePickerControllerCameraFlashMode(pub NSInteger);
109impl UIImagePickerControllerCameraFlashMode {
110 #[doc(alias = "UIImagePickerControllerCameraFlashModeOff")]
111 pub const Off: Self = Self(-1);
112 #[doc(alias = "UIImagePickerControllerCameraFlashModeAuto")]
113 pub const Auto: Self = Self(0);
114 #[doc(alias = "UIImagePickerControllerCameraFlashModeOn")]
115 pub const On: Self = Self(1);
116}
117
118unsafe impl Encode for UIImagePickerControllerCameraFlashMode {
119 const ENCODING: Encoding = NSInteger::ENCODING;
120}
121
122unsafe impl RefEncode for UIImagePickerControllerCameraFlashMode {
123 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
124}
125
126#[deprecated = "Will be removed in a future release, use PHPicker."]
129#[repr(transparent)]
130#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
131pub struct UIImagePickerControllerImageURLExportPreset(pub NSInteger);
132impl UIImagePickerControllerImageURLExportPreset {
133 #[deprecated = "Will be removed in a future release, use PHPicker."]
134 #[doc(alias = "UIImagePickerControllerImageURLExportPresetCompatible")]
135 pub const Compatible: Self = Self(0);
136 #[deprecated = "Will be removed in a future release, use PHPicker."]
137 #[doc(alias = "UIImagePickerControllerImageURLExportPresetCurrent")]
138 pub const Current: Self = Self(1);
139}
140
141unsafe impl Encode for UIImagePickerControllerImageURLExportPreset {
142 const ENCODING: Encoding = NSInteger::ENCODING;
143}
144
145unsafe impl RefEncode for UIImagePickerControllerImageURLExportPreset {
146 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
147}
148
149pub type UIImagePickerControllerInfoKey = NSString;
152
153extern "C" {
154 pub static UIImagePickerControllerMediaType: &'static UIImagePickerControllerInfoKey;
156}
157
158extern "C" {
159 pub static UIImagePickerControllerOriginalImage: &'static UIImagePickerControllerInfoKey;
161}
162
163extern "C" {
164 pub static UIImagePickerControllerEditedImage: &'static UIImagePickerControllerInfoKey;
166}
167
168extern "C" {
169 pub static UIImagePickerControllerCropRect: &'static UIImagePickerControllerInfoKey;
171}
172
173extern "C" {
174 pub static UIImagePickerControllerMediaURL: &'static UIImagePickerControllerInfoKey;
176}
177
178extern "C" {
179 pub static UIImagePickerControllerReferenceURL: &'static UIImagePickerControllerInfoKey;
181}
182
183extern "C" {
184 pub static UIImagePickerControllerMediaMetadata: &'static UIImagePickerControllerInfoKey;
186}
187
188extern "C" {
189 pub static UIImagePickerControllerLivePhoto: &'static UIImagePickerControllerInfoKey;
191}
192
193extern "C" {
194 pub static UIImagePickerControllerPHAsset: &'static UIImagePickerControllerInfoKey;
196}
197
198extern "C" {
199 pub static UIImagePickerControllerImageURL: &'static UIImagePickerControllerInfoKey;
201}
202
203extern_class!(
204 #[unsafe(super(UINavigationController, UIViewController, UIResponder, NSObject))]
206 #[thread_kind = MainThreadOnly]
207 #[derive(Debug, PartialEq, Eq, Hash)]
208 #[cfg(all(
209 feature = "UINavigationController",
210 feature = "UIResponder",
211 feature = "UIViewController"
212 ))]
213 pub struct UIImagePickerController;
214);
215
216#[cfg(all(
217 feature = "UINavigationController",
218 feature = "UIResponder",
219 feature = "UIViewController"
220))]
221unsafe impl NSCoding for UIImagePickerController {}
222
223#[cfg(all(
224 feature = "UINavigationController",
225 feature = "UIResponder",
226 feature = "UIViewController"
227))]
228unsafe impl NSObjectProtocol for UIImagePickerController {}
229
230#[cfg(all(
231 feature = "UIAppearance",
232 feature = "UINavigationController",
233 feature = "UIResponder",
234 feature = "UIViewController"
235))]
236unsafe impl UIAppearanceContainer for UIImagePickerController {}
237
238#[cfg(all(
239 feature = "UINavigationController",
240 feature = "UIResponder",
241 feature = "UIViewController"
242))]
243unsafe impl UIContentContainer for UIImagePickerController {}
244
245#[cfg(all(
246 feature = "UIFocus",
247 feature = "UINavigationController",
248 feature = "UIResponder",
249 feature = "UIViewController"
250))]
251unsafe impl UIFocusEnvironment for UIImagePickerController {}
252
253#[cfg(all(
254 feature = "UINavigationController",
255 feature = "UIResponder",
256 feature = "UIViewController"
257))]
258unsafe impl UIResponderStandardEditActions for UIImagePickerController {}
259
260#[cfg(all(
261 feature = "UINavigationController",
262 feature = "UIResponder",
263 feature = "UITraitCollection",
264 feature = "UIViewController"
265))]
266unsafe impl UITraitEnvironment for UIImagePickerController {}
267
268#[cfg(all(
269 feature = "UINavigationController",
270 feature = "UIResponder",
271 feature = "UIViewController"
272))]
273impl UIImagePickerController {
274 extern_methods!(
275 #[unsafe(method(isSourceTypeAvailable:))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn isSourceTypeAvailable(
278 source_type: UIImagePickerControllerSourceType,
279 mtm: MainThreadMarker,
280 ) -> bool;
281
282 #[unsafe(method(availableMediaTypesForSourceType:))]
283 #[unsafe(method_family = none)]
284 pub unsafe fn availableMediaTypesForSourceType(
285 source_type: UIImagePickerControllerSourceType,
286 mtm: MainThreadMarker,
287 ) -> Option<Retained<NSArray<NSString>>>;
288
289 #[unsafe(method(isCameraDeviceAvailable:))]
290 #[unsafe(method_family = none)]
291 pub unsafe fn isCameraDeviceAvailable(
292 camera_device: UIImagePickerControllerCameraDevice,
293 mtm: MainThreadMarker,
294 ) -> bool;
295
296 #[unsafe(method(isFlashAvailableForCameraDevice:))]
297 #[unsafe(method_family = none)]
298 pub unsafe fn isFlashAvailableForCameraDevice(
299 camera_device: UIImagePickerControllerCameraDevice,
300 mtm: MainThreadMarker,
301 ) -> bool;
302
303 #[unsafe(method(availableCaptureModesForCameraDevice:))]
304 #[unsafe(method_family = none)]
305 pub unsafe fn availableCaptureModesForCameraDevice(
306 camera_device: UIImagePickerControllerCameraDevice,
307 mtm: MainThreadMarker,
308 ) -> Option<Retained<NSArray<NSNumber>>>;
309
310 #[unsafe(method(delegate))]
311 #[unsafe(method_family = none)]
312 pub unsafe fn delegate(
313 &self,
314 ) -> Option<
315 Retained<
316 AnyObject, >,
318 >;
319
320 #[unsafe(method(setDelegate:))]
323 #[unsafe(method_family = none)]
324 pub unsafe fn setDelegate(
325 &self,
326 delegate: Option<
327 &AnyObject, >,
329 );
330
331 #[unsafe(method(sourceType))]
332 #[unsafe(method_family = none)]
333 pub unsafe fn sourceType(&self) -> UIImagePickerControllerSourceType;
334
335 #[unsafe(method(setSourceType:))]
337 #[unsafe(method_family = none)]
338 pub unsafe fn setSourceType(&self, source_type: UIImagePickerControllerSourceType);
339
340 #[unsafe(method(mediaTypes))]
341 #[unsafe(method_family = none)]
342 pub unsafe fn mediaTypes(&self) -> Retained<NSArray<NSString>>;
343
344 #[unsafe(method(setMediaTypes:))]
346 #[unsafe(method_family = none)]
347 pub unsafe fn setMediaTypes(&self, media_types: &NSArray<NSString>);
348
349 #[unsafe(method(allowsEditing))]
350 #[unsafe(method_family = none)]
351 pub unsafe fn allowsEditing(&self) -> bool;
352
353 #[unsafe(method(setAllowsEditing:))]
355 #[unsafe(method_family = none)]
356 pub unsafe fn setAllowsEditing(&self, allows_editing: bool);
357
358 #[deprecated]
359 #[unsafe(method(allowsImageEditing))]
360 #[unsafe(method_family = none)]
361 pub unsafe fn allowsImageEditing(&self) -> bool;
362
363 #[deprecated]
365 #[unsafe(method(setAllowsImageEditing:))]
366 #[unsafe(method_family = none)]
367 pub unsafe fn setAllowsImageEditing(&self, allows_image_editing: bool);
368
369 #[deprecated = "Will be removed in a future release, use PHPicker."]
370 #[unsafe(method(imageExportPreset))]
371 #[unsafe(method_family = none)]
372 pub unsafe fn imageExportPreset(&self) -> UIImagePickerControllerImageURLExportPreset;
373
374 #[deprecated = "Will be removed in a future release, use PHPicker."]
376 #[unsafe(method(setImageExportPreset:))]
377 #[unsafe(method_family = none)]
378 pub unsafe fn setImageExportPreset(
379 &self,
380 image_export_preset: UIImagePickerControllerImageURLExportPreset,
381 );
382
383 #[unsafe(method(videoMaximumDuration))]
384 #[unsafe(method_family = none)]
385 pub unsafe fn videoMaximumDuration(&self) -> NSTimeInterval;
386
387 #[unsafe(method(setVideoMaximumDuration:))]
389 #[unsafe(method_family = none)]
390 pub unsafe fn setVideoMaximumDuration(&self, video_maximum_duration: NSTimeInterval);
391
392 #[unsafe(method(videoQuality))]
393 #[unsafe(method_family = none)]
394 pub unsafe fn videoQuality(&self) -> UIImagePickerControllerQualityType;
395
396 #[unsafe(method(setVideoQuality:))]
398 #[unsafe(method_family = none)]
399 pub unsafe fn setVideoQuality(&self, video_quality: UIImagePickerControllerQualityType);
400
401 #[deprecated = "Will be removed in a future release, use PHPicker."]
402 #[unsafe(method(videoExportPreset))]
403 #[unsafe(method_family = none)]
404 pub unsafe fn videoExportPreset(&self) -> Retained<NSString>;
405
406 #[deprecated = "Will be removed in a future release, use PHPicker."]
408 #[unsafe(method(setVideoExportPreset:))]
409 #[unsafe(method_family = none)]
410 pub unsafe fn setVideoExportPreset(&self, video_export_preset: &NSString);
411
412 #[unsafe(method(showsCameraControls))]
413 #[unsafe(method_family = none)]
414 pub unsafe fn showsCameraControls(&self) -> bool;
415
416 #[unsafe(method(setShowsCameraControls:))]
418 #[unsafe(method_family = none)]
419 pub unsafe fn setShowsCameraControls(&self, shows_camera_controls: bool);
420
421 #[cfg(feature = "UIView")]
422 #[unsafe(method(cameraOverlayView))]
423 #[unsafe(method_family = none)]
424 pub unsafe fn cameraOverlayView(&self) -> Option<Retained<UIView>>;
425
426 #[cfg(feature = "UIView")]
427 #[unsafe(method(setCameraOverlayView:))]
429 #[unsafe(method_family = none)]
430 pub unsafe fn setCameraOverlayView(&self, camera_overlay_view: Option<&UIView>);
431
432 #[cfg(feature = "objc2-core-foundation")]
433 #[unsafe(method(cameraViewTransform))]
434 #[unsafe(method_family = none)]
435 pub unsafe fn cameraViewTransform(&self) -> CGAffineTransform;
436
437 #[cfg(feature = "objc2-core-foundation")]
438 #[unsafe(method(setCameraViewTransform:))]
440 #[unsafe(method_family = none)]
441 pub unsafe fn setCameraViewTransform(&self, camera_view_transform: CGAffineTransform);
442
443 #[unsafe(method(takePicture))]
444 #[unsafe(method_family = none)]
445 pub unsafe fn takePicture(&self);
446
447 #[unsafe(method(startVideoCapture))]
448 #[unsafe(method_family = none)]
449 pub unsafe fn startVideoCapture(&self) -> bool;
450
451 #[unsafe(method(stopVideoCapture))]
452 #[unsafe(method_family = none)]
453 pub unsafe fn stopVideoCapture(&self);
454
455 #[unsafe(method(cameraCaptureMode))]
456 #[unsafe(method_family = none)]
457 pub unsafe fn cameraCaptureMode(&self) -> UIImagePickerControllerCameraCaptureMode;
458
459 #[unsafe(method(setCameraCaptureMode:))]
461 #[unsafe(method_family = none)]
462 pub unsafe fn setCameraCaptureMode(
463 &self,
464 camera_capture_mode: UIImagePickerControllerCameraCaptureMode,
465 );
466
467 #[unsafe(method(cameraDevice))]
468 #[unsafe(method_family = none)]
469 pub unsafe fn cameraDevice(&self) -> UIImagePickerControllerCameraDevice;
470
471 #[unsafe(method(setCameraDevice:))]
473 #[unsafe(method_family = none)]
474 pub unsafe fn setCameraDevice(&self, camera_device: UIImagePickerControllerCameraDevice);
475
476 #[unsafe(method(cameraFlashMode))]
477 #[unsafe(method_family = none)]
478 pub unsafe fn cameraFlashMode(&self) -> UIImagePickerControllerCameraFlashMode;
479
480 #[unsafe(method(setCameraFlashMode:))]
482 #[unsafe(method_family = none)]
483 pub unsafe fn setCameraFlashMode(
484 &self,
485 camera_flash_mode: UIImagePickerControllerCameraFlashMode,
486 );
487 );
488}
489
490#[cfg(all(
492 feature = "UINavigationController",
493 feature = "UIResponder",
494 feature = "UIViewController"
495))]
496impl UIImagePickerController {
497 extern_methods!(
498 #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
499 #[unsafe(method_family = init)]
500 pub unsafe fn initWithNavigationBarClass_toolbarClass(
501 this: Allocated<Self>,
502 navigation_bar_class: Option<&AnyClass>,
503 toolbar_class: Option<&AnyClass>,
504 ) -> Retained<Self>;
505
506 #[unsafe(method(initWithRootViewController:))]
507 #[unsafe(method_family = init)]
508 pub unsafe fn initWithRootViewController(
509 this: Allocated<Self>,
510 root_view_controller: &UIViewController,
511 ) -> Retained<Self>;
512
513 #[unsafe(method(initWithNibName:bundle:))]
514 #[unsafe(method_family = init)]
515 pub unsafe fn initWithNibName_bundle(
516 this: Allocated<Self>,
517 nib_name_or_nil: Option<&NSString>,
518 nib_bundle_or_nil: Option<&NSBundle>,
519 ) -> Retained<Self>;
520
521 #[unsafe(method(initWithCoder:))]
522 #[unsafe(method_family = init)]
523 pub unsafe fn initWithCoder(
524 this: Allocated<Self>,
525 a_decoder: &NSCoder,
526 ) -> Option<Retained<Self>>;
527 );
528}
529
530#[cfg(all(
532 feature = "UINavigationController",
533 feature = "UIResponder",
534 feature = "UIViewController"
535))]
536impl UIImagePickerController {
537 extern_methods!(
538 #[unsafe(method(init))]
539 #[unsafe(method_family = init)]
540 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
541
542 #[unsafe(method(new))]
543 #[unsafe(method_family = new)]
544 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
545 );
546}
547
548extern_protocol!(
549 pub unsafe trait UIImagePickerControllerDelegate:
551 NSObjectProtocol + MainThreadOnly
552 {
553 #[cfg(all(
554 feature = "UIImage",
555 feature = "UINavigationController",
556 feature = "UIResponder",
557 feature = "UIViewController"
558 ))]
559 #[deprecated]
560 #[optional]
561 #[unsafe(method(imagePickerController:didFinishPickingImage:editingInfo:))]
562 #[unsafe(method_family = none)]
563 unsafe fn imagePickerController_didFinishPickingImage_editingInfo(
564 &self,
565 picker: &UIImagePickerController,
566 image: &UIImage,
567 editing_info: Option<&NSDictionary<UIImagePickerControllerInfoKey, AnyObject>>,
568 );
569
570 #[cfg(all(
571 feature = "UINavigationController",
572 feature = "UIResponder",
573 feature = "UIViewController"
574 ))]
575 #[optional]
576 #[unsafe(method(imagePickerController:didFinishPickingMediaWithInfo:))]
577 #[unsafe(method_family = none)]
578 unsafe fn imagePickerController_didFinishPickingMediaWithInfo(
579 &self,
580 picker: &UIImagePickerController,
581 info: &NSDictionary<UIImagePickerControllerInfoKey, AnyObject>,
582 );
583
584 #[cfg(all(
585 feature = "UINavigationController",
586 feature = "UIResponder",
587 feature = "UIViewController"
588 ))]
589 #[optional]
590 #[unsafe(method(imagePickerControllerDidCancel:))]
591 #[unsafe(method_family = none)]
592 unsafe fn imagePickerControllerDidCancel(&self, picker: &UIImagePickerController);
593 }
594);
595
596extern "C-unwind" {
597 #[cfg(feature = "UIImage")]
598 pub fn UIImageWriteToSavedPhotosAlbum(
599 image: &UIImage,
600 completion_target: Option<&AnyObject>,
601 completion_selector: Option<Sel>,
602 context_info: *mut c_void,
603 );
604}
605
606#[inline]
607pub unsafe extern "C-unwind" fn UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(
608 video_path: &NSString,
609) -> bool {
610 extern "C-unwind" {
611 fn UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(video_path: &NSString) -> Bool;
612 }
613 unsafe { UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(video_path) }.as_bool()
614}
615
616extern "C-unwind" {
617 pub fn UISaveVideoAtPathToSavedPhotosAlbum(
618 video_path: &NSString,
619 completion_target: Option<&AnyObject>,
620 completion_selector: Option<Sel>,
621 context_info: *mut c_void,
622 );
623}