use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIGestureRecognizerState(pub NSInteger);
impl UIGestureRecognizerState {
#[doc(alias = "UIGestureRecognizerStatePossible")]
pub const Possible: Self = Self(0);
#[doc(alias = "UIGestureRecognizerStateBegan")]
pub const Began: Self = Self(1);
#[doc(alias = "UIGestureRecognizerStateChanged")]
pub const Changed: Self = Self(2);
#[doc(alias = "UIGestureRecognizerStateEnded")]
pub const Ended: Self = Self(3);
#[doc(alias = "UIGestureRecognizerStateCancelled")]
pub const Cancelled: Self = Self(4);
#[doc(alias = "UIGestureRecognizerStateFailed")]
pub const Failed: Self = Self(5);
#[doc(alias = "UIGestureRecognizerStateRecognized")]
pub const Recognized: Self = Self(UIGestureRecognizerState::Ended.0);
}
unsafe impl Encode for UIGestureRecognizerState {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UIGestureRecognizerState {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UIGestureRecognizer;
unsafe impl ClassType for UIGestureRecognizer {
type Super = NSObject;
type Mutability = MainThreadOnly;
}
);
unsafe impl NSObjectProtocol for UIGestureRecognizer {}
extern_methods!(
unsafe impl UIGestureRecognizer {
#[method_id(@__retain_semantics Init initWithTarget:action:)]
pub unsafe fn initWithTarget_action(
this: Allocated<Self>,
target: Option<&AnyObject>,
action: Option<Sel>,
) -> Retained<Self>;
#[method_id(@__retain_semantics Init init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[method_id(@__retain_semantics Init initWithCoder:)]
pub unsafe fn initWithCoder(
this: Allocated<Self>,
coder: &NSCoder,
) -> Option<Retained<Self>>;
#[method(addTarget:action:)]
pub unsafe fn addTarget_action(&self, target: &AnyObject, action: Sel);
#[method(removeTarget:action:)]
pub unsafe fn removeTarget_action(&self, target: Option<&AnyObject>, action: Option<Sel>);
#[method_id(@__retain_semantics Other delegate)]
pub fn delegate(&self)
-> Option<Retained<ProtocolObject<dyn UIGestureRecognizerDelegate>>>;
#[method(setDelegate:)]
pub fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn UIGestureRecognizerDelegate>>,
);
#[method(isEnabled)]
pub unsafe fn isEnabled(&self) -> bool;
#[method(setEnabled:)]
pub unsafe fn setEnabled(&self, enabled: bool);
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
#[method_id(@__retain_semantics Other view)]
pub unsafe fn view(&self) -> Option<Retained<UIView>>;
#[method(cancelsTouchesInView)]
pub unsafe fn cancelsTouchesInView(&self) -> bool;
#[method(setCancelsTouchesInView:)]
pub unsafe fn setCancelsTouchesInView(&self, cancels_touches_in_view: bool);
#[method(delaysTouchesBegan)]
pub unsafe fn delaysTouchesBegan(&self) -> bool;
#[method(setDelaysTouchesBegan:)]
pub unsafe fn setDelaysTouchesBegan(&self, delays_touches_began: bool);
#[method(delaysTouchesEnded)]
pub unsafe fn delaysTouchesEnded(&self) -> bool;
#[method(setDelaysTouchesEnded:)]
pub unsafe fn setDelaysTouchesEnded(&self, delays_touches_ended: bool);
#[method_id(@__retain_semantics Other allowedTouchTypes)]
pub unsafe fn allowedTouchTypes(&self) -> Retained<NSArray<NSNumber>>;
#[method(setAllowedTouchTypes:)]
pub unsafe fn setAllowedTouchTypes(&self, allowed_touch_types: &NSArray<NSNumber>);
#[method_id(@__retain_semantics Other allowedPressTypes)]
pub unsafe fn allowedPressTypes(&self) -> Retained<NSArray<NSNumber>>;
#[method(setAllowedPressTypes:)]
pub unsafe fn setAllowedPressTypes(&self, allowed_press_types: &NSArray<NSNumber>);
#[method(requiresExclusiveTouchType)]
pub unsafe fn requiresExclusiveTouchType(&self) -> bool;
#[method(setRequiresExclusiveTouchType:)]
pub unsafe fn setRequiresExclusiveTouchType(&self, requires_exclusive_touch_type: bool);
#[method(requireGestureRecognizerToFail:)]
pub unsafe fn requireGestureRecognizerToFail(
&self,
other_gesture_recognizer: &UIGestureRecognizer,
);
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
#[method(locationInView:)]
pub unsafe fn locationInView(&self, view: Option<&UIView>) -> CGPoint;
#[method(numberOfTouches)]
pub unsafe fn numberOfTouches(&self) -> NSUInteger;
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
#[method(locationOfTouch:inView:)]
pub unsafe fn locationOfTouch_inView(
&self,
touch_index: NSUInteger,
view: Option<&UIView>,
) -> CGPoint;
#[method_id(@__retain_semantics Other name)]
pub unsafe fn name(&self) -> Option<Retained<NSString>>;
#[method(setName:)]
pub unsafe fn setName(&self, name: Option<&NSString>);
#[cfg(feature = "UICommand")]
#[method(modifierFlags)]
pub unsafe fn modifierFlags(&self) -> UIKeyModifierFlags;
#[cfg(feature = "UIEvent")]
#[method(buttonMask)]
pub unsafe fn buttonMask(&self) -> UIEventButtonMask;
}
);
extern_methods!(
unsafe impl UIGestureRecognizer {
#[method_id(@__retain_semantics New new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
}
);
extern_protocol!(
pub unsafe trait UIGestureRecognizerDelegate:
NSObjectProtocol + IsMainThreadOnly
{
#[optional]
#[method(gestureRecognizerShouldBegin:)]
unsafe fn gestureRecognizerShouldBegin(
&self,
gesture_recognizer: &UIGestureRecognizer,
) -> bool;
#[optional]
#[method(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:)]
unsafe fn gestureRecognizer_shouldRecognizeSimultaneouslyWithGestureRecognizer(
&self,
gesture_recognizer: &UIGestureRecognizer,
other_gesture_recognizer: &UIGestureRecognizer,
) -> bool;
#[optional]
#[method(gestureRecognizer:shouldRequireFailureOfGestureRecognizer:)]
unsafe fn gestureRecognizer_shouldRequireFailureOfGestureRecognizer(
&self,
gesture_recognizer: &UIGestureRecognizer,
other_gesture_recognizer: &UIGestureRecognizer,
) -> bool;
#[optional]
#[method(gestureRecognizer:shouldBeRequiredToFailByGestureRecognizer:)]
unsafe fn gestureRecognizer_shouldBeRequiredToFailByGestureRecognizer(
&self,
gesture_recognizer: &UIGestureRecognizer,
other_gesture_recognizer: &UIGestureRecognizer,
) -> bool;
#[cfg(feature = "UITouch")]
#[optional]
#[method(gestureRecognizer:shouldReceiveTouch:)]
unsafe fn gestureRecognizer_shouldReceiveTouch(
&self,
gesture_recognizer: &UIGestureRecognizer,
touch: &UITouch,
) -> bool;
#[cfg(feature = "UIPress")]
#[optional]
#[method(gestureRecognizer:shouldReceivePress:)]
unsafe fn gestureRecognizer_shouldReceivePress(
&self,
gesture_recognizer: &UIGestureRecognizer,
press: &UIPress,
) -> bool;
#[cfg(feature = "UIEvent")]
#[optional]
#[method(gestureRecognizer:shouldReceiveEvent:)]
unsafe fn gestureRecognizer_shouldReceiveEvent(
&self,
gesture_recognizer: &UIGestureRecognizer,
event: &UIEvent,
) -> bool;
}
unsafe impl ProtocolType for dyn UIGestureRecognizerDelegate {}
);