objc2_app_kit/generated/
NSTouchBar.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/appkit/nstouchbarcustomizationidentifier?language=objc)
11pub type NSTouchBarCustomizationIdentifier = NSString;
12
13extern_class!(
14    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstouchbar?language=objc)
15    #[unsafe(super(NSObject))]
16    #[thread_kind = MainThreadOnly]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    pub struct NSTouchBar;
19);
20
21unsafe impl NSCoding for NSTouchBar {}
22
23unsafe impl NSObjectProtocol for NSTouchBar {}
24
25impl NSTouchBar {
26    extern_methods!(
27        #[unsafe(method(init))]
28        #[unsafe(method_family = init)]
29        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
30
31        #[unsafe(method(initWithCoder:))]
32        #[unsafe(method_family = init)]
33        pub unsafe fn initWithCoder(
34            this: Allocated<Self>,
35            coder: &NSCoder,
36        ) -> Option<Retained<Self>>;
37
38        #[unsafe(method(customizationIdentifier))]
39        #[unsafe(method_family = none)]
40        pub unsafe fn customizationIdentifier(
41            &self,
42        ) -> Option<Retained<NSTouchBarCustomizationIdentifier>>;
43
44        /// Setter for [`customizationIdentifier`][Self::customizationIdentifier].
45        #[unsafe(method(setCustomizationIdentifier:))]
46        #[unsafe(method_family = none)]
47        pub unsafe fn setCustomizationIdentifier(
48            &self,
49            customization_identifier: Option<&NSTouchBarCustomizationIdentifier>,
50        );
51
52        #[cfg(feature = "NSTouchBarItem")]
53        #[unsafe(method(customizationAllowedItemIdentifiers))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn customizationAllowedItemIdentifiers(
56            &self,
57        ) -> Retained<NSArray<NSTouchBarItemIdentifier>>;
58
59        #[cfg(feature = "NSTouchBarItem")]
60        /// Setter for [`customizationAllowedItemIdentifiers`][Self::customizationAllowedItemIdentifiers].
61        #[unsafe(method(setCustomizationAllowedItemIdentifiers:))]
62        #[unsafe(method_family = none)]
63        pub unsafe fn setCustomizationAllowedItemIdentifiers(
64            &self,
65            customization_allowed_item_identifiers: &NSArray<NSTouchBarItemIdentifier>,
66        );
67
68        #[cfg(feature = "NSTouchBarItem")]
69        #[unsafe(method(customizationRequiredItemIdentifiers))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn customizationRequiredItemIdentifiers(
72            &self,
73        ) -> Retained<NSArray<NSTouchBarItemIdentifier>>;
74
75        #[cfg(feature = "NSTouchBarItem")]
76        /// Setter for [`customizationRequiredItemIdentifiers`][Self::customizationRequiredItemIdentifiers].
77        #[unsafe(method(setCustomizationRequiredItemIdentifiers:))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn setCustomizationRequiredItemIdentifiers(
80            &self,
81            customization_required_item_identifiers: &NSArray<NSTouchBarItemIdentifier>,
82        );
83
84        #[cfg(feature = "NSTouchBarItem")]
85        #[unsafe(method(defaultItemIdentifiers))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn defaultItemIdentifiers(&self) -> Retained<NSArray<NSTouchBarItemIdentifier>>;
88
89        #[cfg(feature = "NSTouchBarItem")]
90        /// Setter for [`defaultItemIdentifiers`][Self::defaultItemIdentifiers].
91        #[unsafe(method(setDefaultItemIdentifiers:))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn setDefaultItemIdentifiers(
94            &self,
95            default_item_identifiers: &NSArray<NSTouchBarItemIdentifier>,
96        );
97
98        #[cfg(feature = "NSTouchBarItem")]
99        #[unsafe(method(itemIdentifiers))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn itemIdentifiers(&self) -> Retained<NSArray<NSTouchBarItemIdentifier>>;
102
103        #[cfg(feature = "NSTouchBarItem")]
104        #[unsafe(method(principalItemIdentifier))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn principalItemIdentifier(&self) -> Option<Retained<NSTouchBarItemIdentifier>>;
107
108        #[cfg(feature = "NSTouchBarItem")]
109        /// Setter for [`principalItemIdentifier`][Self::principalItemIdentifier].
110        #[unsafe(method(setPrincipalItemIdentifier:))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn setPrincipalItemIdentifier(
113            &self,
114            principal_item_identifier: Option<&NSTouchBarItemIdentifier>,
115        );
116
117        #[cfg(feature = "NSTouchBarItem")]
118        #[unsafe(method(escapeKeyReplacementItemIdentifier))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn escapeKeyReplacementItemIdentifier(
121            &self,
122        ) -> Option<Retained<NSTouchBarItemIdentifier>>;
123
124        #[cfg(feature = "NSTouchBarItem")]
125        /// Setter for [`escapeKeyReplacementItemIdentifier`][Self::escapeKeyReplacementItemIdentifier].
126        #[unsafe(method(setEscapeKeyReplacementItemIdentifier:))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn setEscapeKeyReplacementItemIdentifier(
129            &self,
130            escape_key_replacement_item_identifier: Option<&NSTouchBarItemIdentifier>,
131        );
132
133        #[cfg(feature = "NSTouchBarItem")]
134        #[unsafe(method(templateItems))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn templateItems(&self) -> Retained<NSSet<NSTouchBarItem>>;
137
138        #[cfg(feature = "NSTouchBarItem")]
139        /// Setter for [`templateItems`][Self::templateItems].
140        #[unsafe(method(setTemplateItems:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn setTemplateItems(&self, template_items: &NSSet<NSTouchBarItem>);
143
144        #[unsafe(method(delegate))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSTouchBarDelegate>>>;
147
148        /// This is a [weak property][objc2::topics::weak_property].
149        /// Setter for [`delegate`][Self::delegate].
150        #[unsafe(method(setDelegate:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSTouchBarDelegate>>);
153
154        #[cfg(feature = "NSTouchBarItem")]
155        #[unsafe(method(itemForIdentifier:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn itemForIdentifier(
158            &self,
159            identifier: &NSTouchBarItemIdentifier,
160        ) -> Option<Retained<NSTouchBarItem>>;
161
162        #[unsafe(method(isVisible))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn isVisible(&self) -> bool;
165
166        #[unsafe(method(isAutomaticCustomizeTouchBarMenuItemEnabled))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn isAutomaticCustomizeTouchBarMenuItemEnabled(mtm: MainThreadMarker) -> bool;
169
170        /// Setter for [`isAutomaticCustomizeTouchBarMenuItemEnabled`][Self::isAutomaticCustomizeTouchBarMenuItemEnabled].
171        #[unsafe(method(setAutomaticCustomizeTouchBarMenuItemEnabled:))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn setAutomaticCustomizeTouchBarMenuItemEnabled(
174            automatic_customize_touch_bar_menu_item_enabled: bool,
175            mtm: MainThreadMarker,
176        );
177    );
178}
179
180/// Methods declared on superclass `NSObject`.
181impl NSTouchBar {
182    extern_methods!(
183        #[unsafe(method(new))]
184        #[unsafe(method_family = new)]
185        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
186    );
187}
188
189extern_protocol!(
190    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstouchbardelegate?language=objc)
191    pub unsafe trait NSTouchBarDelegate: NSObjectProtocol + MainThreadOnly {
192        #[cfg(feature = "NSTouchBarItem")]
193        #[optional]
194        #[unsafe(method(touchBar:makeItemForIdentifier:))]
195        #[unsafe(method_family = none)]
196        unsafe fn touchBar_makeItemForIdentifier(
197            &self,
198            touch_bar: &NSTouchBar,
199            identifier: &NSTouchBarItemIdentifier,
200        ) -> Option<Retained<NSTouchBarItem>>;
201    }
202);
203
204extern_protocol!(
205    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstouchbarprovider?language=objc)
206    pub unsafe trait NSTouchBarProvider: NSObjectProtocol + MainThreadOnly {
207        #[unsafe(method(touchBar))]
208        #[unsafe(method_family = none)]
209        unsafe fn touchBar(&self) -> Option<Retained<NSTouchBar>>;
210    }
211);
212
213/// NSTouchBarProvider.
214#[cfg(feature = "NSResponder")]
215impl NSResponder {
216    extern_methods!(
217        #[unsafe(method(touchBar))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn touchBar(&self) -> Option<Retained<NSTouchBar>>;
220
221        /// Setter for [`touchBar`][Self::touchBar].
222        #[unsafe(method(setTouchBar:))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn setTouchBar(&self, touch_bar: Option<&NSTouchBar>);
225
226        #[unsafe(method(makeTouchBar))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn makeTouchBar(&self) -> Option<Retained<NSTouchBar>>;
229    );
230}
231
232#[cfg(feature = "NSResponder")]
233unsafe impl NSTouchBarProvider for NSResponder {}
234
235/// NSTouchBarCustomization.
236#[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
237impl NSApplication {
238    extern_methods!(
239        /// Whether or not a menu item to customize the NSTouchBar can be automatically added to the main menu. It will only actually be added when Touch Bar hardware or simulator is present. Defaults to NO. Setting this property to YES is the recommended way to add the customization menu item. But if non-standard placement of the menu item is needed, creating a menu item with an action of `toggleTouchBarCustomizationPalette:` can be used instead.
240        #[unsafe(method(isAutomaticCustomizeTouchBarMenuItemEnabled))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn isAutomaticCustomizeTouchBarMenuItemEnabled(&self) -> bool;
243
244        /// Setter for [`isAutomaticCustomizeTouchBarMenuItemEnabled`][Self::isAutomaticCustomizeTouchBarMenuItemEnabled].
245        #[unsafe(method(setAutomaticCustomizeTouchBarMenuItemEnabled:))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn setAutomaticCustomizeTouchBarMenuItemEnabled(
248            &self,
249            automatic_customize_touch_bar_menu_item_enabled: bool,
250        );
251
252        /// Show or dismiss the customization palette for the currently displayed NSTouchBars. NSApplication validates this selector against whether the current NSTouchBars are customizable and, if configured on a menu item, will standardize and localize the title. If the current system does not have Touch Bar support, the menu item will be automatically hidden.
253        #[unsafe(method(toggleTouchBarCustomizationPalette:))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn toggleTouchBarCustomizationPalette(&self, sender: Option<&AnyObject>);
256    );
257}