objc2-screen-saver 0.3.2

Bindings to the ScreenSaver framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
use objc2_app_kit::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// An abstract class that defines the interface for subclassers to interact
    /// with the screen saver infrastructure.
    ///
    /// ``ScreenSaverView`` provides the interface for your screen saver, including
    /// the content you animate onscreen and an optional configuration sheet. Create
    /// your own custom subclass and add it to your screen saver bundle. Use your
    /// subclass to create the animations that you want to appear onscreen, and to
    /// specify additional animation details.
    ///
    /// - Note: When someone previews your screen saver in System Preferences, the
    /// system instantiates your ``ScreenSaverView`` subclass.
    ///
    /// You can draw from your view’s ``ScreenSaverView/drawRect:`` method, or you
    /// can draw directly from the ``ScreenSaverView/animateOneFrame`` method. If
    /// you prefer to use the ``ScreenSaverView/drawRect:`` method, use the
    /// ``ScreenSaverView/animateOneFrame`` method to call the
    /// <doc
    /// ://com.apple.documentation/documentation/appkit/nsview/1483475-setneedsdisplayinrect>
    /// method and specify the portions of your view that require updates.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/screensaver/screensaverview?language=objc)
    #[unsafe(super(NSView, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2-app-kit")]
    pub struct ScreenSaverView;
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSAccessibility for ScreenSaverView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSAccessibilityElementProtocol for ScreenSaverView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSAnimatablePropertyContainer for ScreenSaverView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSAppearanceCustomization for ScreenSaverView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSCoding for ScreenSaverView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSDraggingDestination for ScreenSaverView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSObjectProtocol for ScreenSaverView {}
);

#[cfg(feature = "objc2-app-kit")]
extern_conformance!(
    unsafe impl NSUserInterfaceItemIdentification for ScreenSaverView {}
);

#[cfg(feature = "objc2-app-kit")]
impl ScreenSaverView {
    extern_methods!(
        /// Returns the type of backing store you want for your screen saver’s window.
        ///
        /// ## Overview
        ///
        /// This method returns
        /// <doc
        /// ://com.apple.documentation/documentation/appkit/nsbackingstoretype/nsbackingstorebuffered>
        /// by default. If you want to change the backing store type, override this method and
        /// return a new value. If you override the method, you don’t need to call the inherited
        /// version.
        #[unsafe(method(backingStoreType))]
        #[unsafe(method_family = none)]
        pub unsafe fn backingStoreType(mtm: MainThreadMarker) -> NSBackingStoreType;

        /// Indicates whether to perform a gradual screen fade when the system starts and stops
        /// your screen saver’s animation.
        ///
        /// ## Overview
        ///
        /// This class method allows the screen saver view to select how the desktop visibly
        /// transitions to the screen saver view. When this method returns
        /// <doc
        /// ://com.apple.documentation/documentation/objectivec/yes>,
        /// the screen gradually darkens before the animation begins. When it returns
        /// <doc
        /// ://com.apple.documentation/documentation/objectivec/no>,
        /// the screen transitions immediately to the screen saver. The latter behavior is more
        /// appropriate if the screen saver animates a screenshot of the desktop, as is the case
        /// for optical lens effects. The default is
        /// <doc
        /// ://com.apple.documentation/documentation/objectivec/yes>.
        #[unsafe(method(performGammaFade))]
        #[unsafe(method_family = none)]
        pub unsafe fn performGammaFade(mtm: MainThreadMarker) -> bool;

        /// Creates a newly allocated screen saver view with the specified frame rectangle and
        /// preview information.
        ///
        /// ## Overview
        ///
        /// The screen saver application installs the new view object into the view hierarchy
        /// of an
        /// <doc
        /// ://com.apple.documentation/documentation/appkit/nswindow> before the animation
        /// begins. This method is the designated initializer for the ``ScreenSaver/ScreenSaverView``
        /// class. Returns `self`.
        ///
        /// - Parameters:
        /// - frame: The frame rectangle for the view.
        ///
        /// - isPreview:
        /// <doc
        /// ://com.apple.documentation/documentation/objectivec/yes> if this view provides a
        /// preview for system settings, or
        /// <doc
        /// ://com.apple.documentation/documentation/objectivec/no>
        /// if the system fills the screen with your view’s contents.
        #[unsafe(method(initWithFrame:isPreview:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrame_isPreview(
            this: Allocated<Self>,
            frame: NSRect,
            is_preview: bool,
        ) -> Option<Retained<Self>>;

        /// The time interval between animation frames.
        ///
        /// If your screen saver has particular requirements for time between animation
        /// frames, call this method to set the animation rate to a reasonable value.
        #[unsafe(method(animationTimeInterval))]
        #[unsafe(method_family = none)]
        pub unsafe fn animationTimeInterval(&self) -> NSTimeInterval;

        /// Setter for [`animationTimeInterval`][Self::animationTimeInterval].
        #[unsafe(method(setAnimationTimeInterval:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAnimationTimeInterval(&self, animation_time_interval: NSTimeInterval);

        /// Activates the periodic timer that animates the screen saver.
        ///
        /// ## Overview
        ///
        /// The system calls this method when it’s time for you to start animating your screen
        /// saver’s content. The system calls this method only once at the start of animations.
        /// Use this method to set up any initial state information you require or to allocate
        /// expensive resources. If you override this method, you must call the inherited implementation
        /// at some point.
        ///
        /// ## See also
        ///
        /// - ``ScreenSaver/ScreenSaverView/stopAnimation``
        #[unsafe(method(startAnimation))]
        #[unsafe(method_family = none)]
        pub unsafe fn startAnimation(&self);

