objc2-app-kit 0.3.2

Bindings to the AppKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

extern_class!(
    /// Manages a color sampling interface to allow the user to select a color from their screen.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorsampler?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSColorSampler;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NSColorSampler {}
);

impl NSColorSampler {
    extern_methods!(
        #[cfg(all(feature = "NSColor", feature = "block2"))]
        /// The primary method for NSColorSampler.
        ///
        /// 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`.
        ///
        /// The calling NSColorSampler instance is retained until the sampling session is completed.
        #[unsafe(method(showSamplerWithSelectionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn showSamplerWithSelectionHandler(
            &self,
            selection_handler: &block2::DynBlock<dyn Fn(*mut NSColor)>,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl NSColorSampler {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for NSColorSampler {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}