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
//! 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::*;
use objc2_foundation::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenuconfigurationelementorder?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIContextMenuConfigurationElementOrder(pub NSInteger);
impl UIContextMenuConfigurationElementOrder {
#[doc(alias = "UIContextMenuConfigurationElementOrderAutomatic")]
pub const Automatic: Self = Self(0);
/// Allows the system to choose the appropriate ordering strategy for the current context.
#[doc(alias = "UIContextMenuConfigurationElementOrderPriority")]
pub const Priority: Self = Self(1);
/// Order menu elements according to priority. Keeping the first element in the UIMenu closest to user's interaction point.
#[doc(alias = "UIContextMenuConfigurationElementOrderFixed")]
pub const Fixed: Self = Self(2);
}
unsafe impl Encode for UIContextMenuConfigurationElementOrder {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UIContextMenuConfigurationElementOrder {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// Return a UIAction-based UIMenu describing the desired action hierarchy.
///
///
/// Parameter `suggestedActions`: An array of suggested actions gathered from the UIResponder chain. You may choose to include
/// some of these actions in the hierarchy returned from this block to display them in the resulting menu.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenuactionprovider?language=objc)
#[cfg(all(feature = "UIMenu", feature = "UIMenuElement", feature = "block2"))]
pub type UIContextMenuActionProvider =
*mut block2::DynBlock<dyn Fn(NonNull<NSArray<UIMenuElement>>) -> *mut UIMenu>;
/// Return a UIViewController to be displayed as this menu's preview component.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenucontentpreviewprovider?language=objc)
#[cfg(all(
feature = "UIResponder",
feature = "UIViewController",
feature = "block2"
))]
pub type UIContextMenuContentPreviewProvider =
*mut block2::DynBlock<dyn Fn() -> *mut UIViewController>;
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenuconfiguration?language=objc)
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UIContextMenuConfiguration;
);
extern_conformance!(
unsafe impl NSObjectProtocol for UIContextMenuConfiguration {}
);
impl UIContextMenuConfiguration {
extern_methods!(
/// This configuration's identifier. When representing multiple items in your app, this identifier
/// corresponds to the primary item (i.e. the one with which the user interacted when invoking the menu).
#[unsafe(method(identifier))]
#[unsafe(method_family = none)]
pub fn identifier(&self) -> Retained<ProtocolObject<dyn NSCopying>>;
/// When this menu acts on multiple items, you may include the identifiers of secondary items to display a multi-item menu.
#[unsafe(method(secondaryItemIdentifiers))]
#[unsafe(method_family = none)]
pub fn secondaryItemIdentifiers(&self) -> Retained<NSSet<ProtocolObject<dyn NSCopying>>>;
/// Setter for [`secondaryItemIdentifiers`][Self::secondaryItemIdentifiers].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
///
/// # Safety
///
/// `secondary_item_identifiers` generic should be of the correct type.
#[unsafe(method(setSecondaryItemIdentifiers:))]
#[unsafe(method_family = none)]
pub unsafe fn setSecondaryItemIdentifiers(
&self,
secondary_item_identifiers: &NSSet<ProtocolObject<dyn NSCopying>>,
);
/// Number of items on which this menu acts. Used to badge a multi-item menu's preview stack.
/// When unset, this value is determined automatically by the system. Values lower than 2 hide the badge.
#[unsafe(method(badgeCount))]
#[unsafe(method_family = none)]
pub fn badgeCount(&self) -> NSInteger;
/// Setter for [`badgeCount`][Self::badgeCount].
#[unsafe(method(setBadgeCount:))]
#[unsafe(method_family = none)]
pub fn setBadgeCount(&self, badge_count: NSInteger);
/// Preferred menu element ordering strategy for this menu.
#[unsafe(method(preferredMenuElementOrder))]
#[unsafe(method_family = none)]
pub fn preferredMenuElementOrder(&self) -> UIContextMenuConfigurationElementOrder;
/// Setter for [`preferredMenuElementOrder`][Self::preferredMenuElementOrder].
#[unsafe(method(setPreferredMenuElementOrder:))]
#[unsafe(method_family = none)]
pub fn setPreferredMenuElementOrder(
&self,
preferred_menu_element_order: UIContextMenuConfigurationElementOrder,
);
#[cfg(all(
feature = "UIMenu",
feature = "UIMenuElement",
feature = "UIResponder",
feature = "UIViewController",
feature = "block2"
))]
/// Returns a UIContextMenuConfiguration.
///
///
/// Parameter `identifier`: Optional unique identifier. If omitted, an NSUUID will be generated. May be used to
/// identify this configuration throughout the interaction's lifecycle.
///
/// Parameter `previewProvider`: Optional preview view controller provider block, called when the menu is about to be presented.
///
/// Parameter `actionProvider`: Optional action provider block, called when the menu is about to be presented.
///
/// # Safety
///
/// - `identifier` should be of the correct type.
/// - `preview_provider` must be a valid pointer or null.
/// - `action_provider` must be a valid pointer or null.
#[unsafe(method(configurationWithIdentifier:previewProvider:actionProvider:))]
#[unsafe(method_family = none)]
pub unsafe fn configurationWithIdentifier_previewProvider_actionProvider(
identifier: Option<&ProtocolObject<dyn NSCopying>>,
preview_provider: UIContextMenuContentPreviewProvider,
action_provider: UIContextMenuActionProvider,
mtm: MainThreadMarker,
) -> Retained<Self>;
);
}
/// Methods declared on superclass `NSObject`.
impl UIContextMenuConfiguration {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}