objc2_ui_kit/generated/
UIPointerInteraction.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8
9use crate::*;
10
11extern_class!(
12    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipointerinteraction?language=objc)
13    #[unsafe(super(NSObject))]
14    #[thread_kind = MainThreadOnly]
15    #[derive(Debug, PartialEq, Eq, Hash)]
16    pub struct UIPointerInteraction;
17);
18
19unsafe impl NSObjectProtocol for UIPointerInteraction {}
20
21#[cfg(feature = "UIInteraction")]
22unsafe impl UIInteraction for UIPointerInteraction {}
23
24impl UIPointerInteraction {
25    extern_methods!(
26        #[unsafe(method(delegate))]
27        #[unsafe(method_family = none)]
28        pub unsafe fn delegate(
29            &self,
30        ) -> Option<Retained<ProtocolObject<dyn UIPointerInteractionDelegate>>>;
31
32        #[unsafe(method(isEnabled))]
33        #[unsafe(method_family = none)]
34        pub unsafe fn isEnabled(&self) -> bool;
35
36        /// Setter for [`isEnabled`][Self::isEnabled].
37        #[unsafe(method(setEnabled:))]
38        #[unsafe(method_family = none)]
39        pub unsafe fn setEnabled(&self, enabled: bool);
40
41        #[unsafe(method(initWithDelegate:))]
42        #[unsafe(method_family = init)]
43        pub unsafe fn initWithDelegate(
44            this: Allocated<Self>,
45            delegate: Option<&ProtocolObject<dyn UIPointerInteractionDelegate>>,
46        ) -> Retained<Self>;
47
48        /// Call this method to cause the interaction to update the pointer in response to some event.
49        #[unsafe(method(invalidate))]
50        #[unsafe(method_family = none)]
51        pub unsafe fn invalidate(&self);
52    );
53}
54
55/// Methods declared on superclass `NSObject`.
56impl UIPointerInteraction {
57    extern_methods!(
58        #[unsafe(method(init))]
59        #[unsafe(method_family = init)]
60        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
61
62        #[unsafe(method(new))]
63        #[unsafe(method_family = new)]
64        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
65    );
66}
67
68extern_protocol!(
69    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipointerinteractiondelegate?language=objc)
70    pub unsafe trait UIPointerInteractionDelegate:
71        NSObjectProtocol + MainThreadOnly
72    {
73        #[cfg(feature = "UIPointerRegion")]
74        /// Called as the pointer moves within the interaction's view.
75        ///
76        ///
77        /// Parameter `interaction`: This UIPointerInteraction.
78        ///
79        /// Parameter `request`: Request object describing the pointer's location in the interaction's view.
80        ///
81        /// Parameter `defaultRegion`: Region representing the entire surface of the interaction's view.
82        ///
83        ///
84        /// Returns: A UIPointerRegion in which to apply a pointer style. Return nil to indicate that this interaction should not customize the pointer for the current location.
85        #[optional]
86        #[unsafe(method(pointerInteraction:regionForRequest:defaultRegion:))]
87        #[unsafe(method_family = none)]
88        unsafe fn pointerInteraction_regionForRequest_defaultRegion(
89            &self,
90            interaction: &UIPointerInteraction,
91            request: &UIPointerRegionRequest,
92            default_region: &UIPointerRegion,
93        ) -> Option<Retained<UIPointerRegion>>;
94
95        #[cfg(all(
96            feature = "UIHoverStyle",
97            feature = "UIPointerRegion",
98            feature = "UIPointerStyle"
99        ))]
100        /// Called after the interaction receives a new UIPointerRegion from pointerInteraction:regionForRequest:defaultRegion:.
101        ///
102        ///
103        /// Parameter `interaction`: This UIPointerInteraction.
104        ///
105        /// Parameter `region`: The UIPointerRegion for which a style is being requested.
106        ///
107        ///
108        /// Returns: A UIPointerStyle describing the desired hover effect or pointer appearance for the given UIPointerRegion.
109        #[optional]
110        #[unsafe(method(pointerInteraction:styleForRegion:))]
111        #[unsafe(method_family = none)]
112        unsafe fn pointerInteraction_styleForRegion(
113            &self,
114            interaction: &UIPointerInteraction,
115            region: &UIPointerRegion,
116        ) -> Option<Retained<UIPointerStyle>>;
117
118        #[cfg(feature = "UIPointerRegion")]
119        /// Called when the pointer enters a given region.
120        ///
121        ///
122        /// Parameter `interaction`: This UIPointerInteraction.
123        ///
124        /// Parameter `region`: The UIPointerRegion the pointer is about to enter.
125        ///
126        /// Parameter `animator`: Region entrance animator. Add animations to run them alongside the pointer's entrance animation.
127        #[optional]
128        #[unsafe(method(pointerInteraction:willEnterRegion:animator:))]
129        #[unsafe(method_family = none)]
130        unsafe fn pointerInteraction_willEnterRegion_animator(
131            &self,
132            interaction: &UIPointerInteraction,
133            region: &UIPointerRegion,
134            animator: &ProtocolObject<dyn UIPointerInteractionAnimating>,
135        );
136
137        #[cfg(feature = "UIPointerRegion")]
138        /// Called when the pointer exists a given region.
139        ///
140        ///
141        /// Parameter `interaction`: This UIPointerInteraction.
142        ///
143        /// Parameter `region`: The UIPointerRegion the pointer is about to exit.
144        ///
145        /// Parameter `animator`: Region exit animator. Add animations to run them alongside the pointer's exit animation.
146        #[optional]
147        #[unsafe(method(pointerInteraction:willExitRegion:animator:))]
148        #[unsafe(method_family = none)]
149        unsafe fn pointerInteraction_willExitRegion_animator(
150            &self,
151            interaction: &UIPointerInteraction,
152            region: &UIPointerRegion,
153            animator: &ProtocolObject<dyn UIPointerInteractionAnimating>,
154        );
155    }
156);
157
158extern_class!(
159    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipointerregionrequest?language=objc)
160    #[unsafe(super(NSObject))]
161    #[thread_kind = MainThreadOnly]
162    #[derive(Debug, PartialEq, Eq, Hash)]
163    pub struct UIPointerRegionRequest;
164);
165
166unsafe impl NSObjectProtocol for UIPointerRegionRequest {}
167
168impl UIPointerRegionRequest {
169    extern_methods!(
170        #[cfg(feature = "objc2-core-foundation")]
171        /// The location of the pointer in the interaction's view's coordinate space.
172        #[unsafe(method(location))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn location(&self) -> CGPoint;
175
176        #[cfg(feature = "UICommand")]
177        /// Key modifier flags representing keyboard keys pressed by the user at the time of this request.
178        #[unsafe(method(modifiers))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn modifiers(&self) -> UIKeyModifierFlags;
181    );
182}
183
184/// Methods declared on superclass `NSObject`.
185impl UIPointerRegionRequest {
186    extern_methods!(
187        #[unsafe(method(init))]
188        #[unsafe(method_family = init)]
189        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
190
191        #[unsafe(method(new))]
192        #[unsafe(method_family = new)]
193        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
194    );
195}
196
197extern_protocol!(
198    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipointerinteractionanimating?language=objc)
199    pub unsafe trait UIPointerInteractionAnimating:
200        NSObjectProtocol + MainThreadOnly
201    {
202        #[cfg(feature = "block2")]
203        #[unsafe(method(addAnimations:))]
204        #[unsafe(method_family = none)]
205        unsafe fn addAnimations(&self, animations: &block2::Block<dyn Fn()>);
206
207        #[cfg(feature = "block2")]
208        #[unsafe(method(addCompletion:))]
209        #[unsafe(method_family = none)]
210        unsafe fn addCompletion(&self, completion: &block2::Block<dyn Fn(Bool)>);
211    }
212);