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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
//! 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 objc2_foundation::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenuinteractioncommitstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIContextMenuInteractionCommitStyle(pub NSInteger);
impl UIContextMenuInteractionCommitStyle {
#[doc(alias = "UIContextMenuInteractionCommitStyleDismiss")]
pub const Dismiss: Self = Self(0);
#[doc(alias = "UIContextMenuInteractionCommitStylePop")]
pub const Pop: Self = Self(1);
}
unsafe impl Encode for UIContextMenuInteractionCommitStyle {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UIContextMenuInteractionCommitStyle {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenuinteractionappearance?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIContextMenuInteractionAppearance(pub NSInteger);
impl UIContextMenuInteractionAppearance {
#[doc(alias = "UIContextMenuInteractionAppearanceUnknown")]
pub const Unknown: Self = Self(0);
#[doc(alias = "UIContextMenuInteractionAppearanceRich")]
pub const Rich: Self = Self(1);
#[doc(alias = "UIContextMenuInteractionAppearanceCompact")]
pub const Compact: Self = Self(2);
}
unsafe impl Encode for UIContextMenuInteractionAppearance {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UIContextMenuInteractionAppearance {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenuinteraction?language=objc)
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UIContextMenuInteraction;
);
extern_conformance!(
unsafe impl NSObjectProtocol for UIContextMenuInteraction {}
);
#[cfg(feature = "UIInteraction")]
extern_conformance!(
unsafe impl UIInteraction for UIContextMenuInteraction {}
);
impl UIContextMenuInteraction {
extern_methods!(
/// The interaction's delegate.
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn UIContextMenuInteractionDelegate>>>;
/// Appearance of the menu this interaction has presented or is about to present. Since it may be
/// dependent on the user's input method, the appearance is only known while the interaction is active.
#[unsafe(method(menuAppearance))]
#[unsafe(method_family = none)]
pub fn menuAppearance(&self) -> UIContextMenuInteractionAppearance;
#[unsafe(method(initWithDelegate:))]
#[unsafe(method_family = init)]
pub fn initWithDelegate(
this: Allocated<Self>,
delegate: &ProtocolObject<dyn UIContextMenuInteractionDelegate>,
) -> Retained<Self>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
#[cfg(all(
feature = "UIResponder",
feature = "UIView",
feature = "objc2-core-foundation"
))]
/// Returns the interaction's location within the given view.
///
///
/// Parameter `view`: The view in which to locate the interaction.
#[unsafe(method(locationInView:))]
#[unsafe(method_family = none)]
pub fn locationInView(&self, view: Option<&UIView>) -> CGPoint;
#[cfg(all(feature = "UIMenu", feature = "UIMenuElement", feature = "block2"))]
/// Call to update the currently visible menu. This method does nothing if called before a menu is presented.
///
///
/// Parameter `block`: Called with a mutable copy of the currently visible menu. Modify and return this menu (or an entirely
/// new one) to change the currently visible menu items. Starting in iOS 15, this block is called once for
/// every visible submenu. For example, in the following hierarchy:
///
/// *- Root Menu
/// *- Submenu A
/// *- Submenu B
/// *- Submenu C
///
/// If Submenu A is visible, the block is called twice (once for the Root Menu and once for Submenu A).
/// If both A and B are visible, it's called 3 times (for the Root Menu, A, and B).
///
/// # Safety
///
/// `block` block's return must be a valid pointer.
#[unsafe(method(updateVisibleMenuWithBlock:))]
#[unsafe(method_family = none)]
pub unsafe fn updateVisibleMenuWithBlock(
&self,
block: &block2::DynBlock<dyn Fn(NonNull<UIMenu>) -> NonNull<UIMenu> + '_>,
);
/// Dismisses the currently presented menu (if there is one).
#[unsafe(method(dismissMenu))]
#[unsafe(method_family = none)]
pub fn dismissMenu(&self);
);
}
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenuinteractionanimating?language=objc)
pub unsafe trait UIContextMenuInteractionAnimating:
NSObjectProtocol + MainThreadOnly
{
#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
/// Displayed preview view controller.
#[unsafe(method(previewViewController))]
#[unsafe(method_family = none)]
fn previewViewController(&self) -> Option<Retained<UIViewController>>;
#[cfg(feature = "block2")]
#[unsafe(method(addAnimations:))]
#[unsafe(method_family = none)]
fn addAnimations(&self, animations: &block2::DynBlock<dyn Fn()>);
#[cfg(feature = "block2")]
#[unsafe(method(addCompletion:))]
#[unsafe(method_family = none)]
fn addCompletion(&self, completion: &block2::DynBlock<dyn Fn()>);
}
);
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenuinteractioncommitanimating?language=objc)
pub unsafe trait UIContextMenuInteractionCommitAnimating:
UIContextMenuInteractionAnimating + MainThreadOnly
{
/// Preferred animation style for the menu's commit action. Triggered when the user taps the preview.
#[unsafe(method(preferredCommitStyle))]
#[unsafe(method_family = none)]
fn preferredCommitStyle(&self) -> UIContextMenuInteractionCommitStyle;
/// Setter for [`preferredCommitStyle`][Self::preferredCommitStyle].
#[unsafe(method(setPreferredCommitStyle:))]
#[unsafe(method_family = none)]
fn setPreferredCommitStyle(
&self,
preferred_commit_style: UIContextMenuInteractionCommitStyle,
);
}
);
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenuinteractiondelegate?language=objc)
pub unsafe trait UIContextMenuInteractionDelegate:
NSObjectProtocol + MainThreadOnly
{
#[cfg(all(
feature = "UIContextMenuConfiguration",
feature = "objc2-core-foundation"
))]
/// Called when the interaction begins.
///
///
/// Parameter `interaction`: The UIContextMenuInteraction.
///
/// Parameter `location`: The location of the interaction in its view.
///
///
/// Returns: A UIContextMenuConfiguration describing the menu to be presented. Return nil to prevent the interaction from beginning.
/// Returning an empty configuration causes the interaction to begin then fail with a cancellation effect. You might use this
/// to indicate to users that it's possible for a menu to be presented from this view, but that there are no actions to
/// present at this particular time.
#[unsafe(method(contextMenuInteraction:configurationForMenuAtLocation:))]
#[unsafe(method_family = none)]
fn contextMenuInteraction_configurationForMenuAtLocation(
&self,
interaction: &UIContextMenuInteraction,
location: CGPoint,
) -> Option<Retained<UIContextMenuConfiguration>>;
#[cfg(all(feature = "UIContextMenuConfiguration", feature = "UITargetedPreview"))]
/// Called when a context menu interaction begins. Return a UITargetedPreview corresponding to the item with the given identifier.
///
///
/// Parameter `interaction`: The UIContextMenuInteraction.
///
/// Parameter `configuration`: Configuration of the menu that will be presented if the interaction proceeds.
///
/// Parameter `identifier`: Identifier for the item whose preview is being requested.
///
/// # Safety
///
/// `identifier` should be of the correct type.
#[optional]
#[unsafe(method(contextMenuInteraction:configuration:highlightPreviewForItemWithIdentifier:))]
#[unsafe(method_family = none)]
unsafe fn contextMenuInteraction_configuration_highlightPreviewForItemWithIdentifier(
&self,
interaction: &UIContextMenuInteraction,
configuration: &UIContextMenuConfiguration,
identifier: &ProtocolObject<dyn NSCopying>,
) -> Option<Retained<UITargetedPreview>>;
#[cfg(all(feature = "UIContextMenuConfiguration", feature = "UITargetedPreview"))]
/// Called when a context menu is dismissed. Return a UITargetedPreview corresponding to the item with the given identifier.
///
///
/// Parameter `interaction`: The UIContextMenuInteraction.
///
/// Parameter `configuration`: Configuration of the menu being dismissed.
///
/// Parameter `identifier`: Identifier for the item whose preview is being requested.
///
/// # Safety
///
/// `identifier` should be of the correct type.
#[optional]
#[unsafe(method(contextMenuInteraction:configuration:dismissalPreviewForItemWithIdentifier:))]
#[unsafe(method_family = none)]
unsafe fn contextMenuInteraction_configuration_dismissalPreviewForItemWithIdentifier(
&self,
interaction: &UIContextMenuInteraction,
configuration: &UIContextMenuConfiguration,
identifier: &ProtocolObject<dyn NSCopying>,
) -> Option<Retained<UITargetedPreview>>;
#[cfg(feature = "UIContextMenuConfiguration")]
/// Called when the interaction is about to "commit" in response to the user tapping the preview.
///
///
/// Parameter `interaction`: The UIContextMenuInteraction.
///
/// Parameter `configuration`: Configuration of the currently displayed menu.
///
/// Parameter `animator`: Commit animator. Add animations to this object to run them alongside the commit transition.
#[optional]
#[unsafe(method(contextMenuInteraction:willPerformPreviewActionForMenuWithConfiguration:animator:))]
#[unsafe(method_family = none)]
fn contextMenuInteraction_willPerformPreviewActionForMenuWithConfiguration_animator(
&self,
interaction: &UIContextMenuInteraction,
configuration: &UIContextMenuConfiguration,
animator: &ProtocolObject<dyn UIContextMenuInteractionCommitAnimating>,
);
#[cfg(feature = "UIContextMenuConfiguration")]
/// Called when the interaction is about to display a menu.
///
///
/// Parameter `interaction`: The UIContextMenuInteraction.
///
/// Parameter `configuration`: The configuration of the menu about to be displayed by this interaction.
///
/// Parameter `animator`: Appearance animator. Add animations to run them alongside the appearance transition.
#[optional]
#[unsafe(method(contextMenuInteraction:willDisplayMenuForConfiguration:animator:))]
#[unsafe(method_family = none)]
fn contextMenuInteraction_willDisplayMenuForConfiguration_animator(
&self,
interaction: &UIContextMenuInteraction,
configuration: &UIContextMenuConfiguration,
animator: Option<&ProtocolObject<dyn UIContextMenuInteractionAnimating>>,
);
#[cfg(feature = "UIContextMenuConfiguration")]
/// Called when the interaction is about to end.
///
///
/// Parameter `interaction`: The UIContextMenuInteraction.
///
/// Parameter `configuration`: Ending configuration.
///
/// Parameter `animator`: Disappearance animator. Add animations to run them alongside the disappearance transition.
#[optional]
#[unsafe(method(contextMenuInteraction:willEndForConfiguration:animator:))]
#[unsafe(method_family = none)]
fn contextMenuInteraction_willEndForConfiguration_animator(
&self,
interaction: &UIContextMenuInteraction,
configuration: &UIContextMenuConfiguration,
animator: Option<&ProtocolObject<dyn UIContextMenuInteractionAnimating>>,
);
#[cfg(all(feature = "UIContextMenuConfiguration", feature = "UITargetedPreview"))]
/// Called when the interaction begins. Return a UITargetedPreview describing the desired highlight preview.
///
///
/// Parameter `interaction`: The UIContextMenuInteraction requesting a highlighting preview.
///
/// Parameter `configuration`: The configuration of the menu about to be displayed by this interaction.
#[deprecated]
#[optional]
#[unsafe(method(contextMenuInteraction:previewForHighlightingMenuWithConfiguration:))]
#[unsafe(method_family = none)]
fn contextMenuInteraction_previewForHighlightingMenuWithConfiguration(
&self,
interaction: &UIContextMenuInteraction,
configuration: &UIContextMenuConfiguration,
) -> Option<Retained<UITargetedPreview>>;
#[cfg(all(feature = "UIContextMenuConfiguration", feature = "UITargetedPreview"))]
/// Called when the interaction is about to dismiss. Return a UITargetedPreview describing the desired dismissal target.
/// The interaction will animate the presented menu to the target. Use this to customize the dismissal animation.
///
///
/// Parameter `interaction`: The UIContextMenuInteraction requesting a dismissal preview.
///
/// Parameter `configuration`: The configuration of the menu displayed by this interaction.
///
///
/// Returns: Return a UITargetedPreview describing the desired dismissal target. Return nil to cause the menu to
/// animate away without morphing into a specific view.
#[deprecated]
#[optional]
#[unsafe(method(contextMenuInteraction:previewForDismissingMenuWithConfiguration:))]
#[unsafe(method_family = none)]
fn contextMenuInteraction_previewForDismissingMenuWithConfiguration(
&self,
interaction: &UIContextMenuInteraction,
configuration: &UIContextMenuConfiguration,
) -> Option<Retained<UITargetedPreview>>;
}
);