objc2_app_kit/generated/
NSColor.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")]
9#[cfg(target_vendor = "apple")]
10use objc2_core_graphics::*;
11#[cfg(feature = "objc2-core-image")]
12#[cfg(target_vendor = "apple")]
13use objc2_core_image::*;
14use objc2_foundation::*;
15
16use crate::*;
17
18/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsappkitversionnumberwithpatterncolorleakfix?language=objc)
19#[cfg(feature = "NSApplication")]
20pub static NSAppKitVersionNumberWithPatternColorLeakFix: NSAppKitVersion = 641.0 as _;
21
22/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolortype?language=objc)
23// NS_ENUM
24#[repr(transparent)]
25#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
26pub struct NSColorType(pub NSInteger);
27impl NSColorType {
28    #[doc(alias = "NSColorTypeComponentBased")]
29    pub const ComponentBased: Self = Self(0);
30    #[doc(alias = "NSColorTypePattern")]
31    pub const Pattern: Self = Self(1);
32    #[doc(alias = "NSColorTypeCatalog")]
33    pub const Catalog: Self = Self(2);
34}
35
36unsafe impl Encode for NSColorType {
37    const ENCODING: Encoding = NSInteger::ENCODING;
38}
39
40unsafe impl RefEncode for NSColorType {
41    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorsystemeffect?language=objc)
45// NS_ENUM
46#[repr(transparent)]
47#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
48pub struct NSColorSystemEffect(pub NSInteger);
49impl NSColorSystemEffect {
50    #[doc(alias = "NSColorSystemEffectNone")]
51    pub const None: Self = Self(0);
52    #[doc(alias = "NSColorSystemEffectPressed")]
53    pub const Pressed: Self = Self(1);
54    #[doc(alias = "NSColorSystemEffectDeepPressed")]
55    pub const DeepPressed: Self = Self(2);
56    #[doc(alias = "NSColorSystemEffectDisabled")]
57    pub const Disabled: Self = Self(3);
58    #[doc(alias = "NSColorSystemEffectRollover")]
59    pub const Rollover: Self = Self(4);
60}
61
62unsafe impl Encode for NSColorSystemEffect {
63    const ENCODING: Encoding = NSInteger::ENCODING;
64}
65
66unsafe impl RefEncode for NSColorSystemEffect {
67    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
68}
69
70extern_class!(
71    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolor?language=objc)
72    #[unsafe(super(NSObject))]
73    #[derive(Debug, PartialEq, Eq, Hash)]
74    pub struct NSColor;
75);
76
77unsafe impl Send for NSColor {}
78
79unsafe impl Sync for NSColor {}
80
81extern_conformance!(
82    unsafe impl NSCoding for NSColor {}
83);
84
85extern_conformance!(
86    unsafe impl NSCopying for NSColor {}
87);
88
89unsafe impl CopyingHelper for NSColor {
90    type Result = Self;
91}
92
93extern_conformance!(
94    unsafe impl NSObjectProtocol for NSColor {}
95);
96
97#[cfg(feature = "NSPasteboard")]
98extern_conformance!(
99    unsafe impl NSPasteboardReading for NSColor {}
100);
101
102#[cfg(feature = "NSPasteboard")]
103extern_conformance!(
104    unsafe impl NSPasteboardWriting for NSColor {}
105);
106
107extern_conformance!(
108    unsafe impl NSSecureCoding for NSColor {}
109);
110
111impl NSColor {
112    extern_methods!(
113        #[unsafe(method(init))]
114        #[unsafe(method_family = init)]
115        pub fn init(this: Allocated<Self>) -> Retained<Self>;
116
117        /// # Safety
118        ///
119        /// `coder` possibly has further requirements.
120        #[unsafe(method(initWithCoder:))]
121        #[unsafe(method_family = init)]
122        pub unsafe fn initWithCoder(
123            this: Allocated<Self>,
124            coder: &NSCoder,
125        ) -> Option<Retained<Self>>;
126
127        #[cfg(all(feature = "NSColorSpace", feature = "objc2-core-foundation"))]
128        /// # Safety
129        ///
130        /// `components` must be a valid pointer.
131        #[unsafe(method(colorWithColorSpace:components:count:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn colorWithColorSpace_components_count(
134            space: &NSColorSpace,
135            components: NonNull<CGFloat>,
136            number_of_components: NSInteger,
137        ) -> Retained<NSColor>;
138
139        #[cfg(feature = "objc2-core-foundation")]
140        #[unsafe(method(colorWithSRGBRed:green:blue:alpha:))]
141        #[unsafe(method_family = none)]
142        pub fn colorWithSRGBRed_green_blue_alpha(
143            red: CGFloat,
144            green: CGFloat,
145            blue: CGFloat,
146            alpha: CGFloat,
147        ) -> Retained<NSColor>;
148
149        #[cfg(feature = "objc2-core-foundation")]
150        #[unsafe(method(colorWithGenericGamma22White:alpha:))]
151        #[unsafe(method_family = none)]
152        pub fn colorWithGenericGamma22White_alpha(
153            white: CGFloat,
154            alpha: CGFloat,
155        ) -> Retained<NSColor>;
156
157        #[cfg(feature = "objc2-core-foundation")]
158        #[unsafe(method(colorWithDisplayP3Red:green:blue:alpha:))]
159        #[unsafe(method_family = none)]
160        pub fn colorWithDisplayP3Red_green_blue_alpha(
161            red: CGFloat,
162            green: CGFloat,
163            blue: CGFloat,
164            alpha: CGFloat,
165        ) -> Retained<NSColor>;
166
167        #[cfg(feature = "objc2-core-foundation")]
168        #[unsafe(method(colorWithWhite:alpha:))]
169        #[unsafe(method_family = none)]
170        pub fn colorWithWhite_alpha(white: CGFloat, alpha: CGFloat) -> Retained<NSColor>;
171
172        #[cfg(feature = "objc2-core-foundation")]
173        #[unsafe(method(colorWithRed:green:blue:alpha:))]
174        #[unsafe(method_family = none)]
175        pub fn colorWithRed_green_blue_alpha(
176            red: CGFloat,
177            green: CGFloat,
178            blue: CGFloat,
179            alpha: CGFloat,
180        ) -> Retained<NSColor>;
181
182        #[cfg(feature = "objc2-core-foundation")]
183        #[unsafe(method(colorWithHue:saturation:brightness:alpha:))]
184        #[unsafe(method_family = none)]
185        pub fn colorWithHue_saturation_brightness_alpha(
186            hue: CGFloat,
187            saturation: CGFloat,
188            brightness: CGFloat,
189            alpha: CGFloat,
190        ) -> Retained<NSColor>;
191
192        #[cfg(all(feature = "NSColorSpace", feature = "objc2-core-foundation"))]
193        #[unsafe(method(colorWithColorSpace:hue:saturation:brightness:alpha:))]
194        #[unsafe(method_family = none)]
195        pub fn colorWithColorSpace_hue_saturation_brightness_alpha(
196            space: &NSColorSpace,
197            hue: CGFloat,
198            saturation: CGFloat,
199            brightness: CGFloat,
200            alpha: CGFloat,
201        ) -> Retained<NSColor>;
202
203        #[cfg(feature = "NSColorList")]
204        #[unsafe(method(colorWithCatalogName:colorName:))]
205        #[unsafe(method_family = none)]
206        pub fn colorWithCatalogName_colorName(
207            list_name: &NSColorListName,
208            color_name: &NSColorName,
209        ) -> Option<Retained<NSColor>>;
210
211        #[cfg(feature = "NSColorList")]
212        #[unsafe(method(colorNamed:bundle:))]
213        #[unsafe(method_family = none)]
214        pub fn colorNamed_bundle(
215            name: &NSColorName,
216            bundle: Option<&NSBundle>,
217        ) -> Option<Retained<NSColor>>;
218
219        #[cfg(feature = "NSColorList")]
220        #[unsafe(method(colorNamed:))]
221        #[unsafe(method_family = none)]
222        pub fn colorNamed(name: &NSColorName) -> Option<Retained<NSColor>>;
223
224        #[cfg(all(feature = "NSAppearance", feature = "NSColorList", feature = "block2"))]
225        /// # Safety
226        ///
227        /// `dynamic_provider` block's return must be a valid pointer.
228        #[unsafe(method(colorWithName:dynamicProvider:))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn colorWithName_dynamicProvider(
231            color_name: Option<&NSColorName>,
232            dynamic_provider: &block2::DynBlock<dyn Fn(NonNull<NSAppearance>) -> NonNull<NSColor>>,
233        ) -> Retained<NSColor>;
234
235        #[cfg(feature = "objc2-core-foundation")]
236        #[unsafe(method(colorWithDeviceWhite:alpha:))]
237        #[unsafe(method_family = none)]
238        pub fn colorWithDeviceWhite_alpha(white: CGFloat, alpha: CGFloat) -> Retained<NSColor>;
239
240        #[cfg(feature = "objc2-core-foundation")]
241        #[unsafe(method(colorWithDeviceRed:green:blue:alpha:))]
242        #[unsafe(method_family = none)]
243        pub fn colorWithDeviceRed_green_blue_alpha(
244            red: CGFloat,
245            green: CGFloat,
246            blue: CGFloat,
247            alpha: CGFloat,
248        ) -> Retained<NSColor>;
249
250        #[cfg(feature = "objc2-core-foundation")]
251        #[unsafe(method(colorWithDeviceHue:saturation:brightness:alpha:))]
252        #[unsafe(method_family = none)]
253        pub fn colorWithDeviceHue_saturation_brightness_alpha(
254            hue: CGFloat,
255            saturation: CGFloat,
256            brightness: CGFloat,
257            alpha: CGFloat,
258        ) -> Retained<NSColor>;
259
260        #[cfg(feature = "objc2-core-foundation")]
261        #[unsafe(method(colorWithDeviceCyan:magenta:yellow:black:alpha:))]
262        #[unsafe(method_family = none)]
263        pub fn colorWithDeviceCyan_magenta_yellow_black_alpha(
264            cyan: CGFloat,
265            magenta: CGFloat,
266            yellow: CGFloat,
267            black: CGFloat,
268            alpha: CGFloat,
269        ) -> Retained<NSColor>;
270
271        #[cfg(feature = "objc2-core-foundation")]
272        #[unsafe(method(colorWithCalibratedWhite:alpha:))]
273        #[unsafe(method_family = none)]
274        pub fn colorWithCalibratedWhite_alpha(white: CGFloat, alpha: CGFloat) -> Retained<NSColor>;
275
276        #[cfg(feature = "objc2-core-foundation")]
277        #[unsafe(method(colorWithCalibratedRed:green:blue:alpha:))]
278        #[unsafe(method_family = none)]
279        pub fn colorWithCalibratedRed_green_blue_alpha(
280            red: CGFloat,
281            green: CGFloat,
282            blue: CGFloat,
283            alpha: CGFloat,
284        ) -> Retained<NSColor>;
285
286        #[cfg(feature = "objc2-core-foundation")]
287        #[unsafe(method(colorWithCalibratedHue:saturation:brightness:alpha:))]
288        #[unsafe(method_family = none)]
289        pub fn colorWithCalibratedHue_saturation_brightness_alpha(
290            hue: CGFloat,
291            saturation: CGFloat,
292            brightness: CGFloat,
293            alpha: CGFloat,
294        ) -> Retained<NSColor>;
295
296        #[cfg(feature = "NSImage")]
297        #[unsafe(method(colorWithPatternImage:))]
298        #[unsafe(method_family = none)]
299        pub fn colorWithPatternImage(image: &NSImage) -> Retained<NSColor>;
300
301        #[unsafe(method(type))]
302        #[unsafe(method_family = none)]
303        pub fn r#type(&self) -> NSColorType;
304
305        #[unsafe(method(colorUsingType:))]
306        #[unsafe(method_family = none)]
307        pub fn colorUsingType(&self, r#type: NSColorType) -> Option<Retained<NSColor>>;
308
309        #[cfg(feature = "NSColorSpace")]
310        #[unsafe(method(colorUsingColorSpace:))]
311        #[unsafe(method_family = none)]
312        pub fn colorUsingColorSpace(&self, space: &NSColorSpace) -> Option<Retained<NSColor>>;
313
314        #[cfg(feature = "objc2-core-foundation")]
315        /// Generates an HDR color in the extended sRGB colorspace by applying an exposure to the SDR color defined by the red, green, and blue components. The `red`, `green`, and `blue` components have a nominal range of [0..1], `exposure` is a value >= 0. To produce an HDR color, we process the given color in a linear color space, multiplying component values by `2^exposure`. The produced color will have a `contentHeadroom` equal to the linearized exposure value. Each whole value of exposure produces a color that is twice as bright.
316        #[unsafe(method(colorWithRed:green:blue:alpha:exposure:))]
317        #[unsafe(method_family = none)]
318        pub fn colorWithRed_green_blue_alpha_exposure(
319            red: CGFloat,
320            green: CGFloat,
321            blue: CGFloat,
322            alpha: CGFloat,
323            exposure: CGFloat,
324        ) -> Retained<NSColor>;
325
326        #[cfg(feature = "objc2-core-foundation")]
327        /// Generates an HDR color in the extended sRGB colorspace by applying an exposure to the SDR color defined by the red, green, and blue components. The `red`, `green`, and `blue` components have a nominal range of [0..1], `linearExposure` is a value >= 1. To produce an HDR color, we process the given color in a linear color space, multiplying component values by `linearExposure `. The produced color will have a `contentHeadroom` equal to `linearExposure`. Each doubling of `linearExposure` produces a color that is twice as bright.
328        #[unsafe(method(colorWithRed:green:blue:alpha:linearExposure:))]
329        #[unsafe(method_family = none)]
330        pub fn colorWithRed_green_blue_alpha_linearExposure(
331            red: CGFloat,
332            green: CGFloat,
333            blue: CGFloat,
334            alpha: CGFloat,
335            linear_exposure: CGFloat,
336        ) -> Retained<NSColor>;
337
338        #[cfg(feature = "objc2-core-foundation")]
339        /// Reinterpret the color by applying a new `contentHeadroom` without changing the color components. Changing the `contentHeadroom` redefines the color relative to a different peak white, changing its behavior under tone mapping and the result of calling `standardDynamicRangeColor`. The new color will have a `contentHeadroom` >= 1.0. If called on a color with a color space that does not support extended range, or does not have an equivalent extended range counterpart, this will return `self`.
340        #[unsafe(method(colorByApplyingContentHeadroom:))]
341        #[unsafe(method_family = none)]
342        pub fn colorByApplyingContentHeadroom(
343            &self,
344            content_headroom: CGFloat,
345        ) -> Retained<NSColor>;
346
347        /// In some cases it is useful to recover the color that was base the SDR color that was exposed to generate an HDR color. If a color's `linearExposure` is > 1, then this will return the base SDR color. If the color is not an HDR color, this will return `self`.
348        #[unsafe(method(standardDynamicRangeColor))]
349        #[unsafe(method_family = none)]
350        pub fn standardDynamicRangeColor(&self) -> Retained<NSColor>;
351
352        #[unsafe(method(blackColor))]
353        #[unsafe(method_family = none)]
354        pub fn blackColor() -> Retained<NSColor>;
355
356        #[unsafe(method(darkGrayColor))]
357        #[unsafe(method_family = none)]
358        pub fn darkGrayColor() -> Retained<NSColor>;
359
360        #[unsafe(method(lightGrayColor))]
361        #[unsafe(method_family = none)]
362        pub fn lightGrayColor() -> Retained<NSColor>;
363
364        #[unsafe(method(whiteColor))]
365        #[unsafe(method_family = none)]
366        pub fn whiteColor() -> Retained<NSColor>;
367
368        #[unsafe(method(grayColor))]
369        #[unsafe(method_family = none)]
370        pub fn grayColor() -> Retained<NSColor>;
371
372        #[unsafe(method(redColor))]
373        #[unsafe(method_family = none)]
374        pub fn redColor() -> Retained<NSColor>;
375
376        #[unsafe(method(greenColor))]
377        #[unsafe(method_family = none)]
378        pub fn greenColor() -> Retained<NSColor>;
379
380        #[unsafe(method(blueColor))]
381        #[unsafe(method_family = none)]
382        pub fn blueColor() -> Retained<NSColor>;
383
384        #[unsafe(method(cyanColor))]
385        #[unsafe(method_family = none)]
386        pub fn cyanColor() -> Retained<NSColor>;
387
388        #[unsafe(method(yellowColor))]
389        #[unsafe(method_family = none)]
390        pub fn yellowColor() -> Retained<NSColor>;
391
392        #[unsafe(method(magentaColor))]
393        #[unsafe(method_family = none)]
394        pub fn magentaColor() -> Retained<NSColor>;
395
396        #[unsafe(method(orangeColor))]
397        #[unsafe(method_family = none)]
398        pub fn orangeColor() -> Retained<NSColor>;
399
400        #[unsafe(method(purpleColor))]
401        #[unsafe(method_family = none)]
402        pub fn purpleColor() -> Retained<NSColor>;
403
404        #[unsafe(method(brownColor))]
405        #[unsafe(method_family = none)]
406        pub fn brownColor() -> Retained<NSColor>;
407
408        #[unsafe(method(clearColor))]
409        #[unsafe(method_family = none)]
410        pub fn clearColor() -> Retained<NSColor>;
411
412        #[unsafe(method(labelColor))]
413        #[unsafe(method_family = none)]
414        pub fn labelColor() -> Retained<NSColor>;
415
416        #[unsafe(method(secondaryLabelColor))]
417        #[unsafe(method_family = none)]
418        pub fn secondaryLabelColor() -> Retained<NSColor>;
419
420        #[unsafe(method(tertiaryLabelColor))]
421        #[unsafe(method_family = none)]
422        pub fn tertiaryLabelColor() -> Retained<NSColor>;
423
424        #[unsafe(method(quaternaryLabelColor))]
425        #[unsafe(method_family = none)]
426        pub fn quaternaryLabelColor() -> Retained<NSColor>;
427
428        #[unsafe(method(quinaryLabelColor))]
429        #[unsafe(method_family = none)]
430        pub fn quinaryLabelColor() -> Retained<NSColor>;
431
432        /// Used for large scale images or subtle decorative elements; not for general foreground content.
433        #[unsafe(method(linkColor))]
434        #[unsafe(method_family = none)]
435        pub fn linkColor() -> Retained<NSColor>;
436
437        #[unsafe(method(placeholderTextColor))]
438        #[unsafe(method_family = none)]
439        pub fn placeholderTextColor() -> Retained<NSColor>;
440
441        #[unsafe(method(windowFrameTextColor))]
442        #[unsafe(method_family = none)]
443        pub fn windowFrameTextColor() -> Retained<NSColor>;
444
445        #[unsafe(method(selectedMenuItemTextColor))]
446        #[unsafe(method_family = none)]
447        pub fn selectedMenuItemTextColor() -> Retained<NSColor>;
448
449        #[unsafe(method(alternateSelectedControlTextColor))]
450        #[unsafe(method_family = none)]
451        pub fn alternateSelectedControlTextColor() -> Retained<NSColor>;
452
453        #[unsafe(method(headerTextColor))]
454        #[unsafe(method_family = none)]
455        pub fn headerTextColor() -> Retained<NSColor>;
456
457        #[unsafe(method(separatorColor))]
458        #[unsafe(method_family = none)]
459        pub fn separatorColor() -> Retained<NSColor>;
460
461        #[unsafe(method(gridColor))]
462        #[unsafe(method_family = none)]
463        pub fn gridColor() -> Retained<NSColor>;
464
465        #[unsafe(method(windowBackgroundColor))]
466        #[unsafe(method_family = none)]
467        pub fn windowBackgroundColor() -> Retained<NSColor>;
468
469        #[unsafe(method(underPageBackgroundColor))]
470        #[unsafe(method_family = none)]
471        pub fn underPageBackgroundColor() -> Retained<NSColor>;
472
473        #[unsafe(method(controlBackgroundColor))]
474        #[unsafe(method_family = none)]
475        pub fn controlBackgroundColor() -> Retained<NSColor>;
476
477        #[unsafe(method(selectedContentBackgroundColor))]
478        #[unsafe(method_family = none)]
479        pub fn selectedContentBackgroundColor() -> Retained<NSColor>;
480
481        #[unsafe(method(unemphasizedSelectedContentBackgroundColor))]
482        #[unsafe(method_family = none)]
483        pub fn unemphasizedSelectedContentBackgroundColor() -> Retained<NSColor>;
484
485        #[unsafe(method(alternatingContentBackgroundColors))]
486        #[unsafe(method_family = none)]
487        pub fn alternatingContentBackgroundColors() -> Retained<NSArray<NSColor>>;
488
489        #[unsafe(method(findHighlightColor))]
490        #[unsafe(method_family = none)]
491        pub fn findHighlightColor() -> Retained<NSColor>;
492
493        #[unsafe(method(textColor))]
494        #[unsafe(method_family = none)]
495        pub fn textColor() -> Retained<NSColor>;
496
497        #[unsafe(method(textBackgroundColor))]
498        #[unsafe(method_family = none)]
499        pub fn textBackgroundColor() -> Retained<NSColor>;
500
501        #[unsafe(method(textInsertionPointColor))]
502        #[unsafe(method_family = none)]
503        pub fn textInsertionPointColor() -> Retained<NSColor>;
504
505        #[unsafe(method(selectedTextColor))]
506        #[unsafe(method_family = none)]
507        pub fn selectedTextColor() -> Retained<NSColor>;
508
509        #[unsafe(method(selectedTextBackgroundColor))]
510        #[unsafe(method_family = none)]
511        pub fn selectedTextBackgroundColor() -> Retained<NSColor>;
512
513        #[unsafe(method(unemphasizedSelectedTextBackgroundColor))]
514        #[unsafe(method_family = none)]
515        pub fn unemphasizedSelectedTextBackgroundColor() -> Retained<NSColor>;
516
517        #[unsafe(method(unemphasizedSelectedTextColor))]
518        #[unsafe(method_family = none)]
519        pub fn unemphasizedSelectedTextColor() -> Retained<NSColor>;
520
521        #[unsafe(method(controlColor))]
522        #[unsafe(method_family = none)]
523        pub fn controlColor() -> Retained<NSColor>;
524
525        #[unsafe(method(controlTextColor))]
526        #[unsafe(method_family = none)]
527        pub fn controlTextColor() -> Retained<NSColor>;
528
529        #[unsafe(method(selectedControlColor))]
530        #[unsafe(method_family = none)]
531        pub fn selectedControlColor() -> Retained<NSColor>;
532
533        #[unsafe(method(selectedControlTextColor))]
534        #[unsafe(method_family = none)]
535        pub fn selectedControlTextColor() -> Retained<NSColor>;
536
537        #[unsafe(method(disabledControlTextColor))]
538        #[unsafe(method_family = none)]
539        pub fn disabledControlTextColor() -> Retained<NSColor>;
540
541        #[unsafe(method(keyboardFocusIndicatorColor))]
542        #[unsafe(method_family = none)]
543        pub fn keyboardFocusIndicatorColor() -> Retained<NSColor>;
544
545        #[unsafe(method(scrubberTexturedBackgroundColor))]
546        #[unsafe(method_family = none)]
547        pub fn scrubberTexturedBackgroundColor() -> Retained<NSColor>;
548
549        #[unsafe(method(systemRedColor))]
550        #[unsafe(method_family = none)]
551        pub fn systemRedColor() -> Retained<NSColor>;
552
553        #[unsafe(method(systemGreenColor))]
554        #[unsafe(method_family = none)]
555        pub fn systemGreenColor() -> Retained<NSColor>;
556
557        #[unsafe(method(systemBlueColor))]
558        #[unsafe(method_family = none)]
559        pub fn systemBlueColor() -> Retained<NSColor>;
560
561        #[unsafe(method(systemOrangeColor))]
562        #[unsafe(method_family = none)]
563        pub fn systemOrangeColor() -> Retained<NSColor>;
564
565        #[unsafe(method(systemYellowColor))]
566        #[unsafe(method_family = none)]
567        pub fn systemYellowColor() -> Retained<NSColor>;
568
569        #[unsafe(method(systemBrownColor))]
570        #[unsafe(method_family = none)]
571        pub fn systemBrownColor() -> Retained<NSColor>;
572
573        #[unsafe(method(systemPinkColor))]
574        #[unsafe(method_family = none)]
575        pub fn systemPinkColor() -> Retained<NSColor>;
576
577        #[unsafe(method(systemPurpleColor))]
578        #[unsafe(method_family = none)]
579        pub fn systemPurpleColor() -> Retained<NSColor>;
580
581        #[unsafe(method(systemGrayColor))]
582        #[unsafe(method_family = none)]
583        pub fn systemGrayColor() -> Retained<NSColor>;
584
585        #[unsafe(method(systemTealColor))]
586        #[unsafe(method_family = none)]
587        pub fn systemTealColor() -> Retained<NSColor>;
588
589        #[unsafe(method(systemIndigoColor))]
590        #[unsafe(method_family = none)]
591        pub fn systemIndigoColor() -> Retained<NSColor>;
592
593        #[unsafe(method(systemMintColor))]
594        #[unsafe(method_family = none)]
595        pub fn systemMintColor() -> Retained<NSColor>;
596
597        #[unsafe(method(systemCyanColor))]
598        #[unsafe(method_family = none)]
599        pub fn systemCyanColor() -> Retained<NSColor>;
600
601        /// Fill colors for UI elements.
602        /// These are meant to be used over the background colors, since their alpha component is less than 1.
603        ///
604        /// systemFillColor is appropriate for filling thin shapes, such as the track of a slider.
605        #[unsafe(method(systemFillColor))]
606        #[unsafe(method_family = none)]
607        pub fn systemFillColor() -> Retained<NSColor>;
608
609        /// secondarySystemFillColor is appropriate for filling small-size shapes, such as the backing of a progress indicator.
610        #[unsafe(method(secondarySystemFillColor))]
611        #[unsafe(method_family = none)]
612        pub fn secondarySystemFillColor() -> Retained<NSColor>;
613
614        /// tertiarySystemFillColor is appropriate for filling medium-size shapes,  such as the backing of a switch.
615        #[unsafe(method(tertiarySystemFillColor))]
616        #[unsafe(method_family = none)]
617        pub fn tertiarySystemFillColor() -> Retained<NSColor>;
618
619        /// quaternarySystemFillColor is appropriate for filling large areas, such as a group box or tab pane.
620        #[unsafe(method(quaternarySystemFillColor))]
621        #[unsafe(method_family = none)]
622        pub fn quaternarySystemFillColor() -> Retained<NSColor>;
623
624        /// quinarySystemFillColor is appropriate for filling large areas that require subtle emphasis, such as content of a form..
625        #[unsafe(method(quinarySystemFillColor))]
626        #[unsafe(method_family = none)]
627        pub fn quinarySystemFillColor() -> Retained<NSColor>;
628
629        /// A dynamic color that reflects the user's current preferred accent color. This color automatically updates when the accent color preference changes. Do not make assumptions about the color space of this color, which may change across releases.
630        #[unsafe(method(controlAccentColor))]
631        #[unsafe(method_family = none)]
632        pub fn controlAccentColor() -> Retained<NSColor>;
633
634        #[cfg(feature = "NSCell")]
635        #[unsafe(method(currentControlTint))]
636        #[unsafe(method_family = none)]
637        pub fn currentControlTint() -> NSControlTint;
638
639        #[cfg(feature = "NSCell")]
640        #[deprecated = "NSControlTint does not describe the full range of available control accent colors. Use +[NSColor controlAccentColor] instead."]
641        #[unsafe(method(colorForControlTint:))]
642        #[unsafe(method_family = none)]
643        pub fn colorForControlTint(control_tint: NSControlTint) -> Retained<NSColor>;
644
645        #[unsafe(method(highlightColor))]
646        #[unsafe(method_family = none)]
647        pub fn highlightColor() -> Retained<NSColor>;
648
649        #[unsafe(method(shadowColor))]
650        #[unsafe(method_family = none)]
651        pub fn shadowColor() -> Retained<NSColor>;
652
653        #[cfg(feature = "objc2-core-foundation")]
654        #[unsafe(method(highlightWithLevel:))]
655        #[unsafe(method_family = none)]
656        pub fn highlightWithLevel(&self, val: CGFloat) -> Option<Retained<NSColor>>;
657
658        #[cfg(feature = "objc2-core-foundation")]
659        #[unsafe(method(shadowWithLevel:))]
660        #[unsafe(method_family = none)]
661        pub fn shadowWithLevel(&self, val: CGFloat) -> Option<Retained<NSColor>>;
662
663        /// Returns a color representing the base color with a system defined effect applied to it. This color is safe to create before draw time, as the resolution of the final color only happens when being `-set`, retrieving its `CGColor`, resolving with `-colorWithType:`, etc. The return color type is `.named`.
664        #[unsafe(method(colorWithSystemEffect:))]
665        #[unsafe(method_family = none)]
666        pub fn colorWithSystemEffect(
667            &self,
668            system_effect: NSColorSystemEffect,
669        ) -> Retained<NSColor>;
670
671        #[unsafe(method(set))]
672        #[unsafe(method_family = none)]
673        pub fn set(&self);
674
675        #[unsafe(method(setFill))]
676        #[unsafe(method_family = none)]
677        pub fn setFill(&self);
678
679        #[unsafe(method(setStroke))]
680        #[unsafe(method_family = none)]
681        pub fn setStroke(&self);
682
683        #[cfg(feature = "objc2-core-foundation")]
684        #[unsafe(method(blendedColorWithFraction:ofColor:))]
685        #[unsafe(method_family = none)]
686        pub fn blendedColorWithFraction_ofColor(
687            &self,
688            fraction: CGFloat,
689            color: &NSColor,
690        ) -> Option<Retained<NSColor>>;
691
692        #[cfg(feature = "objc2-core-foundation")]
693        #[unsafe(method(colorWithAlphaComponent:))]
694        #[unsafe(method_family = none)]
695        pub fn colorWithAlphaComponent(&self, alpha: CGFloat) -> Retained<NSColor>;
696
697        #[cfg(feature = "NSColorList")]
698        /// * Methods to get various components of colors. Not all of the methods apply to all colors; if called, they raise. **
699        #[unsafe(method(catalogNameComponent))]
700        #[unsafe(method_family = none)]
701        pub fn catalogNameComponent(&self) -> Retained<NSColorListName>;
702
703        #[cfg(feature = "NSColorList")]
704        #[unsafe(method(colorNameComponent))]
705        #[unsafe(method_family = none)]
706        pub fn colorNameComponent(&self) -> Retained<NSColorName>;
707
708        #[unsafe(method(localizedCatalogNameComponent))]
709        #[unsafe(method_family = none)]
710        pub fn localizedCatalogNameComponent(&self) -> Retained<NSString>;
711
712        #[unsafe(method(localizedColorNameComponent))]
713        #[unsafe(method_family = none)]
714        pub fn localizedColorNameComponent(&self) -> Retained<NSString>;
715
716        #[cfg(feature = "objc2-core-foundation")]
717        #[unsafe(method(redComponent))]
718        #[unsafe(method_family = none)]
719        pub fn redComponent(&self) -> CGFloat;
720
721        #[cfg(feature = "objc2-core-foundation")]
722        #[unsafe(method(greenComponent))]
723        #[unsafe(method_family = none)]
724        pub fn greenComponent(&self) -> CGFloat;
725
726        #[cfg(feature = "objc2-core-foundation")]
727        #[unsafe(method(blueComponent))]
728        #[unsafe(method_family = none)]
729        pub fn blueComponent(&self) -> CGFloat;
730
731        #[cfg(feature = "objc2-core-foundation")]
732        /// # Safety
733        ///
734        /// - `red` must be a valid pointer or null.
735        /// - `green` must be a valid pointer or null.
736        /// - `blue` must be a valid pointer or null.
737        /// - `alpha` must be a valid pointer or null.
738        #[unsafe(method(getRed:green:blue:alpha:))]
739        #[unsafe(method_family = none)]
740        pub unsafe fn getRed_green_blue_alpha(
741            &self,
742            red: *mut CGFloat,
743            green: *mut CGFloat,
744            blue: *mut CGFloat,
745            alpha: *mut CGFloat,
746        );
747
748        #[cfg(feature = "objc2-core-foundation")]
749        #[unsafe(method(hueComponent))]
750        #[unsafe(method_family = none)]
751        pub fn hueComponent(&self) -> CGFloat;
752
753        #[cfg(feature = "objc2-core-foundation")]
754        #[unsafe(method(saturationComponent))]
755        #[unsafe(method_family = none)]
756        pub fn saturationComponent(&self) -> CGFloat;
757
758        #[cfg(feature = "objc2-core-foundation")]
759        #[unsafe(method(brightnessComponent))]
760        #[unsafe(method_family = none)]
761        pub fn brightnessComponent(&self) -> CGFloat;
762
763        #[cfg(feature = "objc2-core-foundation")]
764        /// # Safety
765        ///
766        /// - `hue` must be a valid pointer or null.
767        /// - `saturation` must be a valid pointer or null.
768        /// - `brightness` must be a valid pointer or null.
769        /// - `alpha` must be a valid pointer or null.
770        #[unsafe(method(getHue:saturation:brightness:alpha:))]
771        #[unsafe(method_family = none)]
772        pub unsafe fn getHue_saturation_brightness_alpha(
773            &self,
774            hue: *mut CGFloat,
775            saturation: *mut CGFloat,
776            brightness: *mut CGFloat,
777            alpha: *mut CGFloat,
778        );
779
780        #[cfg(feature = "objc2-core-foundation")]
781        #[unsafe(method(whiteComponent))]
782        #[unsafe(method_family = none)]
783        pub fn whiteComponent(&self) -> CGFloat;
784
785        #[cfg(feature = "objc2-core-foundation")]
786        /// # Safety
787        ///
788        /// - `white` must be a valid pointer or null.
789        /// - `alpha` must be a valid pointer or null.
790        #[unsafe(method(getWhite:alpha:))]
791        #[unsafe(method_family = none)]
792        pub unsafe fn getWhite_alpha(&self, white: *mut CGFloat, alpha: *mut CGFloat);
793
794        #[cfg(feature = "objc2-core-foundation")]
795        #[unsafe(method(cyanComponent))]
796        #[unsafe(method_family = none)]
797        pub fn cyanComponent(&self) -> CGFloat;
798
799        #[cfg(feature = "objc2-core-foundation")]
800        #[unsafe(method(magentaComponent))]
801        #[unsafe(method_family = none)]
802        pub fn magentaComponent(&self) -> CGFloat;
803
804        #[cfg(feature = "objc2-core-foundation")]
805        #[unsafe(method(yellowComponent))]
806        #[unsafe(method_family = none)]
807        pub fn yellowComponent(&self) -> CGFloat;
808
809        #[cfg(feature = "objc2-core-foundation")]
810        #[unsafe(method(blackComponent))]
811        #[unsafe(method_family = none)]
812        pub fn blackComponent(&self) -> CGFloat;
813
814        #[cfg(feature = "objc2-core-foundation")]
815        /// # Safety
816        ///
817        /// - `cyan` must be a valid pointer or null.
818        /// - `magenta` must be a valid pointer or null.
819        /// - `yellow` must be a valid pointer or null.
820        /// - `black` must be a valid pointer or null.
821        /// - `alpha` must be a valid pointer or null.
822        #[unsafe(method(getCyan:magenta:yellow:black:alpha:))]
823        #[unsafe(method_family = none)]
824        pub unsafe fn getCyan_magenta_yellow_black_alpha(
825            &self,
826            cyan: *mut CGFloat,
827            magenta: *mut CGFloat,
828            yellow: *mut CGFloat,
829            black: *mut CGFloat,
830            alpha: *mut CGFloat,
831        );
832
833        #[cfg(feature = "NSColorSpace")]
834        #[unsafe(method(colorSpace))]
835        #[unsafe(method_family = none)]
836        pub fn colorSpace(&self) -> Retained<NSColorSpace>;
837
838        #[unsafe(method(numberOfComponents))]
839        #[unsafe(method_family = none)]
840        pub fn numberOfComponents(&self) -> NSInteger;
841
842        #[cfg(feature = "objc2-core-foundation")]
843        /// # Safety
844        ///
845        /// `components` must be a valid pointer.
846        #[unsafe(method(getComponents:))]
847        #[unsafe(method_family = none)]
848        pub unsafe fn getComponents(&self, components: NonNull<CGFloat>);
849
850        #[cfg(feature = "NSImage")]
851        #[unsafe(method(patternImage))]
852        #[unsafe(method_family = none)]
853        pub fn patternImage(&self) -> Retained<NSImage>;
854
855        #[cfg(feature = "objc2-core-foundation")]
856        #[unsafe(method(alphaComponent))]
857        #[unsafe(method_family = none)]
858        pub fn alphaComponent(&self) -> CGFloat;
859
860        #[cfg(feature = "objc2-core-foundation")]
861        /// For HDR colors, the linear brightness multiplier that was applied when generating the color. Colors created with an exposure by NSColor create CGColors that are tagged with a contentHeadroom value. While CGColors created without a contentHeadroom tag will return 0 from CGColorGetHeadroom, NSColors generated in a similar fashion return a linearExposure of 1.0.
862        #[unsafe(method(linearExposure))]
863        #[unsafe(method_family = none)]
864        pub fn linearExposure(&self) -> CGFloat;
865
866        #[cfg(feature = "NSPasteboard")]
867        #[unsafe(method(colorFromPasteboard:))]
868        #[unsafe(method_family = none)]
869        pub fn colorFromPasteboard(paste_board: &NSPasteboard) -> Option<Retained<NSColor>>;
870
871        #[cfg(feature = "NSPasteboard")]
872        #[unsafe(method(writeToPasteboard:))]
873        #[unsafe(method_family = none)]
874        pub fn writeToPasteboard(&self, paste_board: &NSPasteboard);
875
876        #[unsafe(method(drawSwatchInRect:))]
877        #[unsafe(method_family = none)]
878        pub fn drawSwatchInRect(&self, rect: NSRect);
879
880        #[cfg(feature = "objc2-core-graphics")]
881        #[cfg(target_vendor = "apple")]
882        #[unsafe(method(colorWithCGColor:))]
883        #[unsafe(method_family = none)]
884        pub fn colorWithCGColor(cg_color: &CGColor) -> Option<Retained<NSColor>>;
885
886        #[cfg(feature = "objc2-core-graphics")]
887        #[cfg(target_vendor = "apple")]
888        #[unsafe(method(CGColor))]
889        #[unsafe(method_family = none)]
890        pub fn CGColor(&self) -> Retained<CGColor>;
891
892        #[deprecated = "Use `showsAlpha` in `NSColorPanel` and `supportsAlpha` in `NSColorWell` to control alpha behavior for individual controls."]
893        #[unsafe(method(ignoresAlpha))]
894        #[unsafe(method_family = none)]
895        pub fn ignoresAlpha(mtm: MainThreadMarker) -> bool;
896
897        /// Setter for [`ignoresAlpha`][Self::ignoresAlpha].
898        #[deprecated = "Use `showsAlpha` in `NSColorPanel` and `supportsAlpha` in `NSColorWell` to control alpha behavior for individual controls."]
899        #[unsafe(method(setIgnoresAlpha:))]
900        #[unsafe(method_family = none)]
901        pub fn setIgnoresAlpha(ignores_alpha: bool, mtm: MainThreadMarker);
902    );
903}
904
905/// Methods declared on superclass `NSObject`.
906impl NSColor {
907    extern_methods!(
908        #[unsafe(method(new))]
909        #[unsafe(method_family = new)]
910        pub fn new() -> Retained<Self>;
911    );
912}
913
914impl DefaultRetained for NSColor {
915    #[inline]
916    fn default_retained() -> Retained<Self> {
917        Self::new()
918    }
919}
920
921/// NSDeprecated.
922impl NSColor {
923    extern_methods!(
924        /// Historically used as the inner border highlight color for beveled buttons. No longer used.
925        #[deprecated = "Use a color that matches the semantics being used, such as `separatorColor`"]
926        #[unsafe(method(controlHighlightColor))]
927        #[unsafe(method_family = none)]
928        pub fn controlHighlightColor() -> Retained<NSColor>;
929
930        /// Historically used as the outer border highlight color for beveled buttons. No longer used.
931        #[deprecated = "Use a color that matches the semantics being used, such as `separatorColor`"]
932        #[unsafe(method(controlLightHighlightColor))]
933        #[unsafe(method_family = none)]
934        pub fn controlLightHighlightColor() -> Retained<NSColor>;
935
936        /// Historically used as the inner border shadow color for beveled buttons. No longer used.
937        #[deprecated = "Use a color that matches the semantics being used, such as `separatorColor`"]
938        #[unsafe(method(controlShadowColor))]
939        #[unsafe(method_family = none)]
940        pub fn controlShadowColor() -> Retained<NSColor>;
941
942        /// Historically used as the outer border shadow color for beveled buttons. No longer used.
943        #[deprecated = "Use a color that matches the semantics being used, such as `separatorColor`"]
944        #[unsafe(method(controlDarkShadowColor))]
945        #[unsafe(method_family = none)]
946        pub fn controlDarkShadowColor() -> Retained<NSColor>;
947
948        /// Historically used as the color of scroll bars. No longer used.
949        #[deprecated = "Use NSScroller instead"]
950        #[unsafe(method(scrollBarColor))]
951        #[unsafe(method_family = none)]
952        pub fn scrollBarColor() -> Retained<NSColor>;
953
954        /// Historically used as the color of scroll bar knobs. No longer used.
955        #[deprecated = "Use NSScroller instead"]
956        #[unsafe(method(knobColor))]
957        #[unsafe(method_family = none)]
958        pub fn knobColor() -> Retained<NSColor>;
959
960        /// Historically used as the color of scroll bar knobs being dragged. No longer used.
961        #[deprecated = "Use NSScroller instead"]
962        #[unsafe(method(selectedKnobColor))]
963        #[unsafe(method_family = none)]
964        pub fn selectedKnobColor() -> Retained<NSColor>;
965
966        /// Historically used as the color of the window chrome, which is no longer able to be represented by a color. No longer used.
967        #[deprecated = "Use NSVisualEffectMaterialTitlebar"]
968        #[unsafe(method(windowFrameColor))]
969        #[unsafe(method_family = none)]
970        pub fn windowFrameColor() -> Retained<NSColor>;
971
972        /// Historically used as the color of selected menu items, which is no longer a color but a tinted blur effect. No longer used.
973        #[deprecated = "Use NSVisualEffectMaterialSelection"]
974        #[unsafe(method(selectedMenuItemColor))]
975        #[unsafe(method_family = none)]
976        pub fn selectedMenuItemColor() -> Retained<NSColor>;
977
978        /// Historically used as the color of table headers, which is no longer a color but a tinted blur effect.
979        #[deprecated = "Use NSVisualEffectMaterialHeaderView"]
980        #[unsafe(method(headerColor))]
981        #[unsafe(method_family = none)]
982        pub fn headerColor() -> Retained<NSColor>;
983
984        /// The background color of selected content or text that is unemphasized. Older alias for +unemphasizedSelectedContentBackgroundColor and +unemphasizedSelectedTextBackgroundColor
985        #[deprecated]
986        #[unsafe(method(secondarySelectedControlColor))]
987        #[unsafe(method_family = none)]
988        pub fn secondarySelectedControlColor() -> Retained<NSColor>;
989
990        /// The background color of selected and emphasized (focused) content: table views rows, collection views, etc. Older alias for +selectedContentBackgroundColor
991        #[deprecated]
992        #[unsafe(method(alternateSelectedControlColor))]
993        #[unsafe(method_family = none)]
994        pub fn alternateSelectedControlColor() -> Retained<NSColor>;
995
996        /// The background colors for alternating content items: such as table view rows, collection view items. Older alias for +alternatingContentBackgroundColors
997        #[deprecated]
998        #[unsafe(method(controlAlternatingRowBackgroundColors))]
999        #[unsafe(method_family = none)]
1000        pub fn controlAlternatingRowBackgroundColors() -> Retained<NSArray<NSColor>>;
1001
1002        #[cfg(feature = "NSGraphics")]
1003        #[deprecated = "Use -type and NSColorType instead"]
1004        #[unsafe(method(colorSpaceName))]
1005        #[unsafe(method_family = none)]
1006        pub fn colorSpaceName(&self) -> Retained<NSColorSpaceName>;
1007
1008        #[cfg(feature = "NSGraphics")]
1009        /// # Safety
1010        ///
1011        /// `device_description` generic should be of the correct type.
1012        #[deprecated = "Use -colorUsingType: or -colorUsingColorSpace: instead"]
1013        #[unsafe(method(colorUsingColorSpaceName:device:))]
1014        #[unsafe(method_family = none)]
1015        pub unsafe fn colorUsingColorSpaceName_device(
1016            &self,
1017            name: Option<&NSColorSpaceName>,
1018            device_description: Option<&NSDictionary<NSDeviceDescriptionKey, AnyObject>>,
1019        ) -> Option<Retained<NSColor>>;
1020
1021        #[cfg(feature = "NSGraphics")]
1022        #[deprecated = "Use -colorUsingType: or -colorUsingColorSpace: instead"]
1023        #[unsafe(method(colorUsingColorSpaceName:))]
1024        #[unsafe(method_family = none)]
1025        pub fn colorUsingColorSpaceName(
1026            &self,
1027            name: &NSColorSpaceName,
1028        ) -> Option<Retained<NSColor>>;
1029    );
1030}
1031
1032/// NSQuartzCoreAdditions.
1033impl NSColor {
1034    extern_methods!(
1035        #[cfg(feature = "objc2-core-image")]
1036        #[cfg(target_vendor = "apple")]
1037        #[unsafe(method(colorWithCIColor:))]
1038        #[unsafe(method_family = none)]
1039        pub fn colorWithCIColor(color: &CIColor) -> Retained<NSColor>;
1040    );
1041}
1042
1043mod private_CIColorNSAppKitAdditions {
1044    pub trait Sealed {}
1045}
1046
1047/// Category "NSAppKitAdditions" on [`CIColor`].
1048#[doc(alias = "NSAppKitAdditions")]
1049pub unsafe trait CIColorNSAppKitAdditions:
1050    ClassType + Sized + private_CIColorNSAppKitAdditions::Sealed
1051{
1052    extern_methods!(
1053        #[unsafe(method(initWithColor:))]
1054        #[unsafe(method_family = init)]
1055        fn initWithColor(this: Allocated<Self>, color: &NSColor) -> Option<Retained<Self>>;
1056    );
1057}
1058
1059#[cfg(feature = "objc2-core-image")]
1060#[cfg(target_vendor = "apple")]
1061impl private_CIColorNSAppKitAdditions::Sealed for CIColor {}
1062#[cfg(feature = "objc2-core-image")]
1063#[cfg(target_vendor = "apple")]
1064unsafe impl CIColorNSAppKitAdditions for CIColor {}
1065
1066extern "C" {
1067    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nssystemcolorsdidchangenotification?language=objc)
1068    pub static NSSystemColorsDidChangeNotification: &'static NSNotificationName;
1069}