objc2_app_kit/generated/
NSTouch.rs1use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct NSTouchPhase(pub NSUInteger);
14bitflags::bitflags! {
15 impl NSTouchPhase: NSUInteger {
16 #[doc(alias = "NSTouchPhaseBegan")]
17 const Began = 1<<0;
18 #[doc(alias = "NSTouchPhaseMoved")]
19 const Moved = 1<<1;
20 #[doc(alias = "NSTouchPhaseStationary")]
21 const Stationary = 1<<2;
22 #[doc(alias = "NSTouchPhaseEnded")]
23 const Ended = 1<<3;
24 #[doc(alias = "NSTouchPhaseCancelled")]
25 const Cancelled = 1<<4;
26 #[doc(alias = "NSTouchPhaseTouching")]
27 const Touching = NSTouchPhase::Began.0|NSTouchPhase::Moved.0|NSTouchPhase::Stationary.0;
28 #[doc(alias = "NSTouchPhaseAny")]
29 const Any = NSUIntegerMax as _;
30 }
31}
32
33unsafe impl Encode for NSTouchPhase {
34 const ENCODING: Encoding = NSUInteger::ENCODING;
35}
36
37unsafe impl RefEncode for NSTouchPhase {
38 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41#[repr(transparent)]
44#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
45pub struct NSTouchType(pub NSInteger);
46impl NSTouchType {
47 #[doc(alias = "NSTouchTypeDirect")]
48 pub const Direct: Self = Self(0);
49 #[doc(alias = "NSTouchTypeIndirect")]
50 pub const Indirect: Self = Self(1);
51}
52
53unsafe impl Encode for NSTouchType {
54 const ENCODING: Encoding = NSInteger::ENCODING;
55}
56
57unsafe impl RefEncode for NSTouchType {
58 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
59}
60
61#[repr(transparent)]
64#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
65pub struct NSTouchTypeMask(pub NSUInteger);
66bitflags::bitflags! {
67 impl NSTouchTypeMask: NSUInteger {
68 #[doc(alias = "NSTouchTypeMaskDirect")]
69 const Direct = 1<<NSTouchType::Direct.0;
70 #[doc(alias = "NSTouchTypeMaskIndirect")]
71 const Indirect = 1<<NSTouchType::Indirect.0;
72 }
73}
74
75unsafe impl Encode for NSTouchTypeMask {
76 const ENCODING: Encoding = NSUInteger::ENCODING;
77}
78
79unsafe impl RefEncode for NSTouchTypeMask {
80 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
81}
82
83extern_class!(
86 #[unsafe(super(NSObject))]
88 #[derive(Debug, PartialEq, Eq, Hash)]
89 pub struct NSTouch;
90);
91
92unsafe impl Send for NSTouch {}
93
94unsafe impl Sync for NSTouch {}
95
96unsafe impl NSCopying for NSTouch {}
97
98unsafe impl CopyingHelper for NSTouch {
99 type Result = Self;
100}
101
102unsafe impl NSObjectProtocol for NSTouch {}
103
104impl NSTouch {
105 extern_methods!(
106 #[unsafe(method(identity))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn identity(&self) -> Retained<AnyObject >;
109
110 #[unsafe(method(phase))]
111 #[unsafe(method_family = none)]
112 pub unsafe fn phase(&self) -> NSTouchPhase;
113
114 #[unsafe(method(normalizedPosition))]
115 #[unsafe(method_family = none)]
116 pub unsafe fn normalizedPosition(&self) -> NSPoint;
117
118 #[unsafe(method(isResting))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn isResting(&self) -> bool;
121
122 #[unsafe(method(device))]
123 #[unsafe(method_family = none)]
124 pub unsafe fn device(&self) -> Option<Retained<AnyObject>>;
125
126 #[unsafe(method(deviceSize))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn deviceSize(&self) -> NSSize;
129 );
130}
131
132impl NSTouch {
134 extern_methods!(
135 #[unsafe(method(init))]
136 #[unsafe(method_family = init)]
137 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
138
139 #[unsafe(method(new))]
140 #[unsafe(method_family = new)]
141 pub unsafe fn new() -> Retained<Self>;
142 );
143}
144
145impl NSTouch {
147 extern_methods!(
148 #[unsafe(method(type))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn r#type(&self) -> NSTouchType;
151
152 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
153 #[unsafe(method(locationInView:))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn locationInView(&self, view: Option<&NSView>) -> NSPoint;
156
157 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
158 #[unsafe(method(previousLocationInView:))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn previousLocationInView(&self, view: Option<&NSView>) -> NSPoint;
161 );
162}