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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
/// SCContentSharingPickerModeSingleWindow picker mode for single window selection
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/sccontentsharingpickermode?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SCContentSharingPickerMode(pub NSUInteger);
bitflags::bitflags! {
impl SCContentSharingPickerMode: NSUInteger {
#[doc(alias = "SCContentSharingPickerModeSingleWindow")]
const SingleWindow = 1<<0;
#[doc(alias = "SCContentSharingPickerModeMultipleWindows")]
const MultipleWindows = 1<<1;
#[doc(alias = "SCContentSharingPickerModeSingleApplication")]
const SingleApplication = 1<<2;
#[doc(alias = "SCContentSharingPickerModeMultipleApplications")]
const MultipleApplications = 1<<3;
#[doc(alias = "SCContentSharingPickerModeSingleDisplay")]
const SingleDisplay = 1<<4;
}
}
unsafe impl Encode for SCContentSharingPickerMode {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for SCContentSharingPickerMode {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// SCContentSharingPickerConfiguration
///
/// SCContentSharingPickerConfiguration is an object which can optionally be set on the SCContentSharingPicker for customized configuration.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/sccontentsharingpickerconfiguration?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct SCContentSharingPickerConfiguration<NSCopying: ?Sized = AnyObject>;
);
impl<NSCopying: ?Sized + Message> SCContentSharingPickerConfiguration<NSCopying> {
/// Unchecked conversion of the generic parameter.
///
/// # Safety
///
/// The generic must be valid to reinterpret as the given type.
#[inline]
pub unsafe fn cast_unchecked<NewNSCopying: ?Sized + Message>(
&self,
) -> &SCContentSharingPickerConfiguration<NewNSCopying> {
unsafe { &*((self as *const Self).cast()) }
}
}
extern_conformance!(
unsafe impl<NSCopying: ?Sized> NSObjectProtocol for SCContentSharingPickerConfiguration<NSCopying> {}
);
impl<NSCopying: Message> SCContentSharingPickerConfiguration<NSCopying> {
extern_methods!(
/// allowedPickerModes Limits the type of selections available to the user when the picker is presented. Default is 0, no excluded picking modes
#[unsafe(method(allowedPickerModes))]
#[unsafe(method_family = none)]
pub unsafe fn allowedPickerModes(&self) -> SCContentSharingPickerMode;
/// Setter for [`allowedPickerModes`][Self::allowedPickerModes].
#[unsafe(method(setAllowedPickerModes:))]
#[unsafe(method_family = none)]
pub unsafe fn setAllowedPickerModes(
&self,
allowed_picker_modes: SCContentSharingPickerMode,
);
/// excludedWindowIDs Excludes CGWindowIDs for picking
#[unsafe(method(excludedWindowIDs))]
#[unsafe(method_family = none)]
pub unsafe fn excludedWindowIDs(&self) -> Retained<NSArray<NSNumber>>;
/// Setter for [`excludedWindowIDs`][Self::excludedWindowIDs].
#[unsafe(method(setExcludedWindowIDs:))]
#[unsafe(method_family = none)]
pub unsafe fn setExcludedWindowIDs(&self, excluded_window_i_ds: &NSArray<NSNumber>);
/// excludedBundleIDs Excludes bundle IDs for picking
#[unsafe(method(excludedBundleIDs))]
#[unsafe(method_family = none)]
pub unsafe fn excludedBundleIDs(&self) -> Retained<NSArray<NSString>>;
/// Setter for [`excludedBundleIDs`][Self::excludedBundleIDs].
#[unsafe(method(setExcludedBundleIDs:))]
#[unsafe(method_family = none)]
pub unsafe fn setExcludedBundleIDs(&self, excluded_bundle_i_ds: &NSArray<NSString>);
/// allowsChangingSelectedContent Controls if the user can make updates to the content filter after the initial selection. Defaults is YES.
#[unsafe(method(allowsChangingSelectedContent))]
#[unsafe(method_family = none)]
pub unsafe fn allowsChangingSelectedContent(&self) -> bool;
/// Setter for [`allowsChangingSelectedContent`][Self::allowsChangingSelectedContent].
#[unsafe(method(setAllowsChangingSelectedContent:))]
#[unsafe(method_family = none)]
pub unsafe fn setAllowsChangingSelectedContent(
&self,
allows_changing_selected_content: bool,
);
);
}
/// Methods declared on superclass `NSObject`.
impl<NSCopying: Message> SCContentSharingPickerConfiguration<NSCopying> {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// SCContentSharingPicker
///
/// SCContentSharingPicker is an object created by client applications to opt-in to Control Center's content picker
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/sccontentsharingpicker?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct SCContentSharingPicker;
);
extern_conformance!(
unsafe impl NSObjectProtocol for SCContentSharingPicker {}
);
impl SCContentSharingPicker {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
/// sharedPicker the singleton shared picker for the application
#[unsafe(method(sharedPicker))]
#[unsafe(method_family = none)]
pub unsafe fn sharedPicker() -> Retained<SCContentSharingPicker>;
/// defaultConfiguration for the content sharing picker. If a stream does not have a configuration, the default configuration will be used.
#[unsafe(method(defaultConfiguration))]
#[unsafe(method_family = none)]
pub unsafe fn defaultConfiguration(&self) -> Retained<SCContentSharingPickerConfiguration>;
/// Setter for [`defaultConfiguration`][Self::defaultConfiguration].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
///
/// # Safety
///
/// `default_configuration` generic should be of the correct type.
#[unsafe(method(setDefaultConfiguration:))]
#[unsafe(method_family = none)]
pub unsafe fn setDefaultConfiguration(
&self,
default_configuration: &SCContentSharingPickerConfiguration,
);
/// maximumStreamCount An integer value that, if set, limits when Control Center will show the UI to present a picker with no associated stream. If set to 0, Control Center will never ever show UI to present a picker without an associated stream.
#[unsafe(method(maximumStreamCount))]
#[unsafe(method_family = none)]
pub unsafe fn maximumStreamCount(&self) -> Option<Retained<NSNumber>>;
/// Setter for [`maximumStreamCount`][Self::maximumStreamCount].
#[unsafe(method(setMaximumStreamCount:))]
#[unsafe(method_family = none)]
pub unsafe fn setMaximumStreamCount(&self, maximum_stream_count: Option<&NSNumber>);
/// active A picker needs to be marked as active for its UI to appear. If `startPickingContent` is called and the picker is not marked as active, the picker will not appear.
#[unsafe(method(isActive))]
#[unsafe(method_family = none)]
pub unsafe fn isActive(&self) -> bool;
/// Setter for [`isActive`][Self::isActive].
#[unsafe(method(setActive:))]
#[unsafe(method_family = none)]
pub unsafe fn setActive(&self, active: bool);
/// addObserver:
///
/// Parameter `observer`: the observer object that adheres to SCContentSharingPickerObserver protocol
///
/// Adds an observer object that will receive the results of user interaction with a displayed picker
#[unsafe(method(addObserver:))]
#[unsafe(method_family = none)]
pub unsafe fn addObserver(
&self,
observer: &ProtocolObject<dyn SCContentSharingPickerObserver>,
);
/// removeObserver:
///
/// Parameter `observer`: the observer object that adheres to SCContentSharingPickerObserver protocol
///
/// Removes an observer object that will receive the results of user interaction with a displayed picker
#[unsafe(method(removeObserver:))]
#[unsafe(method_family = none)]
pub unsafe fn removeObserver(
&self,
observer: &ProtocolObject<dyn SCContentSharingPickerObserver>,
);
#[cfg(feature = "SCStream")]
/// setConfiguration:forStream:
///
/// Parameter `pickerConfig`: configuration for the picker
///
/// Parameter `stream`: stream for optional picking configuration
///
/// Sets optional configuration for the picker for a specific stream. If this is not set, the stream will use the defaultConfiguration instead
///
/// # Safety
///
/// `picker_config` generic should be of the correct type.
#[unsafe(method(setConfiguration:forStream:))]
#[unsafe(method_family = none)]
pub unsafe fn setConfiguration_forStream(
&self,
picker_config: Option<&SCContentSharingPickerConfiguration>,
stream: &SCStream,
);
/// present
///
/// show content sharing picker to get content for updating a new stream
#[unsafe(method(present))]
#[unsafe(method_family = none)]
pub unsafe fn present(&self);
#[cfg(feature = "SCShareableContent")]
/// presentPickerUsingContentStyle:
///
/// Parameter `contentStyle`: the mode in which picking should start
///
/// Takes a person straight into picking particular windows or displays
#[unsafe(method(presentPickerUsingContentStyle:))]
#[unsafe(method_family = none)]
pub unsafe fn presentPickerUsingContentStyle(&self, content_style: SCShareableContentStyle);
#[cfg(feature = "SCStream")]
/// presentPickerForStream:
///
/// Parameter `stream`: the stream to update
///
/// show content sharing picker with an existing stream
#[unsafe(method(presentPickerForStream:))]
#[unsafe(method_family = none)]
pub unsafe fn presentPickerForStream(&self, stream: &SCStream);
#[cfg(all(feature = "SCShareableContent", feature = "SCStream"))]
/// presentPickerForStream:usingContentStyle:
///
/// Parameter `stream`: the stream that the picker will display
///
/// Parameter `contentStyle`: the mode in which picking should start
///
/// Takes a person straight into picking particular windows or displays
#[unsafe(method(presentPickerForStream:usingContentStyle:))]
#[unsafe(method_family = none)]
pub unsafe fn presentPickerForStream_usingContentStyle(
&self,
stream: &SCStream,
content_style: SCShareableContentStyle,
);
);
}
extern_protocol!(
/// SCContentSharingPickerObserver
///
/// SCContentSharingPickerObserver the protocol that is used to inform client when the picker did make selection or cancel
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/sccontentsharingpickerobserver?language=objc)
pub unsafe trait SCContentSharingPickerObserver: NSObjectProtocol {
#[cfg(feature = "SCStream")]
/// contentSharingPicker:didCancelforStream:
///
/// Parameter `picker`: the SCContentSharingPicker object
///
/// Parameter `stream`: the optional associated stream for this picker
///
/// the observer callback method when the picker has been canceled with no selection.
#[unsafe(method(contentSharingPicker:didCancelForStream:))]
#[unsafe(method_family = none)]
unsafe fn contentSharingPicker_didCancelForStream(
&self,
picker: &SCContentSharingPicker,
stream: Option<&SCStream>,
);
#[cfg(feature = "SCStream")]
/// contentSharingPicker:didUpdateWithFilter:forStream:
///
/// Parameter `picker`: the SCContentSharingPicker object
///
/// Parameter `filter`: the updated filter
///
/// Parameter `stream`: the updated stream
///
/// the observer callback method when the user has finished updating content for a stream
#[unsafe(method(contentSharingPicker:didUpdateWithFilter:forStream:))]
#[unsafe(method_family = none)]
unsafe fn contentSharingPicker_didUpdateWithFilter_forStream(
&self,
picker: &SCContentSharingPicker,
filter: &SCContentFilter,
stream: Option<&SCStream>,
);
/// contentSharingPickerStartDidFailWithError:
///
/// Parameter `error`: the error denoted for the failure to start picker
///
/// the observer callback method when the picker was asked to start but failed to do so.
#[unsafe(method(contentSharingPickerStartDidFailWithError:))]
#[unsafe(method_family = none)]
unsafe fn contentSharingPickerStartDidFailWithError(&self, error: &NSError);
}
);