objc2_ui_kit/generated/
UIContextMenuConfiguration.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenuconfigurationelementorder?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UIContextMenuConfigurationElementOrder(pub NSInteger);
15impl UIContextMenuConfigurationElementOrder {
16    #[doc(alias = "UIContextMenuConfigurationElementOrderAutomatic")]
17    pub const Automatic: Self = Self(0);
18    /// Allows the system to choose the appropriate ordering strategy for the current context.
19    #[doc(alias = "UIContextMenuConfigurationElementOrderPriority")]
20    pub const Priority: Self = Self(1);
21    /// Order menu elements according to priority. Keeping the first element in the UIMenu closest to user's interaction point.
22    #[doc(alias = "UIContextMenuConfigurationElementOrderFixed")]
23    pub const Fixed: Self = Self(2);
24}
25
26unsafe impl Encode for UIContextMenuConfigurationElementOrder {
27    const ENCODING: Encoding = NSInteger::ENCODING;
28}
29
30unsafe impl RefEncode for UIContextMenuConfigurationElementOrder {
31    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
32}
33
34/// Return a UIAction-based UIMenu describing the desired action hierarchy.
35///
36///
37/// Parameter `suggestedActions`: An array of suggested actions gathered from the UIResponder chain. You may choose to include
38/// some of these actions in the hierarchy returned from this block to display them in the resulting menu.
39///
40/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenuactionprovider?language=objc)
41#[cfg(all(feature = "UIMenu", feature = "UIMenuElement", feature = "block2"))]
42pub type UIContextMenuActionProvider =
43    *mut block2::Block<dyn Fn(NonNull<NSArray<UIMenuElement>>) -> *mut UIMenu>;
44
45/// Return a UIViewController to be displayed as this menu's preview component.
46///
47/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenucontentpreviewprovider?language=objc)
48#[cfg(all(
49    feature = "UIResponder",
50    feature = "UIViewController",
51    feature = "block2"
52))]
53pub type UIContextMenuContentPreviewProvider =
54    *mut block2::Block<dyn Fn() -> *mut UIViewController>;
55
56extern_class!(
57    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicontextmenuconfiguration?language=objc)
58    #[unsafe(super(NSObject))]
59    #[thread_kind = MainThreadOnly]
60    #[derive(Debug, PartialEq, Eq, Hash)]
61    pub struct UIContextMenuConfiguration;
62);
63
64unsafe impl NSObjectProtocol for UIContextMenuConfiguration {}
65
66impl UIContextMenuConfiguration {
67    extern_methods!(
68        /// This configuration's identifier. When representing multiple items in your app, this identifier
69        /// corresponds to the primary item (i.e. the one with which the user interacted when invoking the menu).
70        #[unsafe(method(identifier))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn identifier(&self) -> Retained<ProtocolObject<dyn NSCopying>>;
73
74        /// When this menu acts on multiple items, you may include the identifiers of secondary items to display a multi-item menu.
75        #[unsafe(method(secondaryItemIdentifiers))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn secondaryItemIdentifiers(
78            &self,
79        ) -> Retained<NSSet<ProtocolObject<dyn NSCopying>>>;
80
81        /// Setter for [`secondaryItemIdentifiers`][Self::secondaryItemIdentifiers].
82        #[unsafe(method(setSecondaryItemIdentifiers:))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn setSecondaryItemIdentifiers(
85            &self,
86            secondary_item_identifiers: &NSSet<ProtocolObject<dyn NSCopying>>,
87        );
88
89        /// Number of items on which this menu acts. Used to badge a multi-item menu's preview stack.
90        /// When unset, this value is determined automatically by the system. Values lower than 2 hide the badge.
91        #[unsafe(method(badgeCount))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn badgeCount(&self) -> NSInteger;
94
95        /// Setter for [`badgeCount`][Self::badgeCount].
96        #[unsafe(method(setBadgeCount:))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn setBadgeCount(&self, badge_count: NSInteger);
99
100        /// Preferred menu element ordering strategy for this menu.
101        #[unsafe(method(preferredMenuElementOrder))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn preferredMenuElementOrder(&self) -> UIContextMenuConfigurationElementOrder;
104
105        /// Setter for [`preferredMenuElementOrder`][Self::preferredMenuElementOrder].
106        #[unsafe(method(setPreferredMenuElementOrder:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn setPreferredMenuElementOrder(
109            &self,
110            preferred_menu_element_order: UIContextMenuConfigurationElementOrder,
111        );
112
113        #[cfg(all(
114            feature = "UIMenu",
115            feature = "UIMenuElement",
116            feature = "UIResponder",
117            feature = "UIViewController",
118            feature = "block2"
119        ))]
120        /// Returns a UIContextMenuConfiguration.
121        ///
122        ///
123        /// Parameter `identifier`: Optional unique identifier. If omitted, an NSUUID will be generated. May be used to
124        /// identify this configuration throughout the interaction's lifecycle.
125        ///
126        /// Parameter `previewProvider`: Optional preview view controller provider block, called when the menu is about to be presented.
127        ///
128        /// Parameter `actionProvider`: Optional action provider block, called when the menu is about to be presented.
129        #[unsafe(method(configurationWithIdentifier:previewProvider:actionProvider:))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn configurationWithIdentifier_previewProvider_actionProvider(
132            identifier: Option<&ProtocolObject<dyn NSCopying>>,
133            preview_provider: UIContextMenuContentPreviewProvider,
134            action_provider: UIContextMenuActionProvider,
135            mtm: MainThreadMarker,
136        ) -> Retained<Self>;
137    );
138}
139
140/// Methods declared on superclass `NSObject`.
141impl UIContextMenuConfiguration {
142    extern_methods!(
143        #[unsafe(method(init))]
144        #[unsafe(method_family = init)]
145        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
146
147        #[unsafe(method(new))]
148        #[unsafe(method_family = new)]
149        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
150    );
151}