objc2_screen_capture_kit/generated/
SCScreenshotManager.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-graphics")]
9use objc2_core_graphics::*;
10#[cfg(feature = "objc2-core-media")]
11use objc2_core_media::*;
12use objc2_foundation::*;
13#[cfg(feature = "objc2-uniform-type-identifiers")]
14use objc2_uniform_type_identifiers::*;
15
16use crate::*;
17
18/// [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/scscreenshotdisplayintent?language=objc)
19// NS_ENUM
20#[repr(transparent)]
21#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
22pub struct SCScreenshotDisplayIntent(pub NSInteger);
23impl SCScreenshotDisplayIntent {
24    #[doc(alias = "SCScreenshotDisplayIntentCanonical")]
25    pub const Canonical: Self = Self(0);
26    #[doc(alias = "SCScreenshotDisplayIntentLocal")]
27    pub const Local: Self = Self(1);
28}
29
30unsafe impl Encode for SCScreenshotDisplayIntent {
31    const ENCODING: Encoding = NSInteger::ENCODING;
32}
33
34unsafe impl RefEncode for SCScreenshotDisplayIntent {
35    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38/// [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/scscreenshotdynamicrange?language=objc)
39// NS_ENUM
40#[repr(transparent)]
41#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
42pub struct SCScreenshotDynamicRange(pub NSInteger);
43impl SCScreenshotDynamicRange {
44    #[doc(alias = "SCScreenshotDynamicRangeSDR")]
45    pub const SDR: Self = Self(0);
46    #[doc(alias = "SCScreenshotDynamicRangeHDR")]
47    pub const HDR: Self = Self(1);
48    #[doc(alias = "SCScreenshotDynamicRangeSDRAndHDR")]
49    pub const SDRAndHDR: Self = Self(2);
50}
51
52unsafe impl Encode for SCScreenshotDynamicRange {
53    const ENCODING: Encoding = NSInteger::ENCODING;
54}
55
56unsafe impl RefEncode for SCScreenshotDynamicRange {
57    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
58}
59
60extern_class!(
61    /// [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/scscreenshotconfiguration?language=objc)
62    #[unsafe(super(NSObject))]
63    #[derive(Debug, PartialEq, Eq, Hash)]
64    pub struct SCScreenshotConfiguration;
65);
66
67extern_conformance!(
68    unsafe impl NSObjectProtocol for SCScreenshotConfiguration {}
69);
70
71impl SCScreenshotConfiguration {
72    extern_methods!(
73        /// SCScreenshotProperty for output width as measured in pixels. Default is the width of the content being captured.
74        #[unsafe(method(width))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn width(&self) -> NSInteger;
77
78        /// Setter for [`width`][Self::width].
79        #[unsafe(method(setWidth:))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn setWidth(&self, width: NSInteger);
82
83        /// SCScreenshotProperty for output height as measured in pixels. Default is the height of the content being captured.
84        #[unsafe(method(height))]
85        #[unsafe(method_family = none)]
86        pub unsafe fn height(&self) -> NSInteger;
87
88        /// Setter for [`height`][Self::height].
89        #[unsafe(method(setHeight:))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn setHeight(&self, height: NSInteger);
92
93        /// SCScreenshotProperty that specifies whether the cursor should appear in the screenshot.  By default the cursor is visible.
94        #[unsafe(method(showsCursor))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn showsCursor(&self) -> bool;
97
98        /// Setter for [`showsCursor`][Self::showsCursor].
99        #[unsafe(method(setShowsCursor:))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn setShowsCursor(&self, shows_cursor: bool);
102
103        #[cfg(feature = "objc2-core-foundation")]
104        /// SCScreenshotProperty that specifies that the screenshot only samples a subset of the frame input. If not set, then the entire screenshot will be captured. The rectangle is specified in points in the display’s logical coordinate system.
105        #[unsafe(method(sourceRect))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn sourceRect(&self) -> CGRect;
108
109        #[cfg(feature = "objc2-core-foundation")]
110        /// Setter for [`sourceRect`][Self::sourceRect].
111        #[unsafe(method(setSourceRect:))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn setSourceRect(&self, source_rect: CGRect);
114
115        #[cfg(feature = "objc2-core-foundation")]
116        /// SCScreenshotProperty that specifies that the screenshot outputs into a subset of the output CGimage.If not set then the output surface is used. The rectangle is specified in pixels in the display's coordinate system.
117        #[unsafe(method(destinationRect))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn destinationRect(&self) -> CGRect;
120
121        #[cfg(feature = "objc2-core-foundation")]
122        /// Setter for [`destinationRect`][Self::destinationRect].
123        #[unsafe(method(setDestinationRect:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn setDestinationRect(&self, destination_rect: CGRect);
126
127        /// SCScreenshotProperty to ignore framing on windows (will ignore shadows).
128        #[unsafe(method(ignoreShadows))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn ignoreShadows(&self) -> bool;
131
132        /// Setter for [`ignoreShadows`][Self::ignoreShadows].
133        #[unsafe(method(setIgnoreShadows:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn setIgnoreShadows(&self, ignore_shadows: bool);
136
137        /// SCScreenshotProperty to ignore framing on windows in the display bounded sharing case (will ignore shadows).
138        #[unsafe(method(ignoreClipping))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn ignoreClipping(&self) -> bool;
141
142        /// Setter for [`ignoreClipping`][Self::ignoreClipping].
143        #[unsafe(method(setIgnoreClipping:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn setIgnoreClipping(&self, ignore_clipping: bool);
146
147        /// SCScreenshotProperty to show the child windows of the applications and windows being captured.  Child windows are included by default.
148        #[unsafe(method(includeChildWindows))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn includeChildWindows(&self) -> bool;
151
152        /// Setter for [`includeChildWindows`][Self::includeChildWindows].
153        #[unsafe(method(setIncludeChildWindows:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn setIncludeChildWindows(&self, include_child_windows: bool);
156
157        /// Specifies the render type of the screenshot.
158        #[unsafe(method(displayIntent))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn displayIntent(&self) -> SCScreenshotDisplayIntent;
161
162        /// Setter for [`displayIntent`][Self::displayIntent].
163        #[unsafe(method(setDisplayIntent:))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn setDisplayIntent(&self, display_intent: SCScreenshotDisplayIntent);
166
167        /// Specifies the CGImage to return to the client.
168        #[unsafe(method(dynamicRange))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn dynamicRange(&self) -> SCScreenshotDynamicRange;
171
172        /// Setter for [`dynamicRange`][Self::dynamicRange].
173        #[unsafe(method(setDynamicRange:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn setDynamicRange(&self, dynamic_range: SCScreenshotDynamicRange);
176
177        #[cfg(feature = "objc2-uniform-type-identifiers")]
178        /// Specifies the screenshot file format.
179        ///
180        /// # Safety
181        ///
182        /// This is not retained internally, you must ensure the object is still alive.
183        #[unsafe(method(contentType))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn contentType(&self) -> Retained<UTType>;
186
187        #[cfg(feature = "objc2-uniform-type-identifiers")]
188        /// Setter for [`contentType`][Self::contentType].
189        ///
190        /// # Safety
191        ///
192        /// This is unretained, you must ensure the object is kept alive while in use.
193        #[unsafe(method(setContentType:))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn setContentType(&self, content_type: &UTType);
196
197        /// Specifies output URL to save the screenshot.  If the imageOutputURL is nil, then the file will not be saved.
198        #[unsafe(method(fileURL))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn fileURL(&self) -> Option<Retained<NSURL>>;
201
202        /// Setter for [`fileURL`][Self::fileURL].
203        #[unsafe(method(setFileURL:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn setFileURL(&self, file_url: Option<&NSURL>);
206
207        #[cfg(feature = "objc2-uniform-type-identifiers")]
208        /// an array of UTTypes that corresponds to the file formats that are supported. ScreenCaptureKit can save the CGImage into heic, jpeg, and png
209        #[unsafe(method(supportedContentTypes))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn supportedContentTypes() -> Retained<NSArray<UTType>>;
212    );
213}
214
215/// Methods declared on superclass `NSObject`.
216impl SCScreenshotConfiguration {
217    extern_methods!(
218        #[unsafe(method(init))]
219        #[unsafe(method_family = init)]
220        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
221
222        #[unsafe(method(new))]
223        #[unsafe(method_family = new)]
224        pub unsafe fn new() -> Retained<Self>;
225    );
226}
227
228extern_class!(
229    /// [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/scscreenshotoutput?language=objc)
230    #[unsafe(super(NSObject))]
231    #[derive(Debug, PartialEq, Eq, Hash)]
232    pub struct SCScreenshotOutput;
233);
234
235extern_conformance!(
236    unsafe impl NSObjectProtocol for SCScreenshotOutput {}
237);
238
239impl SCScreenshotOutput {
240    extern_methods!(
241        #[cfg(feature = "objc2-core-graphics")]
242        /// SCScreenshotOutput property that denotes the SDR CGimage.  The output CGImage uses the same color space as the display
243        #[unsafe(method(sdrImage))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn sdrImage(&self) -> Option<Retained<CGImage>>;
246
247        #[cfg(feature = "objc2-core-graphics")]
248        /// Setter for [`sdrImage`][Self::sdrImage].
249        #[unsafe(method(setSdrImage:))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn setSdrImage(&self, sdr_image: Option<&CGImage>);
252
253        #[cfg(feature = "objc2-core-graphics")]
254        /// SCScreenshotOutput property that denotes the HDR CGimage.  The output CGImage uses the extended sRGB color space.
255        #[unsafe(method(hdrImage))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn hdrImage(&self) -> Option<Retained<CGImage>>;
258
259        #[cfg(feature = "objc2-core-graphics")]
260        /// Setter for [`hdrImage`][Self::hdrImage].
261        #[unsafe(method(setHdrImage:))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn setHdrImage(&self, hdr_image: Option<&CGImage>);
264
265        /// SCScreenshotOutput property to specify the location where the image was saved.  If a fileURL in the screenshot configuration was not specified, then the fileURL will be nil
266        ///
267        /// # Safety
268        ///
269        /// This is not retained internally, you must ensure the object is still alive.
270        #[unsafe(method(fileURL))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn fileURL(&self) -> Option<Retained<NSURL>>;
273
274        /// Setter for [`fileURL`][Self::fileURL].
275        ///
276        /// # Safety
277        ///
278        /// This is unretained, you must ensure the object is kept alive while in use.
279        #[unsafe(method(setFileURL:))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn setFileURL(&self, file_url: Option<&NSURL>);
282    );
283}
284
285/// Methods declared on superclass `NSObject`.
286impl SCScreenshotOutput {
287    extern_methods!(
288        #[unsafe(method(init))]
289        #[unsafe(method_family = init)]
290        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
291
292        #[unsafe(method(new))]
293        #[unsafe(method_family = new)]
294        pub unsafe fn new() -> Retained<Self>;
295    );
296}
297
298extern_class!(
299    /// [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/scscreenshotmanager?language=objc)
300    #[unsafe(super(NSObject))]
301    #[derive(Debug, PartialEq, Eq, Hash)]
302    pub struct SCScreenshotManager;
303);
304
305extern_conformance!(
306    unsafe impl NSObjectProtocol for SCScreenshotManager {}
307);
308
309impl SCScreenshotManager {
310    extern_methods!(
311        #[unsafe(method(init))]
312        #[unsafe(method_family = init)]
313        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
314
315        #[cfg(all(feature = "SCStream", feature = "block2", feature = "objc2-core-media"))]
316        /// captureSampleBufferWithFilter:configuration:completionHandler:
317        ///
318        /// Parameter `contentFilter`: is the filter containing the content to take a screenshot of
319        ///
320        /// Parameter `config`: is the stream configuration containing information on how to format the screenshot
321        ///
322        /// Parameter `completionHandler`: is the handler that will deliver the screenshot to the user
323        ///
324        /// this method takes a screenshot using the filter and configuration passed in and returns it as a CMSampleBuffer
325        #[unsafe(method(captureSampleBufferWithFilter:configuration:completionHandler:))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn captureSampleBufferWithFilter_configuration_completionHandler(
328            content_filter: &SCContentFilter,
329            config: &SCStreamConfiguration,
330            completion_handler: Option<
331                &block2::DynBlock<dyn Fn(*mut CMSampleBuffer, *mut NSError)>,
332            >,
333        );
334
335        #[cfg(all(
336            feature = "SCStream",
337            feature = "block2",
338            feature = "objc2-core-graphics"
339        ))]
340        /// captureImageWithFilter:configuration:completionHandler:
341        ///
342        /// Parameter `contentFilter`: is the filter containing the content to take a screenshot of
343        ///
344        /// Parameter `config`: is the stream configuration containing information on how to format the screenshot
345        ///
346        /// Parameter `completionHandler`: is the handler that will deliver the screenshot to the user
347        ///
348        /// this method takes a screenshot using the filter and configuration passed in and returns it as a CGImage in BGRA format if captureDynamicRange is SCCaptureDynamicRangeSDR, in RGhA format if captureDynamicRange is SCCaptureDynamicRangeHDRLocalDisplay/SCCaptureDynamicRangeHDRCanonicalDisplay
349        #[unsafe(method(captureImageWithFilter:configuration:completionHandler:))]
350        #[unsafe(method_family = none)]
351        pub unsafe fn captureImageWithFilter_configuration_completionHandler(
352            content_filter: &SCContentFilter,
353            config: &SCStreamConfiguration,
354            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut CGImage, *mut NSError)>>,
355        );
356
357        #[cfg(all(
358            feature = "block2",
359            feature = "objc2-core-foundation",
360            feature = "objc2-core-graphics"
361        ))]
362        /// captureImageInRect:completionHandler:
363        ///
364        /// Parameter `rect`: the rect for the region in points on the screen space for the screen shot, this is display agnostic and supports multiple displays
365        ///
366        /// Parameter `completionHandler`: is the handler that will deliver the screenshot to the client
367        ///
368        /// this method returns an image containing the contents of the rectangle in points, specified in display space
369        #[unsafe(method(captureImageInRect:completionHandler:))]
370        #[unsafe(method_family = none)]
371        pub unsafe fn captureImageInRect_completionHandler(
372            rect: CGRect,
373            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut CGImage, *mut NSError)>>,
374        );
375
376        #[cfg(all(feature = "SCStream", feature = "block2"))]
377        /// captureScreenshotWithFilter:configuration:completionHandler:
378        ///
379        /// Parameter `contentFilter`: is the filter containing the content to take a screenshot of
380        ///
381        /// Parameter `config`: is the screenshot configuration containing information on how to format the screenshot
382        ///
383        /// Parameter `completionHandler`: is the handler that will deliver the SCScreenshotOutput object to the client
384        ///
385        /// this method returns an SCScreenshotOutput object containing CGImages of the screenshot requested by the client
386        #[unsafe(method(captureScreenshotWithFilter:configuration:completionHandler:))]
387        #[unsafe(method_family = none)]
388        pub unsafe fn captureScreenshotWithFilter_configuration_completionHandler(
389            content_filter: &SCContentFilter,
390            config: &SCScreenshotConfiguration,
391            completion_handler: Option<
392                &block2::DynBlock<dyn Fn(*mut SCScreenshotOutput, *mut NSError)>,
393            >,
394        );
395
396        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
397        /// captureScreenshotWithRect:configuration:completionHandler:
398        ///
399        /// Parameter `rect`: the rect for the region in points on the screen space for the screen shot, this is display agnostic and supports multiple displays
400        ///
401        /// Parameter `config`: is the screenshot configuration containing information on how to format the screenshot
402        ///
403        /// Parameter `completionHandler`: is the handler that will deliver the SCScreenshotOutput object to the client
404        ///
405        /// this method returns an SCScreenshotOutput object containing CGImages of the screenshot requested by the client
406        #[unsafe(method(captureScreenshotWithRect:configuration:completionHandler:))]
407        #[unsafe(method_family = none)]
408        pub unsafe fn captureScreenshotWithRect_configuration_completionHandler(
409            rect: CGRect,
410            config: &SCScreenshotConfiguration,
411            completion_handler: Option<
412                &block2::DynBlock<dyn Fn(*mut SCScreenshotOutput, *mut NSError)>,
413            >,
414        );
415    );
416}
417
418/// Methods declared on superclass `NSObject`.
419impl SCScreenshotManager {
420    extern_methods!(
421        #[unsafe(method(new))]
422        #[unsafe(method_family = new)]
423        pub unsafe fn new() -> Retained<Self>;
424    );
425}