1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use crate::*;
/// An object conforming to UISpringLoadedInteractionEffect uses UISpringLoadedInteractionEffectState
/// to style the interaction view for the current springloading state.
///
/// - UISpringLoadedInteractionEffectStateInactive: the view is not engaged in springloading and should be displayed with its default style.
/// - UISpringLoadedInteractionEffectStatePossible: the view may springload and should provide a visual cue to the user. The default effect highlights the view.
/// - UISpringLoadedInteractionEffectStateActivating: the view is about to springload. The default effect will briefly flash while in this state.
/// - UISpringLoadedInteractionEffectStateActivated: the view springloaded and the activation handler is called. The default effect will restore the view to its original appearance.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uispringloadedinteractioneffectstate?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UISpringLoadedInteractionEffectState(pub NSInteger);
impl UISpringLoadedInteractionEffectState {
#[doc(alias = "UISpringLoadedInteractionEffectStateInactive")]
pub const Inactive: Self = Self(0);
#[doc(alias = "UISpringLoadedInteractionEffectStatePossible")]
pub const Possible: Self = Self(1);
#[doc(alias = "UISpringLoadedInteractionEffectStateActivating")]
pub const Activating: Self = Self(2);
#[doc(alias = "UISpringLoadedInteractionEffectStateActivated")]
pub const Activated: Self = Self(3);
}
unsafe impl Encode for UISpringLoadedInteractionEffectState {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UISpringLoadedInteractionEffectState {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uispringloadedinteraction?language=objc)
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UISpringLoadedInteraction;
);
extern_conformance!(
unsafe impl NSObjectProtocol for UISpringLoadedInteraction {}
);
#[cfg(feature = "UIInteraction")]
extern_conformance!(
unsafe impl UIInteraction for UISpringLoadedInteraction {}
);
impl UISpringLoadedInteraction {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[cfg(feature = "block2")]
/// The designated `UISpringLoadedInteraction` initializer.
///
///
/// Parameter `interactionBehavior`: The interaction behavior object controlling the springloaded interaction activation. If nil, the default behavior will be used.
///
/// Parameter `interactionEffect`: The interaction effect object styling the interaction's view. If nil, the default effect will be used.
///
/// Parameter `handler`: The handler to be performed when springloading is activated.
///
/// Returns: An initialized springloaded interaction object or `nil` if the springloaded interaction could not be initialized.
#[unsafe(method(initWithInteractionBehavior:interactionEffect:activationHandler:))]
#[unsafe(method_family = init)]
pub fn initWithInteractionBehavior_interactionEffect_activationHandler(
this: Allocated<Self>,
interaction_behavior: Option<&ProtocolObject<dyn UISpringLoadedInteractionBehavior>>,
interaction_effect: Option<&ProtocolObject<dyn UISpringLoadedInteractionEffect>>,
handler: &block2::DynBlock<
dyn Fn(
NonNull<UISpringLoadedInteraction>,
NonNull<ProtocolObject<dyn UISpringLoadedInteractionContext>>,
),
>,
) -> Retained<Self>;
#[cfg(feature = "block2")]
/// A springloaded interaction with the default interaction behavior and effect.
///
///
/// Parameter `handler`: The handler to be performed when springloading is activated.
///
/// Returns: An initialized springloaded interaction object or `nil` if the springloaded interaction could not be initialized.
#[unsafe(method(initWithActivationHandler:))]
#[unsafe(method_family = init)]
pub fn initWithActivationHandler(
this: Allocated<Self>,
handler: &block2::DynBlock<
dyn Fn(
NonNull<UISpringLoadedInteraction>,
NonNull<ProtocolObject<dyn UISpringLoadedInteractionContext>>,
),
>,
) -> Retained<Self>;
#[unsafe(method(interactionBehavior))]
#[unsafe(method_family = none)]
pub fn interactionBehavior(
&self,
) -> Retained<ProtocolObject<dyn UISpringLoadedInteractionBehavior>>;
#[unsafe(method(interactionEffect))]
#[unsafe(method_family = none)]
pub fn interactionEffect(
&self,
) -> Retained<ProtocolObject<dyn UISpringLoadedInteractionEffect>>;
);
}
extern_protocol!(
/// The interaction behavior of a `UISpringLoadedInteraction` object must adopt the `UISpringLoadedInteractionBehavior` protocol.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uispringloadedinteractionbehavior?language=objc)
pub unsafe trait UISpringLoadedInteractionBehavior:
NSObjectProtocol + MainThreadOnly
{
/// Returns whether springloading should begin or continue for a given interaction.
///
///
/// Parameter `interaction`: The springloaded interaction object requesting this information
///
/// Parameter `context`: An object that provides information about the current drag.
///
/// Returns: true if the interaction should begin or continue springloading.
#[unsafe(method(shouldAllowInteraction:withContext:))]
#[unsafe(method_family = none)]
fn shouldAllowInteraction_withContext(
&self,
interaction: &UISpringLoadedInteraction,
context: &ProtocolObject<dyn UISpringLoadedInteractionContext>,
) -> bool;
/// Informs the behavior that springloading for a given interaction was cancelled or activated.
///
///
/// Parameter `interaction`: The springloaded interaction object providing this information.
#[optional]
#[unsafe(method(interactionDidFinish:))]
#[unsafe(method_family = none)]
fn interactionDidFinish(&self, interaction: &UISpringLoadedInteraction);
}
);
extern_protocol!(
/// The interaction effect of a `UISpringLoadedInteraction` object must adopt the `UISpringLoadedInteractionEffect` protocol.
/// It is responsible for styling the interaction view according to the current springloading state.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uispringloadedinteractioneffect?language=objc)
pub unsafe trait UISpringLoadedInteractionEffect:
NSObjectProtocol + MainThreadOnly
{
/// Informs the effect that the springloading state changed.
///
///
/// Parameter `interaction`: The springloaded interaction providing this information.
///
/// Parameter `context`: An object that provides information about the current springloading state.
#[unsafe(method(interaction:didChangeWithContext:))]
#[unsafe(method_family = none)]
fn interaction_didChangeWithContext(
&self,
interaction: &UISpringLoadedInteraction,
context: &ProtocolObject<dyn UISpringLoadedInteractionContext>,
);
}
);
extern_protocol!(
/// UISpringLoadedContext supplies information about the springloading state and current drag.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uispringloadedinteractioncontext?language=objc)
pub unsafe trait UISpringLoadedInteractionContext:
NSObjectProtocol + MainThreadOnly
{
/// The state that describes the current springloading style.
#[unsafe(method(state))]
#[unsafe(method_family = none)]
fn state(&self) -> UISpringLoadedInteractionEffectState;
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
/// The view to which the interaction effect is applied. Defaults to the interaction's view.
#[unsafe(method(targetView))]
#[unsafe(method_family = none)]
fn targetView(&self) -> Option<Retained<UIView>>;
#[cfg(all(feature = "UIResponder", feature = "UIView"))]
/// Setter for [`targetView`][Self::targetView].
#[unsafe(method(setTargetView:))]
#[unsafe(method_family = none)]
fn setTargetView(&self, target_view: Option<&UIView>);
/// The `targetItem` allows to distinguish a region of the view on which the interaction is installed.
/// It is convenient to set this property to a model object associated to `targetView`.
#[unsafe(method(targetItem))]
#[unsafe(method_family = none)]
fn targetItem(&self) -> Option<Retained<AnyObject>>;
/// Setter for [`targetItem`][Self::targetItem].
///
/// # Safety
///
/// `target_item` should be of the correct type.
#[unsafe(method(setTargetItem:))]
#[unsafe(method_family = none)]
unsafe fn setTargetItem(&self, target_item: Option<&AnyObject>);
#[cfg(all(
feature = "UIResponder",
feature = "UIView",
feature = "objc2-core-foundation"
))]
/// Returns the point computed as the location of the current drag in a given view.
///
///
/// Parameter `view`: A view on which the drag is taking place. Specify nil to indicate the window.
///
/// Returns: A point in the local coordinate system of `view`.
#[unsafe(method(locationInView:))]
#[unsafe(method_family = none)]
fn locationInView(&self, view: Option<&UIView>) -> CGPoint;
}
);