objc2_app_kit/generated/
NSColorSampler.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
7use crate::*;
8
9extern_class!(
10    /// Manages a color sampling interface to allow the user to select a color from their screen.
11    ///
12    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorsampler?language=objc)
13    #[unsafe(super(NSObject))]
14    #[derive(Debug, PartialEq, Eq, Hash)]
15    pub struct NSColorSampler;
16);
17
18extern_conformance!(
19    unsafe impl NSObjectProtocol for NSColorSampler {}
20);
21
22impl NSColorSampler {
23    extern_methods!(
24        #[cfg(all(feature = "NSColor", feature = "block2"))]
25        /// The primary method for NSColorSampler.
26        ///
27        /// Begins or attaches to an existing color sampling session which presents UI to the user for selecting a color from their screen. The handler will be called on the main thread when the user completes the session (either by selection, or cancelation). In the event of user-cancellation, `colorSelectionHandler` will be called with `nil`.
28        ///
29        /// The calling NSColorSampler instance is retained until the sampling session is completed.
30        #[unsafe(method(showSamplerWithSelectionHandler:))]
31        #[unsafe(method_family = none)]
32        pub unsafe fn showSamplerWithSelectionHandler(
33            &self,
34            selection_handler: &block2::DynBlock<dyn Fn(*mut NSColor)>,
35        );
36    );
37}
38
39/// Methods declared on superclass `NSObject`.
40impl NSColorSampler {
41    extern_methods!(
42        #[unsafe(method(init))]
43        #[unsafe(method_family = init)]
44        pub fn init(this: Allocated<Self>) -> Retained<Self>;
45
46        #[unsafe(method(new))]
47        #[unsafe(method_family = new)]
48        pub fn new() -> Retained<Self>;
49    );
50}
51
52impl DefaultRetained for NSColorSampler {
53    #[inline]
54    fn default_retained() -> Retained<Self> {
55        Self::new()
56    }
57}