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::DynBlock<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::DynBlock<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
64extern_conformance!(
65    unsafe impl NSObjectProtocol for UIContextMenuConfiguration {}
66);
67
68impl UIContextMenuConfiguration {
69    extern_methods!(
70        /// This configuration's identifier. When representing multiple items in your app, this identifier
71        /// corresponds to the primary item (i.e. the one with which the user interacted when invoking the menu).
72        #[unsafe(method(identifier))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn identifier(&self) -> Retained<ProtocolObject<dyn NSCopying>>;
75
76        /// When this menu acts on multiple items, you may include the identifiers of secondary items to display a multi-item menu.
77        #[unsafe(method(secondaryItemIdentifiers))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn secondaryItemIdentifiers(
80            &self,
81        ) -> Retained<NSSet<ProtocolObject<dyn NSCopying>>>;
82
83        /// Setter for [`secondaryItemIdentifiers`][Self::secondaryItemIdentifiers].
84        #[unsafe(method(setSecondaryItemIdentifiers:))]
85        #[unsafe(method_family = none)]
86        pub unsafe fn setSecondaryItemIdentifiers(
87            &self,
88            secondary_item_identifiers: &NSSet<ProtocolObject<dyn NSCopying>>,
89        );
90
91        /// Number of items on which this menu acts. Used to badge a multi-item menu's preview stack.
92        /// When unset, this value is determined automatically by the system. Values lower than 2 hide the badge.
93        #[unsafe(method(badgeCount))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn badgeCount(&self) -> NSInteger;
96
97        /// Setter for [`badgeCount`][Self::badgeCount].
98        #[unsafe(method(setBadgeCount:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn setBadgeCount(&self, badge_count: NSInteger);
101
102        /// Preferred menu element ordering strategy for this menu.
103        #[unsafe(method(preferredMenuElementOrder))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn preferredMenuElementOrder(&self) -> UIContextMenuConfigurationElementOrder;
106
107        /// Setter for [`preferredMenuElementOrder`][Self::preferredMenuElementOrder].
108        #[unsafe(method(setPreferredMenuElementOrder:))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn setPreferredMenuElementOrder(
111            &self,
112            preferred_menu_element_order: UIContextMenuConfigurationElementOrder,
113        );
114
115        #[cfg(all(
116            feature = "UIMenu",
117            feature = "UIMenuElement",
118            feature = "UIResponder",
119            feature = "UIViewController",
120            feature = "block2"
121        ))]
122        /// Returns a UIContextMenuConfiguration.
123        ///
124        ///
125        /// Parameter `identifier`: Optional unique identifier. If omitted, an NSUUID will be generated. May be used to
126        /// identify this configuration throughout the interaction's lifecycle.
127        ///
128        /// Parameter `previewProvider`: Optional preview view controller provider block, called when the menu is about to be presented.
129        ///
130        /// Parameter `actionProvider`: Optional action provider block, called when the menu is about to be presented.
131        #[unsafe(method(configurationWithIdentifier:previewProvider:actionProvider:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn configurationWithIdentifier_previewProvider_actionProvider(
134            identifier: Option<&ProtocolObject<dyn NSCopying>>,
135            preview_provider: UIContextMenuContentPreviewProvider,
136            action_provider: UIContextMenuActionProvider,
137            mtm: MainThreadMarker,
138        ) -> Retained<Self>;
139    );
140}
141
142/// Methods declared on superclass `NSObject`.
143impl UIContextMenuConfiguration {
144    extern_methods!(
145        #[unsafe(method(init))]
146        #[unsafe(method_family = init)]
147        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
148
149        #[unsafe(method(new))]
150        #[unsafe(method_family = new)]
151        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
152    );
153}