objc2_car_play/generated/
CPNowPlayingButton.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::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-ui-kit")]
10use objc2_ui_kit::*;
11
12use crate::*;
13
14extern "C" {
15    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpnowplayingbuttonmaximumimagesize?language=objc)
16    #[cfg(feature = "objc2-core-foundation")]
17    pub static CPNowPlayingButtonMaximumImageSize: CGSize;
18}
19
20extern_class!(
21    /// [Apple's documentation](https://developer.apple.com/documentation/carplay/cpnowplayingbutton?language=objc)
22    #[unsafe(super(NSObject))]
23    #[thread_kind = MainThreadOnly]
24    #[derive(Debug, PartialEq, Eq, Hash)]
25    pub struct CPNowPlayingButton;
26);
27
28extern_conformance!(
29    unsafe impl NSCoding for CPNowPlayingButton {}
30);
31
32extern_conformance!(
33    unsafe impl NSObjectProtocol for CPNowPlayingButton {}
34);
35
36extern_conformance!(
37    unsafe impl NSSecureCoding for CPNowPlayingButton {}
38);
39
40impl CPNowPlayingButton {
41    extern_methods!(
42        #[unsafe(method(new))]
43        #[unsafe(method_family = new)]
44        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
45
46        #[unsafe(method(init))]
47        #[unsafe(method_family = init)]
48        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
49
50        #[cfg(feature = "block2")]
51        /// Initialize a now playing button with a handler. The handler will be called when the user
52        /// selects this button.
53        ///
54        ///
55        /// Note: Your app should use this method in one of the six concrete subclasses of
56        /// `CPNowPlayingButton.`Do not initialize this class directly.
57        #[unsafe(method(initWithHandler:))]
58        #[unsafe(method_family = init)]
59        pub unsafe fn initWithHandler(
60            this: Allocated<Self>,
61            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPNowPlayingButton>)>>,
62        ) -> Retained<Self>;
63
64        /// A Boolean value indicating whether the button is enabled.
65        ///
66        ///
67        /// Set the value of this property to
68        /// `YES`to enable the button or
69        /// `NO`to disable it. The default value of this property is
70        /// `YES.`
71        #[unsafe(method(isEnabled))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn isEnabled(&self) -> bool;
74
75        /// Setter for [`isEnabled`][Self::isEnabled].
76        #[unsafe(method(setEnabled:))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn setEnabled(&self, enabled: bool);
79
80        /// A Boolean value indicating whether the button is selected. When selected, the button draws with a selected appearance to
81        /// indicate its selected state.
82        ///
83        ///
84        /// Only custom image buttons may display a custom selected state. Other system-provided buttons, like repeat
85        /// and shuffle, change their selected states depending on what your app reports for current repeat and shuffle states.
86        #[unsafe(method(isSelected))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn isSelected(&self) -> bool;
89
90        /// Setter for [`isSelected`][Self::isSelected].
91        #[unsafe(method(setSelected:))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn setSelected(&self, selected: bool);
94    );
95}
96
97extern_class!(
98    /// A now playing button that indicates the current shuffle mode for your app.
99    ///
100    /// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpnowplayingshufflebutton?language=objc)
101    #[unsafe(super(CPNowPlayingButton, NSObject))]
102    #[thread_kind = MainThreadOnly]
103    #[derive(Debug, PartialEq, Eq, Hash)]
104    pub struct CPNowPlayingShuffleButton;
105);
106
107extern_conformance!(
108    unsafe impl NSCoding for CPNowPlayingShuffleButton {}
109);
110
111extern_conformance!(
112    unsafe impl NSObjectProtocol for CPNowPlayingShuffleButton {}
113);
114
115extern_conformance!(
116    unsafe impl NSSecureCoding for CPNowPlayingShuffleButton {}
117);
118
119impl CPNowPlayingShuffleButton {
120    extern_methods!();
121}
122
123/// Methods declared on superclass `CPNowPlayingButton`.
124impl CPNowPlayingShuffleButton {
125    extern_methods!(
126        #[unsafe(method(new))]
127        #[unsafe(method_family = new)]
128        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
129
130        #[unsafe(method(init))]
131        #[unsafe(method_family = init)]
132        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
133
134        #[cfg(feature = "block2")]
135        /// Initialize a now playing button with a handler. The handler will be called when the user
136        /// selects this button.
137        ///
138        ///
139        /// Note: Your app should use this method in one of the six concrete subclasses of
140        /// `CPNowPlayingButton.`Do not initialize this class directly.
141        #[unsafe(method(initWithHandler:))]
142        #[unsafe(method_family = init)]
143        pub unsafe fn initWithHandler(
144            this: Allocated<Self>,
145            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPNowPlayingButton>)>>,
146        ) -> Retained<Self>;
147    );
148}
149
150extern_class!(
151    /// A now playing button that can be used to allow the user to add the current
152    /// playing item to a collection, like their library.
153    ///
154    /// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpnowplayingaddtolibrarybutton?language=objc)
155    #[unsafe(super(CPNowPlayingButton, NSObject))]
156    #[thread_kind = MainThreadOnly]
157    #[derive(Debug, PartialEq, Eq, Hash)]
158    pub struct CPNowPlayingAddToLibraryButton;
159);
160
161extern_conformance!(
162    unsafe impl NSCoding for CPNowPlayingAddToLibraryButton {}
163);
164
165extern_conformance!(
166    unsafe impl NSObjectProtocol for CPNowPlayingAddToLibraryButton {}
167);
168
169extern_conformance!(
170    unsafe impl NSSecureCoding for CPNowPlayingAddToLibraryButton {}
171);
172
173impl CPNowPlayingAddToLibraryButton {
174    extern_methods!();
175}
176
177/// Methods declared on superclass `CPNowPlayingButton`.
178impl CPNowPlayingAddToLibraryButton {
179    extern_methods!(
180        #[unsafe(method(new))]
181        #[unsafe(method_family = new)]
182        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
183
184        #[unsafe(method(init))]
185        #[unsafe(method_family = init)]
186        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
187
188        #[cfg(feature = "block2")]
189        /// Initialize a now playing button with a handler. The handler will be called when the user
190        /// selects this button.
191        ///
192        ///
193        /// Note: Your app should use this method in one of the six concrete subclasses of
194        /// `CPNowPlayingButton.`Do not initialize this class directly.
195        #[unsafe(method(initWithHandler:))]
196        #[unsafe(method_family = init)]
197        pub unsafe fn initWithHandler(
198            this: Allocated<Self>,
199            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPNowPlayingButton>)>>,
200        ) -> Retained<Self>;
201    );
202}
203
204extern_class!(
205    /// A now playing button that shows a callout-style action. For example,
206    /// your app could present a
207    /// `CPActionSheetTemplate`to show more actions
208    /// when the user taps this button.
209    ///
210    /// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpnowplayingmorebutton?language=objc)
211    #[unsafe(super(CPNowPlayingButton, NSObject))]
212    #[thread_kind = MainThreadOnly]
213    #[derive(Debug, PartialEq, Eq, Hash)]
214    pub struct CPNowPlayingMoreButton;
215);
216
217extern_conformance!(
218    unsafe impl NSCoding for CPNowPlayingMoreButton {}
219);
220
221extern_conformance!(
222    unsafe impl NSObjectProtocol for CPNowPlayingMoreButton {}
223);
224
225extern_conformance!(
226    unsafe impl NSSecureCoding for CPNowPlayingMoreButton {}
227);
228
229impl CPNowPlayingMoreButton {
230    extern_methods!();
231}
232
233/// Methods declared on superclass `CPNowPlayingButton`.
234impl CPNowPlayingMoreButton {
235    extern_methods!(
236        #[unsafe(method(new))]
237        #[unsafe(method_family = new)]
238        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
239
240        #[unsafe(method(init))]
241        #[unsafe(method_family = init)]
242        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
243
244        #[cfg(feature = "block2")]
245        /// Initialize a now playing button with a handler. The handler will be called when the user
246        /// selects this button.
247        ///
248        ///
249        /// Note: Your app should use this method in one of the six concrete subclasses of
250        /// `CPNowPlayingButton.`Do not initialize this class directly.
251        #[unsafe(method(initWithHandler:))]
252        #[unsafe(method_family = init)]
253        pub unsafe fn initWithHandler(
254            this: Allocated<Self>,
255            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPNowPlayingButton>)>>,
256        ) -> Retained<Self>;
257    );
258}
259
260extern_class!(
261    /// A now playing button that shows the current playback rate and allows
262    /// the user to cycle between different playback rates provided by your app.
263    ///
264    /// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpnowplayingplaybackratebutton?language=objc)
265    #[unsafe(super(CPNowPlayingButton, NSObject))]
266    #[thread_kind = MainThreadOnly]
267    #[derive(Debug, PartialEq, Eq, Hash)]
268    pub struct CPNowPlayingPlaybackRateButton;
269);
270
271extern_conformance!(
272    unsafe impl NSCoding for CPNowPlayingPlaybackRateButton {}
273);
274
275extern_conformance!(
276    unsafe impl NSObjectProtocol for CPNowPlayingPlaybackRateButton {}
277);
278
279extern_conformance!(
280    unsafe impl NSSecureCoding for CPNowPlayingPlaybackRateButton {}
281);
282
283impl CPNowPlayingPlaybackRateButton {
284    extern_methods!();
285}
286
287/// Methods declared on superclass `CPNowPlayingButton`.
288impl CPNowPlayingPlaybackRateButton {
289    extern_methods!(
290        #[unsafe(method(new))]
291        #[unsafe(method_family = new)]
292        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
293
294        #[unsafe(method(init))]
295        #[unsafe(method_family = init)]
296        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
297
298        #[cfg(feature = "block2")]
299        /// Initialize a now playing button with a handler. The handler will be called when the user
300        /// selects this button.
301        ///
302        ///
303        /// Note: Your app should use this method in one of the six concrete subclasses of
304        /// `CPNowPlayingButton.`Do not initialize this class directly.
305        #[unsafe(method(initWithHandler:))]
306        #[unsafe(method_family = init)]
307        pub unsafe fn initWithHandler(
308            this: Allocated<Self>,
309            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPNowPlayingButton>)>>,
310        ) -> Retained<Self>;
311    );
312}
313
314extern_class!(
315    /// A now playing button that shows the current repeat state, like "once"
316    /// or "all".
317    ///
318    /// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpnowplayingrepeatbutton?language=objc)
319    #[unsafe(super(CPNowPlayingButton, NSObject))]
320    #[thread_kind = MainThreadOnly]
321    #[derive(Debug, PartialEq, Eq, Hash)]
322    pub struct CPNowPlayingRepeatButton;
323);
324
325extern_conformance!(
326    unsafe impl NSCoding for CPNowPlayingRepeatButton {}
327);
328
329extern_conformance!(
330    unsafe impl NSObjectProtocol for CPNowPlayingRepeatButton {}
331);
332
333extern_conformance!(
334    unsafe impl NSSecureCoding for CPNowPlayingRepeatButton {}
335);
336
337impl CPNowPlayingRepeatButton {
338    extern_methods!();
339}
340
341/// Methods declared on superclass `CPNowPlayingButton`.
342impl CPNowPlayingRepeatButton {
343    extern_methods!(
344        #[unsafe(method(new))]
345        #[unsafe(method_family = new)]
346        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
347
348        #[unsafe(method(init))]
349        #[unsafe(method_family = init)]
350        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
351
352        #[cfg(feature = "block2")]
353        /// Initialize a now playing button with a handler. The handler will be called when the user
354        /// selects this button.
355        ///
356        ///
357        /// Note: Your app should use this method in one of the six concrete subclasses of
358        /// `CPNowPlayingButton.`Do not initialize this class directly.
359        #[unsafe(method(initWithHandler:))]
360        #[unsafe(method_family = init)]
361        pub unsafe fn initWithHandler(
362            this: Allocated<Self>,
363            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPNowPlayingButton>)>>,
364        ) -> Retained<Self>;
365    );
366}
367
368extern_class!(
369    /// A now playing button that shows a custom image provided by your app
370    /// for any other custom actions on the now playing screen.
371    ///
372    /// See also [Apple's documentation](https://developer.apple.com/documentation/carplay/cpnowplayingimagebutton?language=objc)
373    #[unsafe(super(CPNowPlayingButton, NSObject))]
374    #[thread_kind = MainThreadOnly]
375    #[derive(Debug, PartialEq, Eq, Hash)]
376    pub struct CPNowPlayingImageButton;
377);
378
379extern_conformance!(
380    unsafe impl NSCoding for CPNowPlayingImageButton {}
381);
382
383extern_conformance!(
384    unsafe impl NSObjectProtocol for CPNowPlayingImageButton {}
385);
386
387extern_conformance!(
388    unsafe impl NSSecureCoding for CPNowPlayingImageButton {}
389);
390
391impl CPNowPlayingImageButton {
392    extern_methods!(
393        #[cfg(all(feature = "block2", feature = "objc2-ui-kit"))]
394        /// Initialize a button with a custom image.
395        ///
396        ///
397        /// Parameter `image`: A custom image for this button. The maximum image size is CPNowPlayingButtonMaximumImageSize; larger images will be scaled down.
398        ///
399        /// Parameter `handler`: A block to execute when the user selects the button. The block has no return value and takes the selected button as its only parameter.
400        ///
401        ///
402        /// Provided image should be dark variant and will be recolored.
403        #[unsafe(method(initWithImage:handler:))]
404        #[unsafe(method_family = init)]
405        pub unsafe fn initWithImage_handler(
406            this: Allocated<Self>,
407            image: &UIImage,
408            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPNowPlayingButton>)>>,
409        ) -> Retained<Self>;
410
411        #[cfg(feature = "objc2-ui-kit")]
412        /// The custom image, if any, displayed on the button.
413        ///
414        ///
415        /// Animated images are not supported. If an animated image is assigned, only the first image will be used. If an empty or zero-size image is provided, a system placeholder glyph will be displayed instead.
416        #[unsafe(method(image))]
417        #[unsafe(method_family = none)]
418        pub unsafe fn image(&self) -> Option<Retained<UIImage>>;
419    );
420}
421
422/// Methods declared on superclass `CPNowPlayingButton`.
423impl CPNowPlayingImageButton {
424    extern_methods!(
425        #[unsafe(method(new))]
426        #[unsafe(method_family = new)]
427        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
428
429        #[unsafe(method(init))]
430        #[unsafe(method_family = init)]
431        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
432
433        #[cfg(feature = "block2")]
434        /// Initialize a now playing button with a handler. The handler will be called when the user
435        /// selects this button.
436        ///
437        ///
438        /// Note: Your app should use this method in one of the six concrete subclasses of
439        /// `CPNowPlayingButton.`Do not initialize this class directly.
440        #[unsafe(method(initWithHandler:))]
441        #[unsafe(method_family = init)]
442        pub unsafe fn initWithHandler(
443            this: Allocated<Self>,
444            handler: Option<&block2::DynBlock<dyn Fn(NonNull<CPNowPlayingButton>)>>,
445        ) -> Retained<Self>;
446    );
447}