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
//! 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/uieditmenuarrowdirection?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIEditMenuArrowDirection(pub NSInteger);
impl UIEditMenuArrowDirection {
#[doc(alias = "UIEditMenuArrowDirectionAutomatic")]
pub const Automatic: Self = Self(0);
#[doc(alias = "UIEditMenuArrowDirectionUp")]
pub const Up: Self = Self(1);
#[doc(alias = "UIEditMenuArrowDirectionDown")]
pub const Down: Self = Self(2);
#[doc(alias = "UIEditMenuArrowDirectionLeft")]
pub const Left: Self = Self(3);
#[doc(alias = "UIEditMenuArrowDirectionRight")]
pub const Right: Self = Self(4);
}
unsafe impl Encode for UIEditMenuArrowDirection {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UIEditMenuArrowDirection {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uieditmenuconfiguration?language=objc)
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UIEditMenuConfiguration;
);
extern_conformance!(
unsafe impl NSObjectProtocol for UIEditMenuConfiguration {}
);
impl UIEditMenuConfiguration {
extern_methods!(
/// The unique identifier of the configuration.
#[unsafe(method(identifier))]
#[unsafe(method_family = none)]
pub fn identifier(&self) -> Retained<ProtocolObject<dyn NSCopying>>;
#[cfg(feature = "objc2-core-foundation")]
/// The source location of the menu. The suggested actions menu elements will be derived from this location in the interaction's view.
/// By default, the menu will be presented from this location. You can change the presentation source of the menu with the delegate
/// method
/// `editMenuInteraction:targetRectForConfiguration:`
#[unsafe(method(sourcePoint))]
#[unsafe(method_family = none)]
pub fn sourcePoint(&self) -> CGPoint;
/// The preferred arrow direction of the edit menu. Default is
/// `UIEditMenuArrowDirectionAutomatic`
#[unsafe(method(preferredArrowDirection))]
#[unsafe(method_family = none)]
pub fn preferredArrowDirection(&self) -> UIEditMenuArrowDirection;
/// Setter for [`preferredArrowDirection`][Self::preferredArrowDirection].
#[unsafe(method(setPreferredArrowDirection:))]
#[unsafe(method_family = none)]
pub fn setPreferredArrowDirection(
&self,
preferred_arrow_direction: UIEditMenuArrowDirection,
);
#[cfg(feature = "objc2-core-foundation")]
/// Creates a new configuration with the specified source location.
///
/// # Safety
///
/// `identifier` should be of the correct type.
#[unsafe(method(configurationWithIdentifier:sourcePoint:))]
#[unsafe(method_family = none)]
pub unsafe fn configurationWithIdentifier_sourcePoint(
identifier: Option<&ProtocolObject<dyn NSCopying>>,
source_point: CGPoint,
mtm: MainThreadMarker,
) -> 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>;
);
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uieditmenuinteraction?language=objc)
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UIEditMenuInteraction;
);
extern_conformance!(
unsafe impl NSObjectProtocol for UIEditMenuInteraction {}
);
#[cfg(feature = "UIInteraction")]
extern_conformance!(
unsafe impl UIInteraction for UIEditMenuInteraction {}
);
impl UIEditMenuInteraction {
extern_methods!(
/// The object that defines the delegate of the interaction.
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn UIEditMenuInteractionDelegate>>>;
/// Creates a new edit menu interaction with the specified delegate.
#[unsafe(method(initWithDelegate:))]
#[unsafe(method_family = init)]
pub fn initWithDelegate(
this: Allocated<Self>,
delegate: Option<&ProtocolObject<dyn UIEditMenuInteractionDelegate>>,
) -> Retained<Self>;
/// Presents an edit menu with the specified
/// `configuration`object.
/// If a menu is already presented, it will be dismissed automatically before the new menu is presented.
///
/// :
/// `presentEditMenuWithConfiguration:`is not supported on Mac Catalyst.
#[unsafe(method(presentEditMenuWithConfiguration:))]
#[unsafe(method_family = none)]
pub fn presentEditMenuWithConfiguration(&self, configuration: &UIEditMenuConfiguration);
/// Dismiss the currently active menu if one is currently presented.
#[unsafe(method(dismissMenu))]
#[unsafe(method_family = none)]
pub fn dismissMenu(&self);
/// Reloads the visible menu. This menu has no effect if there is no menu presented. This method will query
/// the menu again from the delegate method
/// `editMenuInteraction:menuForConfiguration:suggestedActions:`and refresh the UI with the updated menu.
#[unsafe(method(reloadVisibleMenu))]
#[unsafe(method_family = none)]
pub fn reloadVisibleMenu(&self);
/// Updates the position of the currently visible menu, with an option to animate the action. This method
/// has no effect if no menu is presented. This method will query the position from the delegate method
/// `editMenuInteraction:targetRectForConfiguration:`if it is implemented.
#[unsafe(method(updateVisibleMenuPositionAnimated:))]
#[unsafe(method_family = none)]
pub fn updateVisibleMenuPositionAnimated(&self, animated: bool);
#[cfg(all(
feature = "UIResponder",
feature = "UIView",
feature = "objc2-core-foundation"
))]
/// Returns the interaction's location within the given view.
#[unsafe(method(locationInView:))]
#[unsafe(method_family = none)]
pub fn locationInView(&self, view: Option<&UIView>) -> CGPoint;
#[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>;
);
}
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uieditmenuinteractionanimating?language=objc)
pub unsafe trait UIEditMenuInteractionAnimating:
NSObjectProtocol + MainThreadOnly
{
#[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/uieditmenuinteractiondelegate?language=objc)
pub unsafe trait UIEditMenuInteractionDelegate: NSObjectProtocol {
#[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
/// Called when the interaction begins.
///
///
/// Parameter `interaction`: The UIEditMenuInteraction.
///
/// Parameter `configuration`: The UIEditMenuConfiguration object used to present the menu.
///
/// Parameter `suggestedActions`: An array of suggested actions gathered from the UIResponder chain. You may
/// include these actions in the hierarchy to display them in the resulting menu.
///
///
/// Returns: Return a UIMenu describing the desired menu hierarchy. Return
/// `nil`to present the default system menu.
#[optional]
#[unsafe(method(editMenuInteraction:menuForConfiguration:suggestedActions:))]
#[unsafe(method_family = none)]
fn editMenuInteraction_menuForConfiguration_suggestedActions(
&self,
interaction: &UIEditMenuInteraction,
configuration: &UIEditMenuConfiguration,
suggested_actions: &NSArray<UIMenuElement>,
) -> Option<Retained<UIMenu>>;
#[cfg(feature = "objc2-core-foundation")]
/// Called when the interaction begins, or when
/// `updateVisibleMenuPosition(animated:)`is called.
///
///
/// Parameter `interaction`: The UIEditMenuInteraction.
///
/// Parameter `configuration`: The UIEditMenuConfiguration object used to present the menu.
///
///
/// Returns: Return a rectangle relative to the interaction's view. The menu will be displayed around
/// target rect, space permitting, with the arrow pointing at the edge of the target rectangle
/// for the specified arrow direction of the configuration. By default, an empty-sized rectangle
/// centered at
/// `configuration.sourcePoint`will be used if this method is not implemented. Return
/// `CGRectNull`to use the default rect.
#[optional]
#[unsafe(method(editMenuInteraction:targetRectForConfiguration:))]
#[unsafe(method_family = none)]
fn editMenuInteraction_targetRectForConfiguration(
&self,
interaction: &UIEditMenuInteraction,
configuration: &UIEditMenuConfiguration,
) -> CGRect;
/// Called when the interaction is about to present the menu.
///
///
/// Parameter `interaction`: The UIEditMenuInteraction.
///
/// Parameter `configuration`: The configuration object of the menu about to be presented by this interaction.
///
/// Parameter `animator`: Appearance animator. Add animations to this object to run them alongside the appearance transition.
#[optional]
#[unsafe(method(editMenuInteraction:willPresentMenuForConfiguration:animator:))]
#[unsafe(method_family = none)]
fn editMenuInteraction_willPresentMenuForConfiguration_animator(
&self,
interaction: &UIEditMenuInteraction,
configuration: &UIEditMenuConfiguration,
animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
);
/// Called when the interaction is about to dismiss the menu.
///
///
/// Parameter `interaction`: The UIEditMenuInteraction.
///
/// Parameter `configuration`: The configuration object of the menu about to be dismissed by this interaction.
///
/// Parameter `animator`: Dismiss animator. Add animations to this object to run them alongside the dismiss transition.
#[optional]
#[unsafe(method(editMenuInteraction:willDismissMenuForConfiguration:animator:))]
#[unsafe(method_family = none)]
fn editMenuInteraction_willDismissMenuForConfiguration_animator(
&self,
interaction: &UIEditMenuInteraction,
configuration: &UIEditMenuConfiguration,
animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
);
}
);