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