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
83impl NSTouchTypeMask {
84 }
86
87extern_class!(
88 #[unsafe(super(NSObject))]
90 #[derive(Debug, PartialEq, Eq, Hash)]
91 pub struct NSTouch;
92);
93
94unsafe impl Send for NSTouch {}
95
96unsafe impl Sync for NSTouch {}
97
98extern_conformance!(
99 unsafe impl NSCopying for NSTouch {}
100);
101
102unsafe impl CopyingHelper for NSTouch {
103 type Result = Self;
104}
105
106extern_conformance!(
107 unsafe impl NSObjectProtocol for NSTouch {}
108);
109
110impl NSTouch {
111 extern_methods!(
112 #[unsafe(method(identity))]
113 #[unsafe(method_family = none)]
114 pub unsafe fn identity(&self) -> Retained<AnyObject >;
115
116 #[unsafe(method(phase))]
117 #[unsafe(method_family = none)]
118 pub unsafe fn phase(&self) -> NSTouchPhase;
119
120 #[unsafe(method(normalizedPosition))]
121 #[unsafe(method_family = none)]
122 pub unsafe fn normalizedPosition(&self) -> NSPoint;
123
124 #[unsafe(method(isResting))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn isResting(&self) -> bool;
127
128 #[unsafe(method(device))]
129 #[unsafe(method_family = none)]
130 pub unsafe fn device(&self) -> Option<Retained<AnyObject>>;
131
132 #[unsafe(method(deviceSize))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn deviceSize(&self) -> NSSize;
135 );
136}
137
138impl NSTouch {
140 extern_methods!(
141 #[unsafe(method(init))]
142 #[unsafe(method_family = init)]
143 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
144
145 #[unsafe(method(new))]
146 #[unsafe(method_family = new)]
147 pub unsafe fn new() -> Retained<Self>;
148 );
149}
150
151impl NSTouch {
153 extern_methods!(
154 #[unsafe(method(type))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn r#type(&self) -> NSTouchType;
157
158 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
159 #[unsafe(method(locationInView:))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn locationInView(&self, view: Option<&NSView>) -> NSPoint;
162
163 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
164 #[unsafe(method(previousLocationInView:))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn previousLocationInView(&self, view: Option<&NSView>) -> NSPoint;
167 );
168}