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
21extern_conformance!(
22    unsafe impl NSCoding for NSTouchBar {}
23);
24
25extern_conformance!(
26    unsafe impl NSObjectProtocol for NSTouchBar {}
27);
28
29impl NSTouchBar {
30    extern_methods!(
31        #[unsafe(method(init))]
32        #[unsafe(method_family = init)]
33        pub fn init(this: Allocated<Self>) -> Retained<Self>;
34
35        /// # Safety
36        ///
37        /// `coder` possibly has further requirements.
38        #[unsafe(method(initWithCoder:))]
39        #[unsafe(method_family = init)]
40        pub unsafe fn initWithCoder(
41            this: Allocated<Self>,
42            coder: &NSCoder,
43        ) -> Option<Retained<Self>>;
44
45        #[unsafe(method(customizationIdentifier))]
46        #[unsafe(method_family = none)]
47        pub fn customizationIdentifier(
48            &self,
49        ) -> Option<Retained<NSTouchBarCustomizationIdentifier>>;
50
51        /// Setter for [`customizationIdentifier`][Self::customizationIdentifier].
52        ///
53        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
54        #[unsafe(method(setCustomizationIdentifier:))]
55        #[unsafe(method_family = none)]
56        pub fn setCustomizationIdentifier(
57            &self,
58            customization_identifier: Option<&NSTouchBarCustomizationIdentifier>,
59        );
60
61        #[cfg(feature = "NSTouchBarItem")]
62        #[unsafe(method(customizationAllowedItemIdentifiers))]
63        #[unsafe(method_family = none)]
64        pub fn customizationAllowedItemIdentifiers(
65            &self,
66        ) -> Retained<NSArray<NSTouchBarItemIdentifier>>;
67
68        #[cfg(feature = "NSTouchBarItem")]
69        /// Setter for [`customizationAllowedItemIdentifiers`][Self::customizationAllowedItemIdentifiers].
70        ///
71        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
72        #[unsafe(method(setCustomizationAllowedItemIdentifiers:))]
73        #[unsafe(method_family = none)]
74        pub fn setCustomizationAllowedItemIdentifiers(
75            &self,
76            customization_allowed_item_identifiers: &NSArray<NSTouchBarItemIdentifier>,
77        );
78
79        #[cfg(feature = "NSTouchBarItem")]
80        #[unsafe(method(customizationRequiredItemIdentifiers))]
81        #[unsafe(method_family = none)]
82        pub fn customizationRequiredItemIdentifiers(
83            &self,
84        ) -> Retained<NSArray<NSTouchBarItemIdentifier>>;
85
86        #[cfg(feature = "NSTouchBarItem")]
87        /// Setter for [`customizationRequiredItemIdentifiers`][Self::customizationRequiredItemIdentifiers].
88        ///
89        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
90        #[unsafe(method(setCustomizationRequiredItemIdentifiers:))]
91        #[unsafe(method_family = none)]
92        pub fn setCustomizationRequiredItemIdentifiers(
93            &self,
94            customization_required_item_identifiers: &NSArray<NSTouchBarItemIdentifier>,
95        );
96
97        #[cfg(feature = "NSTouchBarItem")]
98        #[unsafe(method(defaultItemIdentifiers))]
99        #[unsafe(method_family = none)]
100        pub fn defaultItemIdentifiers(&self) -> Retained<NSArray<NSTouchBarItemIdentifier>>;
101
102        #[cfg(feature = "NSTouchBarItem")]
103        /// Setter for [`defaultItemIdentifiers`][Self::defaultItemIdentifiers].
104        ///
105        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
106        #[unsafe(method(setDefaultItemIdentifiers:))]
107        #[unsafe(method_family = none)]
108        pub fn setDefaultItemIdentifiers(
109            &self,
110            default_item_identifiers: &NSArray<NSTouchBarItemIdentifier>,
111        );
112
113        #[cfg(feature = "NSTouchBarItem")]
114        #[unsafe(method(itemIdentifiers))]
115        #[unsafe(method_family = none)]
116        pub fn itemIdentifiers(&self) -> Retained<NSArray<NSTouchBarItemIdentifier>>;
117
118        #[cfg(feature = "NSTouchBarItem")]
119        #[unsafe(method(principalItemIdentifier))]
120        #[unsafe(method_family = none)]
121        pub fn principalItemIdentifier(&self) -> Option<Retained<NSTouchBarItemIdentifier>>;
122
123        #[cfg(feature = "NSTouchBarItem")]
124        /// Setter for [`principalItemIdentifier`][Self::principalItemIdentifier].
125        ///
126        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
127        #[unsafe(method(setPrincipalItemIdentifier:))]
128        #[unsafe(method_family = none)]
129        pub fn setPrincipalItemIdentifier(
130            &self,
131            principal_item_identifier: Option<&NSTouchBarItemIdentifier>,
132        );
133
134        #[cfg(feature = "NSTouchBarItem")]
135        #[unsafe(method(escapeKeyReplacementItemIdentifier))]
136        #[unsafe(method_family = none)]
137        pub fn escapeKeyReplacementItemIdentifier(
138            &self,
139        ) -> Option<Retained<NSTouchBarItemIdentifier>>;
140
141        #[cfg(feature = "NSTouchBarItem")]
142        /// Setter for [`escapeKeyReplacementItemIdentifier`][Self::escapeKeyReplacementItemIdentifier].
143        ///
144        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
145        #[unsafe(method(setEscapeKeyReplacementItemIdentifier:))]
146        #[unsafe(method_family = none)]
147        pub fn setEscapeKeyReplacementItemIdentifier(
148            &self,
149            escape_key_replacement_item_identifier: Option<&NSTouchBarItemIdentifier>,
150        );
151
152        #[cfg(feature = "NSTouchBarItem")]
153        #[unsafe(method(templateItems))]
154        #[unsafe(method_family = none)]
155        pub fn templateItems(&self) -> Retained<NSSet<NSTouchBarItem>>;
156
157        #[cfg(feature = "NSTouchBarItem")]
158        /// Setter for [`templateItems`][Self::templateItems].
159        ///
160        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
161        #[unsafe(method(setTemplateItems:))]
162        #[unsafe(method_family = none)]
163        pub fn setTemplateItems(&self, template_items: &NSSet<NSTouchBarItem>);
164
165        #[unsafe(method(delegate))]
166        #[unsafe(method_family = none)]
167        pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSTouchBarDelegate>>>;
168
169        /// Setter for [`delegate`][Self::delegate].
170        ///
171        /// This is a [weak property][objc2::topics::weak_property].
172        #[unsafe(method(setDelegate:))]
173        #[unsafe(method_family = none)]
174        pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSTouchBarDelegate>>);
175
176        #[cfg(feature = "NSTouchBarItem")]
177        #[unsafe(method(itemForIdentifier:))]
178        #[unsafe(method_family = none)]
179        pub fn itemForIdentifier(
180            &self,
181            identifier: &NSTouchBarItemIdentifier,
182        ) -> Option<Retained<NSTouchBarItem>>;
183
184        #[unsafe(method(isVisible))]
185        #[unsafe(method_family = none)]
186        pub fn isVisible(&self) -> bool;
187
188        #[unsafe(method(isAutomaticCustomizeTouchBarMenuItemEnabled))]
189        #[unsafe(method_family = none)]
190        pub fn isAutomaticCustomizeTouchBarMenuItemEnabled(mtm: MainThreadMarker) -> bool;
191
192        /// Setter for [`isAutomaticCustomizeTouchBarMenuItemEnabled`][Self::isAutomaticCustomizeTouchBarMenuItemEnabled].
193        #[unsafe(method(setAutomaticCustomizeTouchBarMenuItemEnabled:))]
194        #[unsafe(method_family = none)]
195        pub fn setAutomaticCustomizeTouchBarMenuItemEnabled(
196            automatic_customize_touch_bar_menu_item_enabled: bool,
197            mtm: MainThreadMarker,
198        );
199    );
200}
201
202/// Methods declared on superclass `NSObject`.
203impl NSTouchBar {
204    extern_methods!(
205        #[unsafe(method(new))]
206        #[unsafe(method_family = new)]
207        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
208    );
209}
210
211extern_protocol!(
212    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstouchbardelegate?language=objc)
213    pub unsafe trait NSTouchBarDelegate: NSObjectProtocol + MainThreadOnly {
214        #[cfg(feature = "NSTouchBarItem")]
215        #[optional]
216        #[unsafe(method(touchBar:makeItemForIdentifier:))]
217        #[unsafe(method_family = none)]
218        fn touchBar_makeItemForIdentifier(
219            &self,
220            touch_bar: &NSTouchBar,
221            identifier: &NSTouchBarItemIdentifier,
222        ) -> Option<Retained<NSTouchBarItem>>;
223    }
224);
225
226extern_protocol!(
227    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstouchbarprovider?language=objc)
228    pub unsafe trait NSTouchBarProvider: NSObjectProtocol + MainThreadOnly {
229        #[unsafe(method(touchBar))]
230        #[unsafe(method_family = none)]
231        fn touchBar(&self) -> Option<Retained<NSTouchBar>>;
232    }
233);
234
235/// NSTouchBarProvider.
236#[cfg(feature = "NSResponder")]
237impl NSResponder {
238    extern_methods!(
239        #[unsafe(method(touchBar))]
240        #[unsafe(method_family = none)]
241        pub fn touchBar(&self) -> Option<Retained<NSTouchBar>>;
242
243        /// Setter for [`touchBar`][Self::touchBar].
244        #[unsafe(method(setTouchBar:))]
245        #[unsafe(method_family = none)]
246        pub fn setTouchBar(&self, touch_bar: Option<&NSTouchBar>);
247
248        #[unsafe(method(makeTouchBar))]
249        #[unsafe(method_family = none)]
250        pub fn makeTouchBar(&self) -> Option<Retained<NSTouchBar>>;
251    );
252}
253
254#[cfg(feature = "NSResponder")]
255extern_conformance!(
256    unsafe impl NSTouchBarProvider for NSResponder {}
257);
258
259/// NSTouchBarCustomization.
260#[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
261impl NSApplication {
262    extern_methods!(
263        /// 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.
264        #[unsafe(method(isAutomaticCustomizeTouchBarMenuItemEnabled))]
265        #[unsafe(method_family = none)]
266        pub fn isAutomaticCustomizeTouchBarMenuItemEnabled(&self) -> bool;
267
268        /// Setter for [`isAutomaticCustomizeTouchBarMenuItemEnabled`][Self::isAutomaticCustomizeTouchBarMenuItemEnabled].
269        #[unsafe(method(setAutomaticCustomizeTouchBarMenuItemEnabled:))]
270        #[unsafe(method_family = none)]
271        pub fn setAutomaticCustomizeTouchBarMenuItemEnabled(
272            &self,
273            automatic_customize_touch_bar_menu_item_enabled: bool,
274        );
275
276        /// 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.
277        ///
278        /// # Safety
279        ///
280        /// `sender` should be of the correct type.
281        #[unsafe(method(toggleTouchBarCustomizationPalette:))]
282        #[unsafe(method_family = none)]
283        pub unsafe fn toggleTouchBarCustomizationPalette(&self, sender: Option<&AnyObject>);
284    );
285}