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::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstouchphase?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTouchPhase(pub NSUInteger);
bitflags::bitflags! {
    impl NSTouchPhase: NSUInteger {
        #[doc(alias = "NSTouchPhaseBegan")]
        const Began = 1<<0;
        #[doc(alias = "NSTouchPhaseMoved")]
        const Moved = 1<<1;
        #[doc(alias = "NSTouchPhaseStationary")]
        const Stationary = 1<<2;
        #[doc(alias = "NSTouchPhaseEnded")]
        const Ended = 1<<3;
        #[doc(alias = "NSTouchPhaseCancelled")]
        const Cancelled = 1<<4;
        #[doc(alias = "NSTouchPhaseTouching")]
        const Touching = NSTouchPhase::Began.0|NSTouchPhase::Moved.0|NSTouchPhase::Stationary.0;
        #[doc(alias = "NSTouchPhaseAny")]
        const Any = NSUIntegerMax as _;
    }
}

unsafe impl Encode for NSTouchPhase {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSTouchPhase {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstouchtype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTouchType(pub NSInteger);
impl NSTouchType {
    #[doc(alias = "NSTouchTypeDirect")]
    pub const Direct: Self = Self(0);
    #[doc(alias = "NSTouchTypeIndirect")]
    pub const Indirect: Self = Self(1);
}

unsafe impl Encode for NSTouchType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSTouchType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstouchtypemask?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSTouchTypeMask(pub NSUInteger);
bitflags::bitflags! {
    impl NSTouchTypeMask: NSUInteger {
        #[doc(alias = "NSTouchTypeMaskDirect")]
        const Direct = 1<<NSTouchType::Direct.0;
        #[doc(alias = "NSTouchTypeMaskIndirect")]
        const Indirect = 1<<NSTouchType::Indirect.0;
    }
}

unsafe impl Encode for NSTouchTypeMask {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSTouchTypeMask {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

impl NSTouchTypeMask {
    // TODO: pub fn NSTouchTypeMaskFromType(r#type: NSTouchType,) -> NSTouchTypeMask;
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstouch?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSTouch;
);

unsafe impl Send for NSTouch {}

unsafe impl Sync for NSTouch {}

extern_conformance!(
    unsafe impl NSCopying for NSTouch {}
);

unsafe impl CopyingHelper for NSTouch {
    type Result = Self;
}

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

impl NSTouch {
    extern_methods!(
        #[unsafe(method(identity))]
        #[unsafe(method_family = none)]
        pub fn identity(&self) -> Retained<AnyObject /* NSObjectProtocol+ NSCopying */>;

        #[unsafe(method(phase))]
        #[unsafe(method_family = none)]
        pub fn phase(&self) -> NSTouchPhase;

        #[unsafe(method(normalizedPosition))]
        #[unsafe(method_family = none)]
        pub fn normalizedPosition(&self) -> NSPoint;

        #[unsafe(method(isResting))]
        #[unsafe(method_family = none)]
        pub fn isResting(&self) -> bool;

        #[unsafe(method(device))]
        #[unsafe(method_family = none)]
        pub fn device(&self) -> Option<Retained<AnyObject>>;

        #[unsafe(method(deviceSize))]
        #[unsafe(method_family = none)]
        pub fn deviceSize(&self) -> NSSize;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSTouch {
    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 NSTouch {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

/// NSTouchBar.
impl NSTouch {
    extern_methods!(
        #[unsafe(method(type))]
        #[unsafe(method_family = none)]
        pub fn r#type(&self) -> NSTouchType;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[unsafe(method(locationInView:))]
        #[unsafe(method_family = none)]
        pub fn locationInView(&self, view: Option<&NSView>) -> NSPoint;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[unsafe(method(previousLocationInView:))]
        #[unsafe(method_family = none)]
        pub fn previousLocationInView(&self, view: Option<&NSView>) -> NSPoint;
    );
}