objc2_av_foundation/generated/AVCaptureIndexPicker.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "dispatch2")]
6use dispatch2::*;
7use objc2::__framework_prelude::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13 /// An `AVCaptureControl` for selecting from a set of mutually exclusive values by index.
14 ///
15 ///
16 /// `AVCaptureIndexPicker` is ideal when the set of values is provided by an indexed container like `NSArray`, `Array`, or `Sequence`. Controls may be added to an `AVCaptureSession` using `-[AVCaptureSession addControl:]`.
17 ///
18 /// `AVCaptureIndexPicker` uses zero-based indexing.
19 ///
20 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptureindexpicker?language=objc)
21 #[unsafe(super(AVCaptureControl, NSObject))]
22 #[derive(Debug, PartialEq, Eq, Hash)]
23 #[cfg(feature = "AVCaptureControl")]
24 pub struct AVCaptureIndexPicker;
25);
26
27#[cfg(feature = "AVCaptureControl")]
28extern_conformance!(
29 unsafe impl NSObjectProtocol for AVCaptureIndexPicker {}
30);
31
32#[cfg(feature = "AVCaptureControl")]
33impl AVCaptureIndexPicker {
34 extern_methods!(
35 /// Initializes an `AVCaptureIndexPicker` to pick between `numberOfIndexes` values.
36 ///
37 ///
38 /// Parameter `localizedTitle`: A localized string that describes the picker's `action`.
39 ///
40 /// Parameter `symbolName`: The name of a symbol to represent the picker.
41 ///
42 /// Parameter `numberOfIndexes`: The number of indexes to pick between. `numberOfIndexes` must be greater than 0, otherwise an `NSInvalidArgumentException` is thrown.
43 ///
44 /// Returns: An `AVCaptureIndexPicker` instance that picks between `numberOfIndexes` values.
45 ///
46 ///
47 /// Suitable when your picked values don't need titles.
48 #[unsafe(method(initWithLocalizedTitle:symbolName:numberOfIndexes:))]
49 #[unsafe(method_family = init)]
50 pub unsafe fn initWithLocalizedTitle_symbolName_numberOfIndexes(
51 this: Allocated<Self>,
52 localized_title: &NSString,
53 symbol_name: &NSString,
54 number_of_indexes: NSInteger,
55 ) -> Retained<Self>;
56
57 #[cfg(feature = "block2")]
58 /// Initializes an `AVCaptureIndexPicker` to pick between `numberOfIndexes` values.
59 ///
60 ///
61 /// Parameter `localizedTitle`: A localized string that describes the picker's `action`.
62 ///
63 /// Parameter `symbolName`: The name of a symbol to represent the picker.
64 ///
65 /// Parameter `numberOfIndexes`: The number of indexes to pick between. `numberOfIndexes` must be greater than 0, otherwise an `NSInvalidArgumentException` is thrown.
66 ///
67 /// Parameter `localizedTitleTransform`: A transformation from index to localized title.
68 ///
69 /// Returns: An `AVCaptureIndexPicker` instance that picks between `numberOfIndexes` values with a transformation from index to localized title.
70 ///
71 ///
72 /// Suitable when you want to provide a title for each picked value lazily.
73 ///
74 /// # Safety
75 ///
76 /// `localized_title_transform` block's return must be a valid pointer.
77 #[unsafe(method(initWithLocalizedTitle:symbolName:numberOfIndexes:localizedTitleTransform:))]
78 #[unsafe(method_family = init)]
79 pub unsafe fn initWithLocalizedTitle_symbolName_numberOfIndexes_localizedTitleTransform(
80 this: Allocated<Self>,
81 localized_title: &NSString,
82 symbol_name: &NSString,
83 number_of_indexes: NSInteger,
84 localized_title_transform: &block2::DynBlock<
85 dyn Fn(NSInteger) -> NonNull<NSString> + '_,
86 >,
87 ) -> Retained<Self>;
88
89 /// Initializes an `AVCaptureIndexPicker` to pick between `localizedIndexTitles.count` values.
90 ///
91 ///
92 /// Parameter `localizedTitle`: A localized string that describes the picker's `action`.
93 ///
94 /// Parameter `symbolName`: The name of a symbol to represent the picker.
95 ///
96 /// Parameter `localizedIndexTitles`: The titles to use for each index. `localizedIndexTitles` must be greater than 0, otherwise an `NSInvalidArgumentException` is thrown.
97 ///
98 /// Returns: An `AVCaptureIndexPicker` instance that picks between `localizedIndexTitles.count` values.
99 ///
100 ///
101 /// Suitable when you already have an array containing a title for each picked value.
102 #[unsafe(method(initWithLocalizedTitle:symbolName:localizedIndexTitles:))]
103 #[unsafe(method_family = init)]
104 pub unsafe fn initWithLocalizedTitle_symbolName_localizedIndexTitles(
105 this: Allocated<Self>,
106 localized_title: &NSString,
107 symbol_name: &NSString,
108 localized_index_titles: &NSArray<NSString>,
109 ) -> Retained<Self>;
110
111 /// The currently selected index.
112 ///
113 ///
114 /// Because the camera system may be independent from the main thread or `
115 /// MainThreadOnly`, `selectedIndex` must be changed on `actionQueue` – the queue provided to `setActionQueue:action:`. The default value is 0. An index may only be set if it is greater than 0 or less than `numberOfIndexes`, otherwise an `NSInvalidArgumentException` is thrown.
116 #[unsafe(method(selectedIndex))]
117 #[unsafe(method_family = none)]
118 pub unsafe fn selectedIndex(&self) -> NSInteger;
119
120 /// Setter for [`selectedIndex`][Self::selectedIndex].
121 #[unsafe(method(setSelectedIndex:))]
122 #[unsafe(method_family = none)]
123 pub unsafe fn setSelectedIndex(&self, selected_index: NSInteger);
124
125 /// A localized string that describes the picker's `action`.
126 #[unsafe(method(localizedTitle))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn localizedTitle(&self) -> Retained<NSString>;
129
130 /// The name of a symbol to represent the picker.
131 #[unsafe(method(symbolName))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn symbolName(&self) -> Retained<NSString>;
134
135 /// The number of indexes to pick between.
136 #[unsafe(method(numberOfIndexes))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn numberOfIndexes(&self) -> NSInteger;
139
140 /// The titles used for each index.
141 #[unsafe(method(localizedIndexTitles))]
142 #[unsafe(method_family = none)]
143 pub unsafe fn localizedIndexTitles(&self) -> Retained<NSArray<NSString>>;
144
145 /// A string that identifies the picker.
146 #[unsafe(method(accessibilityIdentifier))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn accessibilityIdentifier(&self) -> Option<Retained<NSString>>;
149
150 /// Setter for [`accessibilityIdentifier`][Self::accessibilityIdentifier].
151 ///
152 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
153 #[unsafe(method(setAccessibilityIdentifier:))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn setAccessibilityIdentifier(
156 &self,
157 accessibility_identifier: Option<&NSString>,
158 );
159
160 #[cfg(all(feature = "block2", feature = "dispatch2"))]
161 /// Configures the picker's `action` which is called on `actionQueue` whenever the index of the picker is changed.
162 ///
163 ///
164 /// Parameter `actionQueue`: A queue for the `action` to be called.
165 ///
166 /// Parameter `action`: An action called on `actionQueue` whenever the selected index of the picker is changed.
167 ///
168 ///
169 /// Because the camera system may be independent from the main thread or `
170 /// MainThreadOnly`, `action` is always called on an internal `DispatchSerialQueue` targeted at `actionQueue`.
171 ///
172 /// If `action` modifies a property of the camera system, `actionQueue` must represent the same exclusive execution context as the camera system (see `isSameExclusiveExecutionContext`).
173 ///
174 /// # Safety
175 ///
176 /// `action_queue` possibly has additional threading requirements.
177 #[unsafe(method(setActionQueue:action:))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn setActionQueue_action(
180 &self,
181 action_queue: &DispatchQueue,
182 action: &block2::DynBlock<dyn Fn(NSInteger)>,
183 );
184 );
185}
186
187/// Methods declared on superclass `AVCaptureControl`.
188#[cfg(feature = "AVCaptureControl")]
189impl AVCaptureIndexPicker {
190 extern_methods!(
191 #[unsafe(method(init))]
192 #[unsafe(method_family = init)]
193 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
194
195 #[unsafe(method(new))]
196 #[unsafe(method_family = new)]
197 pub unsafe fn new() -> Retained<Self>;
198 );
199}