        /// Deactivates the timer that advances the animation.
        ///
        /// ## Overview
        ///
        /// The system calls this method when it’s time for you to stop animating your screen
        /// saver’s content. The system calls this method only once at the end of animations.
        /// Use this method to unload expensive resources or to reset your screen saver to a
        /// known state. If you override this method, you must call the inherited implementation
        /// at some point.
        ///
        /// ## See also
        ///
        /// - ``ScreenSaver/ScreenSaverView/startAnimation``
        #[unsafe(method(stopAnimation))]
        #[unsafe(method_family = none)]
        pub unsafe fn stopAnimation(&self);

        /// A Boolean value that indicates whether the screen saver is animating.
        ///
        /// ## Overview
        ///
        /// The value of this property is
        /// <doc
        /// ://com.apple.documentation/documentation/objectivec/yes>
        /// when the screen saver is animating, and
        /// <doc
        /// ://com.apple.documentation/documentation/objectivec/no>
        /// when it isn’t.
        ///
        /// ## See also
        ///
        /// - ``ScreenSaver/ScreenSaverView/stopAnimation``
        /// - ``ScreenSaver/ScreenSaverView/startAnimation``
        #[unsafe(method(isAnimating))]
        #[unsafe(method_family = none)]
        pub unsafe fn isAnimating(&self) -> bool;

        /// Draws the screen saver view.
        ///
        /// ## Overview
        ///
        /// ``ScreenSaver/ScreenSaverView`` implements ``ScreenSaver/ScreenSaverView/drawRect:``
        /// to draw a black background. Subclasses can do their drawing here or in ``ScreenSaver/ScreenSaverView/animateOneFrame``.
        ///
        /// ## See also
        ///
        /// - ``ScreenSaver/ScreenSaverView/stopAnimation``
        /// - ``ScreenSaver/ScreenSaverView/animateOneFrame``
        /// - ``ScreenSaver/ScreenSaverView/startAnimation``
        #[unsafe(method(drawRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn drawRect(&self, rect: NSRect);

        /// Advances the screen saver’s animation by a single frame.
        ///
        /// ## Overview
        ///
        /// The system calls this method each time the timer animating the screen saver fires.
        /// The time between calls to this method is always at least ``ScreenSaver/ScreenSaverView/animationTimeInterval``.
        /// The system locks focus on your view before it calls this method, so you can use this
        /// method to draw content. You can also let ``ScreenSaver/ScreenSaverView/drawRect:``
        /// perform the drawing, in which case you use this method to call
        /// <doc
        /// ://com.apple.documentation/documentation/appkit/nsview/1483475-setneedsdisplayinrect>
        /// to mark your view as dirty. The default implementation of this method does nothing.
        ///
        /// ## See also
        ///
        /// - ``ScreenSaver/ScreenSaverView/drawRect:``
        #[unsafe(method(animateOneFrame))]
        #[unsafe(method_family = none)]
        pub unsafe fn animateOneFrame(&self);

        /// A Boolean value that indicates whether the screen saver has an associated configuration sheet.
        ///
        /// If you provide a configuration sheet in your bundle, override this method and return
        /// <doc
        /// ://com.apple.documentation/documentation/objectivec/yes>.
        ///
        /// ## See also
        ///
        /// - ``ScreenSaver/ScreenSaverView/configureSheet``
        #[unsafe(method(hasConfigureSheet))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasConfigureSheet(&self) -> bool;

        /// The window that contains the controls to configure the screen saver.
        ///
        /// The system runs this window as a sheet, so include buttons that allow the
        /// user to end the modal session in which the sheet runs. When the user
        /// dismisses the sheet, the controller in charge of the sheet must end the
        /// document modal session by calling the
        /// <doc
        /// ://com.apple.documentation/documentation/appkit/nsapplication> method
        /// <doc
        /// ://com.apple.documentation/documentation/appkit/nsapplication/1428503-endsheet>
        /// with the sheet’s window as the argument.
        ///
        /// ## See also
        ///
        /// - ``ScreenSaver/ScreenSaverView/hasConfigureSheet``
        #[unsafe(method(configureSheet))]
        #[unsafe(method_family = none)]
        pub unsafe fn configureSheet(&self) -> Option<Retained<NSWindow>>;

        /// A Boolean value that indicates whether the screen saver view is set to a size suitable
        /// for previewing its content.
        ///
        /// ## Overview
        ///
        /// The system sets the value of this property to
        /// <doc
        /// ://com.apple.documentation/documentation/objectivec/yes>
        /// when it creates a smaller preview of your screen saver. When the value is
        /// <doc
        /// ://com.apple.documentation/documentation/objectivec/no>,
        /// your view matches the size of the screen. Use this property to adjust the content
        /// you present. For example, you might change the drawing parameters or data you display
        /// in your view.
        #[unsafe(method(isPreview))]
        #[unsafe(method_family = none)]
        pub unsafe fn isPreview(&self) -> bool;
    );
}

/// Methods declared on superclass `NSView`.
#[cfg(feature = "objc2-app-kit")]
impl ScreenSaverView {
    extern_methods!(
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;
    );
}

/// Methods declared on superclass `NSResponder`.
#[cfg(feature = "objc2-app-kit")]
impl ScreenSaverView {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "objc2-app-kit")]
impl ScreenSaverView {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

// TODO: pub fn SSRandomIntBetween(a: c_int,b: c_int,) -> c_int;

// TODO: pub fn SSRandomFloatBetween(a: CGFloat,b: CGFloat,) -> CGFloat;

// TODO: pub fn SSRandomPointForSizeWithinRect(size: NSSize,rect: NSRect,) -> NSPoint;

// TODO: pub fn SSCenteredRectInRect(inner_rect: NSRect,outer_rect: NSRect,) -> NSRect;