objc2_ui_kit/generated/
UIEditMenuInteraction.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::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uieditmenuarrowdirection?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct UIEditMenuArrowDirection(pub NSInteger);
17impl UIEditMenuArrowDirection {
18    #[doc(alias = "UIEditMenuArrowDirectionAutomatic")]
19    pub const Automatic: Self = Self(0);
20    #[doc(alias = "UIEditMenuArrowDirectionUp")]
21    pub const Up: Self = Self(1);
22    #[doc(alias = "UIEditMenuArrowDirectionDown")]
23    pub const Down: Self = Self(2);
24    #[doc(alias = "UIEditMenuArrowDirectionLeft")]
25    pub const Left: Self = Self(3);
26    #[doc(alias = "UIEditMenuArrowDirectionRight")]
27    pub const Right: Self = Self(4);
28}
29
30unsafe impl Encode for UIEditMenuArrowDirection {
31    const ENCODING: Encoding = NSInteger::ENCODING;
32}
33
34unsafe impl RefEncode for UIEditMenuArrowDirection {
35    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38extern_class!(
39    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uieditmenuconfiguration?language=objc)
40    #[unsafe(super(NSObject))]
41    #[thread_kind = MainThreadOnly]
42    #[derive(Debug, PartialEq, Eq, Hash)]
43    pub struct UIEditMenuConfiguration;
44);
45
46extern_conformance!(
47    unsafe impl NSObjectProtocol for UIEditMenuConfiguration {}
48);
49
50impl UIEditMenuConfiguration {
51    extern_methods!(
52        /// The unique identifier of the configuration.
53        #[unsafe(method(identifier))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn identifier(&self) -> Retained<ProtocolObject<dyn NSCopying>>;
56
57        #[cfg(feature = "objc2-core-foundation")]
58        /// The source location of the menu. The suggested actions menu elements will be derived from this location in the interaction's view.
59        /// By default, the menu will be presented from this location. You can change the presentation source of the menu with the delegate
60        /// method
61        /// `editMenuInteraction:targetRectForConfiguration:`
62        #[unsafe(method(sourcePoint))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn sourcePoint(&self) -> CGPoint;
65
66        /// The preferred arrow direction of the edit menu. Default is
67        /// `UIEditMenuArrowDirectionAutomatic`
68        #[unsafe(method(preferredArrowDirection))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn preferredArrowDirection(&self) -> UIEditMenuArrowDirection;
71
72        /// Setter for [`preferredArrowDirection`][Self::preferredArrowDirection].
73        #[unsafe(method(setPreferredArrowDirection:))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn setPreferredArrowDirection(
76            &self,
77            preferred_arrow_direction: UIEditMenuArrowDirection,
78        );
79
80        #[cfg(feature = "objc2-core-foundation")]
81        /// Creates a new configuration with the specified source location.
82        #[unsafe(method(configurationWithIdentifier:sourcePoint:))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn configurationWithIdentifier_sourcePoint(
85            identifier: Option<&ProtocolObject<dyn NSCopying>>,
86            source_point: CGPoint,
87            mtm: MainThreadMarker,
88        ) -> Retained<Self>;
89
90        #[unsafe(method(init))]
91        #[unsafe(method_family = init)]
92        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
93
94        #[unsafe(method(new))]
95        #[unsafe(method_family = new)]
96        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
97    );
98}
99
100extern_class!(
101    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uieditmenuinteraction?language=objc)
102    #[unsafe(super(NSObject))]
103    #[thread_kind = MainThreadOnly]
104    #[derive(Debug, PartialEq, Eq, Hash)]
105    pub struct UIEditMenuInteraction;
106);
107
108extern_conformance!(
109    unsafe impl NSObjectProtocol for UIEditMenuInteraction {}
110);
111
112#[cfg(feature = "UIInteraction")]
113extern_conformance!(
114    unsafe impl UIInteraction for UIEditMenuInteraction {}
115);
116
117impl UIEditMenuInteraction {
118    extern_methods!(
119        /// The object that defines the delegate of the interaction.
120        #[unsafe(method(delegate))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn delegate(
123            &self,
124        ) -> Option<Retained<ProtocolObject<dyn UIEditMenuInteractionDelegate>>>;
125
126        /// Creates a new edit menu interaction with the specified delegate.
127        #[unsafe(method(initWithDelegate:))]
128        #[unsafe(method_family = init)]
129        pub unsafe fn initWithDelegate(
130            this: Allocated<Self>,
131            delegate: Option<&ProtocolObject<dyn UIEditMenuInteractionDelegate>>,
132        ) -> Retained<Self>;
133
134        /// Presents an edit menu with the specified
135        /// `configuration`object.
136        /// If a menu is already presented, it will be dismissed automatically before the new menu is presented.
137        ///
138        /// :
139        /// `presentEditMenuWithConfiguration:`is not supported on Mac Catalyst.
140        #[unsafe(method(presentEditMenuWithConfiguration:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn presentEditMenuWithConfiguration(
143            &self,
144            configuration: &UIEditMenuConfiguration,
145        );
146
147        /// Dismiss the currently active menu if one is currently presented.
148        #[unsafe(method(dismissMenu))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn dismissMenu(&self);
151
152        /// Reloads the visible menu. This menu has no effect if there is no menu presented. This method will query
153        /// the menu again from the delegate method
154        /// `editMenuInteraction:menuForConfiguration:suggestedActions:`and refresh the UI with the updated menu.
155        #[unsafe(method(reloadVisibleMenu))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn reloadVisibleMenu(&self);
158
159        /// Updates the position of the currently visible menu, with an option to animate the action. This method
160        /// has no effect if no menu is presented. This method will query the position from the delegate method
161        /// `editMenuInteraction:targetRectForConfiguration:`if it is implemented.
162        #[unsafe(method(updateVisibleMenuPositionAnimated:))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn updateVisibleMenuPositionAnimated(&self, animated: bool);
165
166        #[cfg(all(
167            feature = "UIResponder",
168            feature = "UIView",
169            feature = "objc2-core-foundation"
170        ))]
171        /// Returns the interaction's location within the given view.
172        #[unsafe(method(locationInView:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn locationInView(&self, view: Option<&UIView>) -> CGPoint;
175
176        #[unsafe(method(init))]
177        #[unsafe(method_family = init)]
178        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
179
180        #[unsafe(method(new))]
181        #[unsafe(method_family = new)]
182        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
183    );
184}
185
186extern_protocol!(
187    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uieditmenuinteractionanimating?language=objc)
188    pub unsafe trait UIEditMenuInteractionAnimating:
189        NSObjectProtocol + MainThreadOnly
190    {
191        #[cfg(feature = "block2")]
192        #[unsafe(method(addAnimations:))]
193        #[unsafe(method_family = none)]
194        unsafe fn addAnimations(&self, animations: &block2::DynBlock<dyn Fn()>);
195
196        #[cfg(feature = "block2")]
197        #[unsafe(method(addCompletion:))]
198        #[unsafe(method_family = none)]
199        unsafe fn addCompletion(&self, completion: &block2::DynBlock<dyn Fn()>);
200    }
201);
202
203extern_protocol!(
204    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uieditmenuinteractiondelegate?language=objc)
205    pub unsafe trait UIEditMenuInteractionDelegate:
206        NSObjectProtocol + MainThreadOnly
207    {
208        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
209        /// Called when the interaction begins.
210        ///
211        ///
212        /// Parameter `interaction`: The UIEditMenuInteraction.
213        ///
214        /// Parameter `configuration`: The UIEditMenuConfiguration object used to present the menu.
215        ///
216        /// Parameter `suggestedActions`: An array of suggested actions gathered from the UIResponder chain. You may
217        /// include these actions in the hierarchy to display them in the resulting menu.
218        ///
219        ///
220        /// Returns: Return a UIMenu describing the desired menu hierarchy. Return
221        /// `nil`to present the default system menu.
222        #[optional]
223        #[unsafe(method(editMenuInteraction:menuForConfiguration:suggestedActions:))]
224        #[unsafe(method_family = none)]
225        unsafe fn editMenuInteraction_menuForConfiguration_suggestedActions(
226            &self,
227            interaction: &UIEditMenuInteraction,
228            configuration: &UIEditMenuConfiguration,
229            suggested_actions: &NSArray<UIMenuElement>,
230        ) -> Option<Retained<UIMenu>>;
231
232        #[cfg(feature = "objc2-core-foundation")]
233        /// Called when the interaction begins, or when
234        /// `updateVisibleMenuPosition(animated:)`is called.
235        ///
236        ///
237        /// Parameter `interaction`: The UIEditMenuInteraction.
238        ///
239        /// Parameter `configuration`: The UIEditMenuConfiguration object used to present the menu.
240        ///
241        ///
242        /// Returns: Return a rectangle relative to the interaction's view. The menu will be displayed around
243        /// target rect, space permitting, with the arrow pointing at the edge of the target rectangle
244        /// for the specified arrow direction of the configuration. By default, an empty-sized rectangle
245        /// centered at
246        /// `configuration.sourcePoint`will be used if this method is not implemented. Return
247        /// `CGRectNull`to use the default rect.
248        #[optional]
249        #[unsafe(method(editMenuInteraction:targetRectForConfiguration:))]
250        #[unsafe(method_family = none)]
251        unsafe fn editMenuInteraction_targetRectForConfiguration(
252            &self,
253            interaction: &UIEditMenuInteraction,
254            configuration: &UIEditMenuConfiguration,
255        ) -> CGRect;
256
257        /// Called when the interaction is about to present the menu.
258        ///
259        ///
260        /// Parameter `interaction`: The UIEditMenuInteraction.
261        ///
262        /// Parameter `configuration`: The configuration object of the menu about to be presented by this interaction.
263        ///
264        /// Parameter `animator`: Appearance animator. Add animations to this object to run them alongside the appearance transition.
265        #[optional]
266        #[unsafe(method(editMenuInteraction:willPresentMenuForConfiguration:animator:))]
267        #[unsafe(method_family = none)]
268        unsafe fn editMenuInteraction_willPresentMenuForConfiguration_animator(
269            &self,
270            interaction: &UIEditMenuInteraction,
271            configuration: &UIEditMenuConfiguration,
272            animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
273        );
274
275        /// Called when the interaction is about to dismiss the menu.
276        ///
277        ///
278        /// Parameter `interaction`: The UIEditMenuInteraction.
279        ///
280        /// Parameter `configuration`: The configuration object of the menu about to be dismissed by this interaction.
281        ///
282        /// Parameter `animator`: Dismiss animator. Add animations to this object to run them alongside the dismiss transition.
283        #[optional]
284        #[unsafe(method(editMenuInteraction:willDismissMenuForConfiguration:animator:))]
285        #[unsafe(method_family = none)]
286        unsafe fn editMenuInteraction_willDismissMenuForConfiguration_animator(
287            &self,
288            interaction: &UIEditMenuInteraction,
289            configuration: &UIEditMenuConfiguration,
290            animator: &ProtocolObject<dyn UIEditMenuInteractionAnimating>,
291        );
292    }
293);