use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSGestureRecognizerState(pub NSInteger);
impl NSGestureRecognizerState {
#[doc(alias = "NSGestureRecognizerStatePossible")]
pub const Possible: Self = Self(0);
#[doc(alias = "NSGestureRecognizerStateBegan")]
pub const Began: Self = Self(1);
#[doc(alias = "NSGestureRecognizerStateChanged")]
pub const Changed: Self = Self(2);
#[doc(alias = "NSGestureRecognizerStateEnded")]
pub const Ended: Self = Self(3);
#[doc(alias = "NSGestureRecognizerStateCancelled")]
pub const Cancelled: Self = Self(4);
#[doc(alias = "NSGestureRecognizerStateFailed")]
pub const Failed: Self = Self(5);
#[doc(alias = "NSGestureRecognizerStateRecognized")]
pub const Recognized: Self = Self(NSGestureRecognizerState::Ended.0);
}
unsafe impl Encode for NSGestureRecognizerState {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSGestureRecognizerState {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSGestureRecognizer;
);
extern_conformance!(
unsafe impl NSCoding for NSGestureRecognizer {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSGestureRecognizer {}
);
impl NSGestureRecognizer {
extern_methods!(
#[unsafe(method(initWithTarget:action:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithTarget_action(
this: Allocated<Self>,
target: Option<&AnyObject>,
action: Option<Sel>,
) -> Retained<Self>;
#[unsafe(method(initWithCoder:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
#[unsafe(method(target))]
#[unsafe(method_family = none)]
pub fn target(&self) -> Option<Retained<AnyObject>>;
#[unsafe(method(setTarget:))]
#[unsafe(method_family = none)]
pub unsafe fn setTarget(&self, target: Option<&AnyObject>);
#[unsafe(method(action))]
#[unsafe(method_family = none)]
pub fn action(&self) -> Option<Sel>;
#[unsafe(method(setAction:))]
#[unsafe(method_family = none)]
pub unsafe fn setAction(&self, action: Option<Sel>);
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub fn delegate(&self)
-> Option<Retained<ProtocolObject<dyn NSGestureRecognizerDelegate>>>;
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn NSGestureRecognizerDelegate>>,
);
#[unsafe(method(isEnabled))]
#[unsafe(method_family = none)]
pub fn isEnabled(&self) -> bool;
#[unsafe(method(setEnabled:))]
#[unsafe(method_family = none)]
pub fn setEnabled(&self, enabled: bool);
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
#[unsafe(method(view))]
#[unsafe(method_family = none)]
pub fn view(&self) -> Option<Retained<NSView>>;
#[cfg(feature = "NSPressureConfiguration")]
#[unsafe(method(pressureConfiguration))]
#[unsafe(method_family = none)]
pub fn pressureConfiguration(&self) -> Retained<NSPressureConfiguration>;
#[cfg(feature = "NSPressureConfiguration")]
#[unsafe(method(setPressureConfiguration:))]
#[unsafe(method_family = none)]
pub fn setPressureConfiguration(&self, pressure_configuration: &NSPressureConfiguration);
#[unsafe(method(delaysPrimaryMouseButtonEvents))]
#[unsafe(method_family = none)]
pub fn delaysPrimaryMouseButtonEvents(&self) -> bool;
#[unsafe(method(setDelaysPrimaryMouseButtonEvents:))]
#[unsafe(method_family = none)]
pub fn setDelaysPrimaryMouseButtonEvents(&self, delays_primary_mouse_button_events: bool);
#[unsafe(method(delaysSecondaryMouseButtonEvents))]
#[unsafe(method_family = none)]
pub fn delaysSecondaryMouseButtonEvents(&self) -> bool;
#[unsafe(method(setDelaysSecondaryMouseButtonEvents:))]
#[unsafe(method_family = none)]
pub fn setDelaysSecondaryMouseButtonEvents(
&self,
delays_secondary_mouse_button_events: bool,
);
#[unsafe(method(delaysOtherMouseButtonEvents))]
#[unsafe(method_family = none)]
pub fn delaysOtherMouseButtonEvents(&self) -> bool;
#[unsafe(method(setDelaysOtherMouseButtonEvents:))]
#[unsafe(method_family = none)]
pub fn setDelaysOtherMouseButtonEvents(&self, delays_other_mouse_button_events: bool);
#[unsafe(method(delaysKeyEvents))]
#[unsafe(method_family = none)]
pub fn delaysKeyEvents(&self) -> bool;
#[unsafe(method(setDelaysKeyEvents:))]
#[unsafe(method_family = none)]
pub fn setDelaysKeyEvents(&self, delays_key_events: bool);
#[unsafe(method(delaysMagnificationEvents))]
#[unsafe(method_family = none)]
pub fn delaysMagnificationEvents(&self) -> bool;
#[unsafe(method(setDelaysMagnificationEvents:))]
#[unsafe(method_family = none)]
pub fn setDelaysMagnificationEvents(&self, delays_magnification_events: bool);
#[unsafe(method(delaysRotationEvents))]
#[unsafe(method_family = none)]
pub fn delaysRotationEvents(&self) -> bool;
#[unsafe(method(setDelaysRotationEvents:))]
#[unsafe(method_family = none)]
pub fn setDelaysRotationEvents(&self, delays_rotation_events: bool);
#[cfg(all(feature = "NSResponder", feature = "NSView"))]
#[unsafe(method(locationInView:))]
#[unsafe(method_family = none)]
pub fn locationInView(&self, view: Option<&NSView>) -> NSPoint;
#[unsafe(method(name))]
#[unsafe(method_family = none)]
pub fn name(&self) -> Option<Retained<NSString>>;
#[unsafe(method(setName:))]
#[unsafe(method_family = none)]
pub fn setName(&self, name: Option<&NSString>);
#[cfg(feature = "NSEvent")]
#[unsafe(method(modifierFlags))]
#[unsafe(method_family = none)]
pub fn modifierFlags(&self) -> NSEventModifierFlags;
);
}
impl NSGestureRecognizer {
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(mtm: MainThreadMarker) -> Retained<Self>;
);
}
impl NSGestureRecognizer {
extern_methods!(
#[cfg(feature = "NSTouch")]
#[unsafe(method(allowedTouchTypes))]
#[unsafe(method_family = none)]
pub fn allowedTouchTypes(&self) -> NSTouchTypeMask;
#[cfg(feature = "NSTouch")]
#[unsafe(method(setAllowedTouchTypes:))]
#[unsafe(method_family = none)]
pub fn setAllowedTouchTypes(&self, allowed_touch_types: NSTouchTypeMask);
);
}
extern_protocol!(
pub unsafe trait NSGestureRecognizerDelegate: NSObjectProtocol + MainThreadOnly {
#[cfg(feature = "NSEvent")]
#[optional]
#[unsafe(method(gestureRecognizer:shouldAttemptToRecognizeWithEvent:))]
#[unsafe(method_family = none)]
fn gestureRecognizer_shouldAttemptToRecognizeWithEvent(
&self,
gesture_recognizer: &NSGestureRecognizer,
event: &NSEvent,
) -> bool;
#[optional]
#[unsafe(method(gestureRecognizerShouldBegin:))]
#[unsafe(method_family = none)]
fn gestureRecognizerShouldBegin(&self, gesture_recognizer: &NSGestureRecognizer) -> bool;
#[optional]
#[unsafe(method(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:))]
#[unsafe(method_family = none)]
fn gestureRecognizer_shouldRecognizeSimultaneouslyWithGestureRecognizer(
&self,
gesture_recognizer: &NSGestureRecognizer,
other_gesture_recognizer: &NSGestureRecognizer,
) -> bool;
#[optional]
#[unsafe(method(gestureRecognizer:shouldRequireFailureOfGestureRecognizer:))]
#[unsafe(method_family = none)]
fn gestureRecognizer_shouldRequireFailureOfGestureRecognizer(
&self,
gesture_recognizer: &NSGestureRecognizer,
other_gesture_recognizer: &NSGestureRecognizer,
) -> bool;
#[optional]
#[unsafe(method(gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer:))]
#[unsafe(method_family = none)]
fn gestureRecognizer_shouldBeRequiredToFailByGestureRecognizer(
&self,
gesture_recognizer: &NSGestureRecognizer,
other_gesture_recognizer: &NSGestureRecognizer,
) -> bool;
#[cfg(feature = "NSTouch")]
#[optional]
#[unsafe(method(gestureRecognizer:shouldReceiveTouch:))]
#[unsafe(method_family = none)]
fn gestureRecognizer_shouldReceiveTouch(
&self,
gesture_recognizer: &NSGestureRecognizer,
touch: &NSTouch,
) -> bool;
}
);
impl NSGestureRecognizer {
extern_methods!(
#[unsafe(method(setState:))]
#[unsafe(method_family = none)]
pub fn setState(&self, state: NSGestureRecognizerState);
#[unsafe(method(reset))]
#[unsafe(method_family = none)]
pub fn reset(&self);
#[unsafe(method(canPreventGestureRecognizer:))]
#[unsafe(method_family = none)]
pub fn canPreventGestureRecognizer(
&self,
prevented_gesture_recognizer: &NSGestureRecognizer,
) -> bool;
#[unsafe(method(canBePreventedByGestureRecognizer:))]
#[unsafe(method_family = none)]
pub fn canBePreventedByGestureRecognizer(
&self,
preventing_gesture_recognizer: &NSGestureRecognizer,
) -> bool;
#[unsafe(method(shouldRequireFailureOfGestureRecognizer:))]
#[unsafe(method_family = none)]
pub fn shouldRequireFailureOfGestureRecognizer(
&self,
other_gesture_recognizer: &NSGestureRecognizer,
) -> bool;
#[unsafe(method(shouldBeRequiredToFailByGestureRecognizer:))]
#[unsafe(method_family = none)]
pub fn shouldBeRequiredToFailByGestureRecognizer(
&self,
other_gesture_recognizer: &NSGestureRecognizer,
) -> bool;
#[cfg(feature = "NSEvent")]
#[unsafe(method(mouseDown:))]
#[unsafe(method_family = none)]
pub fn mouseDown(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(rightMouseDown:))]
#[unsafe(method_family = none)]
pub fn rightMouseDown(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(otherMouseDown:))]
#[unsafe(method_family = none)]
pub fn otherMouseDown(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(mouseUp:))]
#[unsafe(method_family = none)]
pub fn mouseUp(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(rightMouseUp:))]
#[unsafe(method_family = none)]
pub fn rightMouseUp(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(otherMouseUp:))]
#[unsafe(method_family = none)]
pub fn otherMouseUp(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(mouseDragged:))]
#[unsafe(method_family = none)]
pub fn mouseDragged(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(rightMouseDragged:))]
#[unsafe(method_family = none)]
pub fn rightMouseDragged(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(otherMouseDragged:))]
#[unsafe(method_family = none)]
pub fn otherMouseDragged(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(mouseCancelled:))]
#[unsafe(method_family = none)]
pub fn mouseCancelled(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(keyDown:))]
#[unsafe(method_family = none)]
pub fn keyDown(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(keyUp:))]
#[unsafe(method_family = none)]
pub fn keyUp(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(flagsChanged:))]
#[unsafe(method_family = none)]
pub fn flagsChanged(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(tabletPoint:))]
#[unsafe(method_family = none)]
pub fn tabletPoint(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(magnifyWithEvent:))]
#[unsafe(method_family = none)]
pub fn magnifyWithEvent(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(rotateWithEvent:))]
#[unsafe(method_family = none)]
pub fn rotateWithEvent(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(pressureChangeWithEvent:))]
#[unsafe(method_family = none)]
pub fn pressureChangeWithEvent(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(touchesBeganWithEvent:))]
#[unsafe(method_family = none)]
pub fn touchesBeganWithEvent(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(touchesMovedWithEvent:))]
#[unsafe(method_family = none)]
pub fn touchesMovedWithEvent(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(touchesEndedWithEvent:))]
#[unsafe(method_family = none)]
pub fn touchesEndedWithEvent(&self, event: &NSEvent);
#[cfg(feature = "NSEvent")]
#[unsafe(method(touchesCancelledWithEvent:))]
#[unsafe(method_family = none)]
pub fn touchesCancelledWithEvent(&self, event: &NSEvent);
);
}