objc2_screen_saver/generated/
ScreenSaverView.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-app-kit")]
7use objc2_app_kit::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13    /// An abstract class that defines the interface for subclassers to interact
14    /// with the screen saver infrastructure.
15    ///
16    /// ``ScreenSaverView`` provides the interface for your screen saver, including
17    /// the content you animate onscreen and an optional configuration sheet. Create
18    /// your own custom subclass and add it to your screen saver bundle. Use your
19    /// subclass to create the animations that you want to appear onscreen, and to
20    /// specify additional animation details.
21    ///
22    /// - Note: When someone previews your screen saver in System Preferences, the
23    /// system instantiates your ``ScreenSaverView`` subclass.
24    ///
25    /// You can draw from your view’s ``ScreenSaverView/drawRect:`` method, or you
26    /// can draw directly from the ``ScreenSaverView/animateOneFrame`` method. If
27    /// you prefer to use the ``ScreenSaverView/drawRect:`` method, use the
28    /// ``ScreenSaverView/animateOneFrame`` method to call the
29    /// <doc
30    /// ://com.apple.documentation/documentation/appkit/nsview/1483475-setneedsdisplayinrect>
31    /// method and specify the portions of your view that require updates.
32    ///
33    /// See also [Apple's documentation](https://developer.apple.com/documentation/screensaver/screensaverview?language=objc)
34    #[unsafe(super(NSView, NSResponder, NSObject))]
35    #[derive(Debug, PartialEq, Eq, Hash)]
36    #[cfg(feature = "objc2-app-kit")]
37    pub struct ScreenSaverView;
38);
39
40#[cfg(feature = "objc2-app-kit")]
41extern_conformance!(
42    unsafe impl NSAccessibility for ScreenSaverView {}
43);
44
45#[cfg(feature = "objc2-app-kit")]
46extern_conformance!(
47    unsafe impl NSAccessibilityElementProtocol for ScreenSaverView {}
48);
49
50#[cfg(feature = "objc2-app-kit")]
51extern_conformance!(
52    unsafe impl NSAnimatablePropertyContainer for ScreenSaverView {}
53);
54
55#[cfg(feature = "objc2-app-kit")]
56extern_conformance!(
57    unsafe impl NSAppearanceCustomization for ScreenSaverView {}
58);
59
60#[cfg(feature = "objc2-app-kit")]
61extern_conformance!(
62    unsafe impl NSCoding for ScreenSaverView {}
63);
64
65#[cfg(feature = "objc2-app-kit")]
66extern_conformance!(
67    unsafe impl NSDraggingDestination for ScreenSaverView {}
68);
69
70#[cfg(feature = "objc2-app-kit")]
71extern_conformance!(
72    unsafe impl NSObjectProtocol for ScreenSaverView {}
73);
74
75#[cfg(feature = "objc2-app-kit")]
76extern_conformance!(
77    unsafe impl NSUserInterfaceItemIdentification for ScreenSaverView {}
78);
79
80#[cfg(feature = "objc2-app-kit")]
81impl ScreenSaverView {
82    extern_methods!(
83        /// Returns the type of backing store you want for your screen saver’s window.
84        ///
85        /// ## Overview
86        ///
87        /// This method returns
88        /// <doc
89        /// ://com.apple.documentation/documentation/appkit/nsbackingstoretype/nsbackingstorebuffered>
90        /// by default. If you want to change the backing store type, override this method and
91        /// return a new value. If you override the method, you don’t need to call the inherited
92        /// version.
93        #[unsafe(method(backingStoreType))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn backingStoreType(mtm: MainThreadMarker) -> NSBackingStoreType;
96
97        /// Indicates whether to perform a gradual screen fade when the system starts and stops
98        /// your screen saver’s animation.
99        ///
100        /// ## Overview
101        ///
102        /// This class method allows the screen saver view to select how the desktop visibly
103        /// transitions to the screen saver view. When this method returns
104        /// <doc
105        /// ://com.apple.documentation/documentation/objectivec/yes>,
106        /// the screen gradually darkens before the animation begins. When it returns
107        /// <doc
108        /// ://com.apple.documentation/documentation/objectivec/no>,
109        /// the screen transitions immediately to the screen saver. The latter behavior is more
110        /// appropriate if the screen saver animates a screenshot of the desktop, as is the case
111        /// for optical lens effects. The default is
112        /// <doc
113        /// ://com.apple.documentation/documentation/objectivec/yes>.
114        #[unsafe(method(performGammaFade))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn performGammaFade(mtm: MainThreadMarker) -> bool;
117
118        /// Creates a newly allocated screen saver view with the specified frame rectangle and
119        /// preview information.
120        ///
121        /// ## Overview
122        ///
123        /// The screen saver application installs the new view object into the view hierarchy
124        /// of an
125        /// <doc
126        /// ://com.apple.documentation/documentation/appkit/nswindow> before the animation
127        /// begins. This method is the designated initializer for the ``ScreenSaver/ScreenSaverView``
128        /// class. Returns `self`.
129        ///
130        /// - Parameters:
131        /// - frame: The frame rectangle for the view.
132        ///
133        /// - isPreview:
134        /// <doc
135        /// ://com.apple.documentation/documentation/objectivec/yes> if this view provides a
136        /// preview for system settings, or
137        /// <doc
138        /// ://com.apple.documentation/documentation/objectivec/no>
139        /// if the system fills the screen with your view’s contents.
140        #[unsafe(method(initWithFrame:isPreview:))]
141        #[unsafe(method_family = init)]
142        pub unsafe fn initWithFrame_isPreview(
143            this: Allocated<Self>,
144            frame: NSRect,
145            is_preview: bool,
146        ) -> Option<Retained<Self>>;
147
148        /// The time interval between animation frames.
149        ///
150        /// If your screen saver has particular requirements for time between animation
151        /// frames, call this method to set the animation rate to a reasonable value.
152        #[unsafe(method(animationTimeInterval))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn animationTimeInterval(&self) -> NSTimeInterval;
155
156        /// Setter for [`animationTimeInterval`][Self::animationTimeInterval].
157        #[unsafe(method(setAnimationTimeInterval:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setAnimationTimeInterval(&self, animation_time_interval: NSTimeInterval);
160
161        /// Activates the periodic timer that animates the screen saver.
162        ///
163        /// ## Overview
164        ///
165        /// The system calls this method when it’s time for you to start animating your screen
166        /// saver’s content. The system calls this method only once at the start of animations.
167        /// Use this method to set up any initial state information you require or to allocate
168        /// expensive resources. If you override this method, you must call the inherited implementation
169        /// at some point.
170        ///
171        /// ## See also
172        ///
173        /// - ``ScreenSaver/ScreenSaverView/stopAnimation``
174        #[unsafe(method(startAnimation))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn startAnimation(&self);
177
178        /// Deactivates the timer that advances the animation.
179        ///
180        /// ## Overview
181        ///
182        /// The system calls this method when it’s time for you to stop animating your screen
183        /// saver’s content. The system calls this method only once at the end of animations.
184        /// Use this method to unload expensive resources or to reset your screen saver to a
185        /// known state. If you override this method, you must call the inherited implementation
186        /// at some point.
187        ///
188        /// ## See also
189        ///
190        /// - ``ScreenSaver/ScreenSaverView/startAnimation``
191        #[unsafe(method(stopAnimation))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn stopAnimation(&self);
194
195        /// A Boolean value that indicates whether the screen saver is animating.
196        ///
197        /// ## Overview
198        ///
199        /// The value of this property is
200        /// <doc
201        /// ://com.apple.documentation/documentation/objectivec/yes>
202        /// when the screen saver is animating, and
203        /// <doc
204        /// ://com.apple.documentation/documentation/objectivec/no>
205        /// when it isn’t.
206        ///
207        /// ## See also
208        ///
209        /// - ``ScreenSaver/ScreenSaverView/stopAnimation``
210        /// - ``ScreenSaver/ScreenSaverView/startAnimation``
211        #[unsafe(method(isAnimating))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn isAnimating(&self) -> bool;
214
215        /// Draws the screen saver view.
216        ///
217        /// ## Overview
218        ///
219        /// ``ScreenSaver/ScreenSaverView`` implements ``ScreenSaver/ScreenSaverView/drawRect:``
220        /// to draw a black background. Subclasses can do their drawing here or in ``ScreenSaver/ScreenSaverView/animateOneFrame``.
221        ///
222        /// ## See also
223        ///
224        /// - ``ScreenSaver/ScreenSaverView/stopAnimation``
225        /// - ``ScreenSaver/ScreenSaverView/animateOneFrame``
226        /// - ``ScreenSaver/ScreenSaverView/startAnimation``
227        #[unsafe(method(drawRect:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn drawRect(&self, rect: NSRect);
230
231        /// Advances the screen saver’s animation by a single frame.
232        ///
233        /// ## Overview
234        ///
235        /// The system calls this method each time the timer animating the screen saver fires.
236        /// The time between calls to this method is always at least ``ScreenSaver/ScreenSaverView/animationTimeInterval``.
237        /// The system locks focus on your view before it calls this method, so you can use this
238        /// method to draw content. You can also let ``ScreenSaver/ScreenSaverView/drawRect:``
239        /// perform the drawing, in which case you use this method to call
240        /// <doc
241        /// ://com.apple.documentation/documentation/appkit/nsview/1483475-setneedsdisplayinrect>
242        /// to mark your view as dirty. The default implementation of this method does nothing.
243        ///
244        /// ## See also
245        ///
246        /// - ``ScreenSaver/ScreenSaverView/drawRect:``
247        #[unsafe(method(animateOneFrame))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn animateOneFrame(&self);
250
251        /// A Boolean value that indicates whether the screen saver has an associated configuration sheet.
252        ///
253        /// If you provide a configuration sheet in your bundle, override this method and return
254        /// <doc
255        /// ://com.apple.documentation/documentation/objectivec/yes>.
256        ///
257        /// ## See also
258        ///
259        /// - ``ScreenSaver/ScreenSaverView/configureSheet``
260        #[unsafe(method(hasConfigureSheet))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn hasConfigureSheet(&self) -> bool;
263
264        /// The window that contains the controls to configure the screen saver.
265        ///
266        /// The system runs this window as a sheet, so include buttons that allow the
267        /// user to end the modal session in which the sheet runs. When the user
268        /// dismisses the sheet, the controller in charge of the sheet must end the
269        /// document modal session by calling the
270        /// <doc
271        /// ://com.apple.documentation/documentation/appkit/nsapplication> method
272        /// <doc
273        /// ://com.apple.documentation/documentation/appkit/nsapplication/1428503-endsheet>
274        /// with the sheet’s window as the argument.
275        ///
276        /// ## See also
277        ///
278        /// - ``ScreenSaver/ScreenSaverView/hasConfigureSheet``
279        #[unsafe(method(configureSheet))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn configureSheet(&self) -> Option<Retained<NSWindow>>;
282
283        /// A Boolean value that indicates whether the screen saver view is set to a size suitable
284        /// for previewing its content.
285        ///
286        /// ## Overview
287        ///
288        /// The system sets the value of this property to
289        /// <doc
290        /// ://com.apple.documentation/documentation/objectivec/yes>
291        /// when it creates a smaller preview of your screen saver. When the value is
292        /// <doc
293        /// ://com.apple.documentation/documentation/objectivec/no>,
294        /// your view matches the size of the screen. Use this property to adjust the content
295        /// you present. For example, you might change the drawing parameters or data you display
296        /// in your view.
297        #[unsafe(method(isPreview))]
298        #[unsafe(method_family = none)]
299        pub unsafe fn isPreview(&self) -> bool;
300    );
301}
302
303/// Methods declared on superclass `NSView`.
304#[cfg(feature = "objc2-app-kit")]
305impl ScreenSaverView {
306    extern_methods!(
307        #[unsafe(method(initWithFrame:))]
308        #[unsafe(method_family = init)]
309        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
310
311        /// # Safety
312        ///
313        /// `coder` possibly has further requirements.
314        #[unsafe(method(initWithCoder:))]
315        #[unsafe(method_family = init)]
316        pub unsafe fn initWithCoder(
317            this: Allocated<Self>,
318            coder: &NSCoder,
319        ) -> Option<Retained<Self>>;
320    );
321}
322
323/// Methods declared on superclass `NSResponder`.
324#[cfg(feature = "objc2-app-kit")]
325impl ScreenSaverView {
326    extern_methods!(
327        #[unsafe(method(init))]
328        #[unsafe(method_family = init)]
329        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
330    );
331}
332
333/// Methods declared on superclass `NSObject`.
334#[cfg(feature = "objc2-app-kit")]
335impl ScreenSaverView {
336    extern_methods!(
337        #[unsafe(method(new))]
338        #[unsafe(method_family = new)]
339        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
340    );
341}
342
343// TODO: pub fn SSRandomIntBetween(a: c_int,b: c_int,) -> c_int;
344
345// TODO: pub fn SSRandomFloatBetween(a: CGFloat,b: CGFloat,) -> CGFloat;
346
347// TODO: pub fn SSRandomPointForSizeWithinRect(size: NSSize,rect: NSRect,) -> NSPoint;
348
349// TODO: pub fn SSCenteredRectInRect(inner_rect: NSRect,outer_rect: NSRect,) -> NSRect;