objc2_ui_kit/generated/
UIGraphicsImageRenderer.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::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigraphicsimagedrawingactions?language=objc)
13#[cfg(all(feature = "UIGraphicsRenderer", feature = "block2"))]
14pub type UIGraphicsImageDrawingActions =
15    *mut block2::DynBlock<dyn Fn(NonNull<UIGraphicsImageRendererContext>)>;
16
17/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigraphicsimagerendererformatrange?language=objc)
18// NS_ENUM
19#[repr(transparent)]
20#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
21pub struct UIGraphicsImageRendererFormatRange(pub NSInteger);
22impl UIGraphicsImageRendererFormatRange {
23    #[doc(alias = "UIGraphicsImageRendererFormatRangeUnspecified")]
24    pub const Unspecified: Self = Self(-1);
25    #[doc(alias = "UIGraphicsImageRendererFormatRangeAutomatic")]
26    pub const Automatic: Self = Self(0);
27    #[doc(alias = "UIGraphicsImageRendererFormatRangeExtended")]
28    pub const Extended: Self = Self(1);
29    #[doc(alias = "UIGraphicsImageRendererFormatRangeStandard")]
30    pub const Standard: Self = Self(2);
31}
32
33unsafe impl Encode for UIGraphicsImageRendererFormatRange {
34    const ENCODING: Encoding = NSInteger::ENCODING;
35}
36
37unsafe impl RefEncode for UIGraphicsImageRendererFormatRange {
38    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41extern_class!(
42    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigraphicsimagerendererformat?language=objc)
43    #[unsafe(super(UIGraphicsRendererFormat, NSObject))]
44    #[derive(Debug, PartialEq, Eq, Hash)]
45    #[cfg(feature = "UIGraphicsRenderer")]
46    pub struct UIGraphicsImageRendererFormat;
47);
48
49#[cfg(feature = "UIGraphicsRenderer")]
50extern_conformance!(
51    unsafe impl NSCopying for UIGraphicsImageRendererFormat {}
52);
53
54#[cfg(feature = "UIGraphicsRenderer")]
55unsafe impl CopyingHelper for UIGraphicsImageRendererFormat {
56    type Result = Self;
57}
58
59#[cfg(feature = "UIGraphicsRenderer")]
60extern_conformance!(
61    unsafe impl NSObjectProtocol for UIGraphicsImageRendererFormat {}
62);
63
64#[cfg(feature = "UIGraphicsRenderer")]
65impl UIGraphicsImageRendererFormat {
66    extern_methods!(
67        #[cfg(feature = "objc2-core-foundation")]
68        #[unsafe(method(scale))]
69        #[unsafe(method_family = none)]
70        pub fn scale(&self) -> CGFloat;
71
72        #[cfg(feature = "objc2-core-foundation")]
73        /// Setter for [`scale`][Self::scale].
74        #[unsafe(method(setScale:))]
75        #[unsafe(method_family = none)]
76        pub fn setScale(&self, scale: CGFloat);
77
78        #[unsafe(method(opaque))]
79        #[unsafe(method_family = none)]
80        pub fn opaque(&self) -> bool;
81
82        /// Setter for [`opaque`][Self::opaque].
83        #[unsafe(method(setOpaque:))]
84        #[unsafe(method_family = none)]
85        pub fn setOpaque(&self, opaque: bool);
86
87        #[deprecated = "Use the preferredRange property instead"]
88        #[unsafe(method(prefersExtendedRange))]
89        #[unsafe(method_family = none)]
90        pub fn prefersExtendedRange(&self) -> bool;
91
92        /// Setter for [`prefersExtendedRange`][Self::prefersExtendedRange].
93        #[deprecated = "Use the preferredRange property instead"]
94        #[unsafe(method(setPrefersExtendedRange:))]
95        #[unsafe(method_family = none)]
96        pub fn setPrefersExtendedRange(&self, prefers_extended_range: bool);
97
98        #[unsafe(method(supportsHighDynamicRange))]
99        #[unsafe(method_family = none)]
100        pub fn supportsHighDynamicRange(&self) -> bool;
101
102        /// indicates if the format supports high dynamic range rendering.
103        #[unsafe(method(preferredRange))]
104        #[unsafe(method_family = none)]
105        pub fn preferredRange(&self) -> UIGraphicsImageRendererFormatRange;
106
107        /// Setter for [`preferredRange`][Self::preferredRange].
108        #[unsafe(method(setPreferredRange:))]
109        #[unsafe(method_family = none)]
110        pub fn setPreferredRange(&self, preferred_range: UIGraphicsImageRendererFormatRange);
111
112        #[cfg(feature = "UITraitCollection")]
113        #[unsafe(method(formatForTraitCollection:))]
114        #[unsafe(method_family = none)]
115        pub fn formatForTraitCollection(trait_collection: &UITraitCollection) -> Retained<Self>;
116    );
117}
118
119/// Methods declared on superclass `UIGraphicsRendererFormat`.
120#[cfg(feature = "UIGraphicsRenderer")]
121impl UIGraphicsImageRendererFormat {
122    extern_methods!(
123        #[deprecated]
124        #[unsafe(method(defaultFormat))]
125        #[unsafe(method_family = none)]
126        pub fn defaultFormat() -> Retained<Self>;
127
128        #[unsafe(method(preferredFormat))]
129        #[unsafe(method_family = none)]
130        pub fn preferredFormat() -> Retained<Self>;
131    );
132}
133
134/// Methods declared on superclass `NSObject`.
135#[cfg(feature = "UIGraphicsRenderer")]
136impl UIGraphicsImageRendererFormat {
137    extern_methods!(
138        #[unsafe(method(init))]
139        #[unsafe(method_family = init)]
140        pub fn init(this: Allocated<Self>) -> Retained<Self>;
141
142        #[unsafe(method(new))]
143        #[unsafe(method_family = new)]
144        pub fn new() -> Retained<Self>;
145    );
146}
147
148#[cfg(feature = "UIGraphicsRenderer")]
149impl DefaultRetained for UIGraphicsImageRendererFormat {
150    #[inline]
151    fn default_retained() -> Retained<Self> {
152        Self::new()
153    }
154}
155
156extern_class!(
157    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigraphicsimagerenderercontext?language=objc)
158    #[unsafe(super(UIGraphicsRendererContext, NSObject))]
159    #[derive(Debug, PartialEq, Eq, Hash)]
160    #[cfg(feature = "UIGraphicsRenderer")]
161    pub struct UIGraphicsImageRendererContext;
162);
163
164#[cfg(feature = "UIGraphicsRenderer")]
165extern_conformance!(
166    unsafe impl NSObjectProtocol for UIGraphicsImageRendererContext {}
167);
168
169#[cfg(feature = "UIGraphicsRenderer")]
170impl UIGraphicsImageRendererContext {
171    extern_methods!(
172        #[cfg(feature = "UIImage")]
173        #[unsafe(method(currentImage))]
174        #[unsafe(method_family = none)]
175        pub fn currentImage(&self) -> Retained<UIImage>;
176    );
177}
178
179/// Methods declared on superclass `NSObject`.
180#[cfg(feature = "UIGraphicsRenderer")]
181impl UIGraphicsImageRendererContext {
182    extern_methods!(
183        #[unsafe(method(init))]
184        #[unsafe(method_family = init)]
185        pub fn init(this: Allocated<Self>) -> Retained<Self>;
186
187        #[unsafe(method(new))]
188        #[unsafe(method_family = new)]
189        pub fn new() -> Retained<Self>;
190    );
191}
192
193#[cfg(feature = "UIGraphicsRenderer")]
194impl DefaultRetained for UIGraphicsImageRendererContext {
195    #[inline]
196    fn default_retained() -> Retained<Self> {
197        Self::new()
198    }
199}
200
201extern_class!(
202    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigraphicsimagerenderer?language=objc)
203    #[unsafe(super(UIGraphicsRenderer, NSObject))]
204    #[derive(Debug, PartialEq, Eq, Hash)]
205    #[cfg(feature = "UIGraphicsRenderer")]
206    pub struct UIGraphicsImageRenderer;
207);
208
209#[cfg(feature = "UIGraphicsRenderer")]
210extern_conformance!(
211    unsafe impl NSObjectProtocol for UIGraphicsImageRenderer {}
212);
213
214#[cfg(feature = "UIGraphicsRenderer")]
215impl UIGraphicsImageRenderer {
216    extern_methods!(
217        #[cfg(feature = "objc2-core-foundation")]
218        #[unsafe(method(initWithSize:))]
219        #[unsafe(method_family = init)]
220        pub fn initWithSize(this: Allocated<Self>, size: CGSize) -> Retained<Self>;
221
222        #[cfg(feature = "objc2-core-foundation")]
223        #[unsafe(method(initWithSize:format:))]
224        #[unsafe(method_family = init)]
225        pub fn initWithSize_format(
226            this: Allocated<Self>,
227            size: CGSize,
228            format: &UIGraphicsImageRendererFormat,
229        ) -> Retained<Self>;
230
231        #[cfg(feature = "objc2-core-foundation")]
232        #[unsafe(method(initWithBounds:format:))]
233        #[unsafe(method_family = init)]
234        pub fn initWithBounds_format(
235            this: Allocated<Self>,
236            bounds: CGRect,
237            format: &UIGraphicsImageRendererFormat,
238        ) -> Retained<Self>;
239
240        #[cfg(all(feature = "UIImage", feature = "block2"))]
241        /// # Safety
242        ///
243        /// `actions` must be a valid pointer.
244        #[unsafe(method(imageWithActions:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn imageWithActions(
247            &self,
248            actions: UIGraphicsImageDrawingActions,
249        ) -> Retained<UIImage>;
250
251        #[cfg(feature = "block2")]
252        /// # Safety
253        ///
254        /// `actions` must be a valid pointer.
255        #[unsafe(method(PNGDataWithActions:))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn PNGDataWithActions(
258            &self,
259            actions: UIGraphicsImageDrawingActions,
260        ) -> Retained<NSData>;
261
262        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
263        /// # Safety
264        ///
265        /// `actions` must be a valid pointer.
266        #[unsafe(method(JPEGDataWithCompressionQuality:actions:))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn JPEGDataWithCompressionQuality_actions(
269            &self,
270            compression_quality: CGFloat,
271            actions: UIGraphicsImageDrawingActions,
272        ) -> Retained<NSData>;
273    );
274}
275
276/// Methods declared on superclass `UIGraphicsRenderer`.
277#[cfg(feature = "UIGraphicsRenderer")]
278impl UIGraphicsImageRenderer {
279    extern_methods!(
280        #[cfg(feature = "objc2-core-foundation")]
281        #[unsafe(method(initWithBounds:))]
282        #[unsafe(method_family = init)]
283        pub fn initWithBounds(this: Allocated<Self>, bounds: CGRect) -> Retained<Self>;
284    );
285}
286
287/// Methods declared on superclass `NSObject`.
288#[cfg(feature = "UIGraphicsRenderer")]
289impl UIGraphicsImageRenderer {
290    extern_methods!(
291        #[unsafe(method(init))]
292        #[unsafe(method_family = init)]
293        pub fn init(this: Allocated<Self>) -> Retained<Self>;
294
295        #[unsafe(method(new))]
296        #[unsafe(method_family = new)]
297        pub fn new() -> Retained<Self>;
298    );
299}
300
301#[cfg(feature = "UIGraphicsRenderer")]
302impl DefaultRetained for UIGraphicsImageRenderer {
303    #[inline]
304    fn default_retained() -> Retained<Self> {
305        Self::new()
306    }
307}