objc2_ui_kit/generated/
UIColor.rs1use 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-image")]
11#[cfg(not(target_os = "watchos"))]
12use objc2_core_image::*;
13use objc2_foundation::*;
14
15use crate::*;
16
17#[repr(transparent)]
20#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
21pub struct UIColorProminence(pub NSInteger);
22impl UIColorProminence {
23 #[doc(alias = "UIColorProminencePrimary")]
24 pub const Primary: Self = Self(0);
25 #[doc(alias = "UIColorProminenceSecondary")]
26 pub const Secondary: Self = Self(1);
27 #[doc(alias = "UIColorProminenceTertiary")]
28 pub const Tertiary: Self = Self(2);
29 #[doc(alias = "UIColorProminenceQuaternary")]
30 pub const Quaternary: Self = Self(3);
31}
32
33unsafe impl Encode for UIColorProminence {
34 const ENCODING: Encoding = NSInteger::ENCODING;
35}
36
37unsafe impl RefEncode for UIColorProminence {
38 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41extern_class!(
42 #[unsafe(super(NSObject))]
44 #[derive(Debug, PartialEq, Eq, Hash)]
45 pub struct UIColor;
46);
47
48unsafe impl Send for UIColor {}
49
50unsafe impl Sync for UIColor {}
51
52unsafe impl NSCoding for UIColor {}
53
54unsafe impl NSCopying for UIColor {}
55
56unsafe impl CopyingHelper for UIColor {
57 type Result = Self;
58}
59
60unsafe impl NSObjectProtocol for UIColor {}
61
62unsafe impl NSSecureCoding for UIColor {}
63
64impl UIColor {
65 extern_methods!(
66 #[cfg(feature = "objc2-core-foundation")]
67 #[unsafe(method(colorWithWhite:alpha:))]
68 #[unsafe(method_family = none)]
69 pub unsafe fn colorWithWhite_alpha(white: CGFloat, alpha: CGFloat) -> Retained<UIColor>;
70
71 #[cfg(feature = "objc2-core-foundation")]
72 #[unsafe(method(colorWithHue:saturation:brightness:alpha:))]
73 #[unsafe(method_family = none)]
74 pub unsafe fn colorWithHue_saturation_brightness_alpha(
75 hue: CGFloat,
76 saturation: CGFloat,
77 brightness: CGFloat,
78 alpha: CGFloat,
79 ) -> Retained<UIColor>;
80
81 #[cfg(feature = "objc2-core-foundation")]
82 #[unsafe(method(colorWithRed:green:blue:alpha:))]
83 #[unsafe(method_family = none)]
84 pub unsafe fn colorWithRed_green_blue_alpha(
85 red: CGFloat,
86 green: CGFloat,
87 blue: CGFloat,
88 alpha: CGFloat,
89 ) -> Retained<UIColor>;
90
91 #[cfg(feature = "objc2-core-foundation")]
92 #[unsafe(method(colorWithDisplayP3Red:green:blue:alpha:))]
93 #[unsafe(method_family = none)]
94 pub unsafe fn colorWithDisplayP3Red_green_blue_alpha(
95 display_p3_red: CGFloat,
96 green: CGFloat,
97 blue: CGFloat,
98 alpha: CGFloat,
99 ) -> Retained<UIColor>;
100
101 #[cfg(feature = "objc2-core-graphics")]
102 #[unsafe(method(colorWithCGColor:))]
103 #[unsafe(method_family = none)]
104 pub unsafe fn colorWithCGColor(cg_color: &CGColor) -> Retained<UIColor>;
105
106 #[cfg(feature = "UIImage")]
107 #[unsafe(method(colorWithPatternImage:))]
108 #[unsafe(method_family = none)]
109 pub unsafe fn colorWithPatternImage(image: &UIImage) -> Retained<UIColor>;
110
111 #[cfg(feature = "objc2-core-image")]
112 #[cfg(not(target_os = "watchos"))]
113 #[unsafe(method(colorWithCIColor:))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn colorWithCIColor(ci_color: &CIColor) -> Retained<UIColor>;
116
117 #[cfg(feature = "objc2-core-foundation")]
118 #[unsafe(method(initWithWhite:alpha:))]
119 #[unsafe(method_family = init)]
120 pub unsafe fn initWithWhite_alpha(
121 this: Allocated<Self>,
122 white: CGFloat,
123 alpha: CGFloat,
124 ) -> Retained<UIColor>;
125
126 #[cfg(feature = "objc2-core-foundation")]
127 #[unsafe(method(initWithHue:saturation:brightness:alpha:))]
128 #[unsafe(method_family = init)]
129 pub unsafe fn initWithHue_saturation_brightness_alpha(
130 this: Allocated<Self>,
131 hue: CGFloat,
132 saturation: CGFloat,
133 brightness: CGFloat,
134 alpha: CGFloat,
135 ) -> Retained<UIColor>;
136
137 #[cfg(feature = "objc2-core-foundation")]
138 #[unsafe(method(initWithRed:green:blue:alpha:))]
139 #[unsafe(method_family = init)]
140 pub unsafe fn initWithRed_green_blue_alpha(
141 this: Allocated<Self>,
142 red: CGFloat,
143 green: CGFloat,
144 blue: CGFloat,
145 alpha: CGFloat,
146 ) -> Retained<UIColor>;
147
148 #[cfg(feature = "objc2-core-foundation")]
149 #[unsafe(method(initWithDisplayP3Red:green:blue:alpha:))]
150 #[unsafe(method_family = init)]
151 pub unsafe fn initWithDisplayP3Red_green_blue_alpha(
152 this: Allocated<Self>,
153 display_p3_red: CGFloat,
154 green: CGFloat,
155 blue: CGFloat,
156 alpha: CGFloat,
157 ) -> Retained<UIColor>;
158
159 #[cfg(feature = "objc2-core-graphics")]
160 #[unsafe(method(initWithCGColor:))]
161 #[unsafe(method_family = init)]
162 pub unsafe fn initWithCGColor(
163 this: Allocated<Self>,
164 cg_color: &CGColor,
165 ) -> Retained<UIColor>;
166
167 #[cfg(feature = "UIImage")]
168 #[unsafe(method(initWithPatternImage:))]
169 #[unsafe(method_family = init)]
170 pub unsafe fn initWithPatternImage(
171 this: Allocated<Self>,
172 image: &UIImage,
173 ) -> Retained<UIColor>;
174
175 #[cfg(feature = "objc2-core-image")]
176 #[cfg(not(target_os = "watchos"))]
177 #[unsafe(method(initWithCIColor:))]
178 #[unsafe(method_family = init)]
179 pub unsafe fn initWithCIColor(
180 this: Allocated<Self>,
181 ci_color: &CIColor,
182 ) -> Retained<UIColor>;
183
184 #[unsafe(method(blackColor))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn blackColor() -> Retained<UIColor>;
187
188 #[unsafe(method(darkGrayColor))]
189 #[unsafe(method_family = none)]
190 pub unsafe fn darkGrayColor() -> Retained<UIColor>;
191
192 #[unsafe(method(lightGrayColor))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn lightGrayColor() -> Retained<UIColor>;
195
196 #[unsafe(method(whiteColor))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn whiteColor() -> Retained<UIColor>;
199
200 #[unsafe(method(grayColor))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn grayColor() -> Retained<UIColor>;
203
204 #[unsafe(method(redColor))]
205 #[unsafe(method_family = none)]
206 pub unsafe fn redColor() -> Retained<UIColor>;
207
208 #[unsafe(method(greenColor))]
209 #[unsafe(method_family = none)]
210 pub unsafe fn greenColor() -> Retained<UIColor>;
211
212 #[unsafe(method(blueColor))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn blueColor() -> Retained<UIColor>;
215
216 #[unsafe(method(cyanColor))]
217 #[unsafe(method_family = none)]
218 pub unsafe fn cyanColor() -> Retained<UIColor>;
219
220 #[unsafe(method(yellowColor))]
221 #[unsafe(method_family = none)]
222 pub unsafe fn yellowColor() -> Retained<UIColor>;
223
224 #[unsafe(method(magentaColor))]
225 #[unsafe(method_family = none)]
226 pub unsafe fn magentaColor() -> Retained<UIColor>;
227
228 #[unsafe(method(orangeColor))]
229 #[unsafe(method_family = none)]
230 pub unsafe fn orangeColor() -> Retained<UIColor>;
231
232 #[unsafe(method(purpleColor))]
233 #[unsafe(method_family = none)]
234 pub unsafe fn purpleColor() -> Retained<UIColor>;
235
236 #[unsafe(method(brownColor))]
237 #[unsafe(method_family = none)]
238 pub unsafe fn brownColor() -> Retained<UIColor>;
239
240 #[unsafe(method(clearColor))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn clearColor() -> Retained<UIColor>;
243
244 #[unsafe(method(set))]
245 #[unsafe(method_family = none)]
246 pub unsafe fn set(&self);
247
248 #[unsafe(method(setFill))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn setFill(&self);
251
252 #[unsafe(method(setStroke))]
253 #[unsafe(method_family = none)]
254 pub unsafe fn setStroke(&self);
255
256 #[cfg(feature = "objc2-core-foundation")]
257 #[unsafe(method(getWhite:alpha:))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn getWhite_alpha(&self, white: *mut CGFloat, alpha: *mut CGFloat) -> bool;
260
261 #[cfg(feature = "objc2-core-foundation")]
262 #[unsafe(method(getHue:saturation:brightness:alpha:))]
263 #[unsafe(method_family = none)]
264 pub unsafe fn getHue_saturation_brightness_alpha(
265 &self,
266 hue: *mut CGFloat,
267 saturation: *mut CGFloat,
268 brightness: *mut CGFloat,
269 alpha: *mut CGFloat,
270 ) -> bool;
271
272 #[cfg(feature = "objc2-core-foundation")]
273 #[unsafe(method(getRed:green:blue:alpha:))]
274 #[unsafe(method_family = none)]
275 pub unsafe fn getRed_green_blue_alpha(
276 &self,
277 red: *mut CGFloat,
278 green: *mut CGFloat,
279 blue: *mut CGFloat,
280 alpha: *mut CGFloat,
281 ) -> bool;
282
283 #[cfg(feature = "objc2-core-foundation")]
284 #[unsafe(method(colorWithAlphaComponent:))]
285 #[unsafe(method_family = none)]
286 pub unsafe fn colorWithAlphaComponent(&self, alpha: CGFloat) -> Retained<UIColor>;
287
288 #[cfg(feature = "objc2-core-graphics")]
289 #[unsafe(method(CGColor))]
290 #[unsafe(method_family = none)]
291 pub unsafe fn CGColor(&self) -> Retained<CGColor>;
292
293 #[cfg(feature = "objc2-core-image")]
294 #[cfg(not(target_os = "watchos"))]
295 #[unsafe(method(CIColor))]
296 #[unsafe(method_family = none)]
297 pub unsafe fn CIColor(&self) -> Retained<CIColor>;
298 );
299}
300
301impl UIColor {
303 extern_methods!(
304 #[unsafe(method(init))]
305 #[unsafe(method_family = init)]
306 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
307
308 #[unsafe(method(new))]
309 #[unsafe(method_family = new)]
310 pub unsafe fn new() -> Retained<Self>;
311 );
312}
313
314impl UIColor {
316 extern_methods!();
317}
318
319unsafe impl NSItemProviderReading for UIColor {}
320
321unsafe impl NSItemProviderWriting for UIColor {}
322
323mod private_CIColorUIKitAdditions {
324 pub trait Sealed {}
325}
326
327#[doc(alias = "UIKitAdditions")]
329pub unsafe trait CIColorUIKitAdditions:
330 ClassType + Sized + private_CIColorUIKitAdditions::Sealed
331{
332 extern_methods!(
333 #[unsafe(method(initWithColor:))]
334 #[unsafe(method_family = init)]
335 unsafe fn initWithColor(this: Allocated<Self>, color: &UIColor) -> Retained<Self>;
336 );
337}
338
339#[cfg(feature = "objc2-core-image")]
340#[cfg(not(target_os = "watchos"))]
341impl private_CIColorUIKitAdditions::Sealed for CIColor {}
342#[cfg(feature = "objc2-core-image")]
343#[cfg(not(target_os = "watchos"))]
344unsafe impl CIColorUIKitAdditions for CIColor {}
345
346impl UIColor {
348 extern_methods!(
349 #[unsafe(method(colorNamed:))]
350 #[unsafe(method_family = none)]
351 pub unsafe fn colorNamed(name: &NSString) -> Option<Retained<UIColor>>;
352
353 #[cfg(feature = "UITraitCollection")]
354 #[unsafe(method(colorNamed:inBundle:compatibleWithTraitCollection:))]
355 #[unsafe(method_family = none)]
356 pub unsafe fn colorNamed_inBundle_compatibleWithTraitCollection(
357 name: &NSString,
358 bundle: Option<&NSBundle>,
359 trait_collection: Option<&UITraitCollection>,
360 ) -> Option<Retained<UIColor>>;
361 );
362}
363
364impl UIColor {
366 extern_methods!(
367 #[cfg(all(feature = "UITraitCollection", feature = "block2"))]
368 #[unsafe(method(colorWithDynamicProvider:))]
369 #[unsafe(method_family = none)]
370 pub unsafe fn colorWithDynamicProvider(
371 dynamic_provider: &block2::Block<
372 dyn Fn(NonNull<UITraitCollection>) -> NonNull<UIColor>,
373 >,
374 ) -> Retained<UIColor>;
375
376 #[cfg(all(feature = "UITraitCollection", feature = "block2"))]
377 #[unsafe(method(initWithDynamicProvider:))]
378 #[unsafe(method_family = init)]
379 pub unsafe fn initWithDynamicProvider(
380 this: Allocated<Self>,
381 dynamic_provider: &block2::Block<
382 dyn Fn(NonNull<UITraitCollection>) -> NonNull<UIColor>,
383 >,
384 ) -> Retained<UIColor>;
385
386 #[cfg(feature = "UITraitCollection")]
387 #[unsafe(method(resolvedColorWithTraitCollection:))]
388 #[unsafe(method_family = none)]
389 pub unsafe fn resolvedColorWithTraitCollection(
390 &self,
391 trait_collection: &UITraitCollection,
392 ) -> Retained<UIColor>;
393 );
394}
395
396impl UIColor {
398 extern_methods!(
399 #[unsafe(method(colorWithProminence:))]
400 #[unsafe(method_family = none)]
401 pub unsafe fn colorWithProminence(
402 &self,
403 prominence: UIColorProminence,
404 ) -> Retained<UIColor>;
405
406 #[unsafe(method(prominence))]
407 #[unsafe(method_family = none)]
408 pub unsafe fn prominence(&self) -> UIColorProminence;
409 );
410}