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