objc2-core-graphics 0.3.2

Bindings to the CoreGraphics framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgshading?language=objc)
#[doc(alias = "CGShadingRef")]
#[repr(C)]
pub struct CGShading {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

cf_type!(
    unsafe impl CGShading {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
    unsafe impl RefEncode<"CGShading"> for CGShading {}
);

unsafe impl ConcreteType for CGShading {
    #[doc(alias = "CGShadingGetTypeID")]
    #[inline]
    fn type_id() -> CFTypeID {
        extern "C-unwind" {
            fn CGShadingGetTypeID() -> CFTypeID;
        }
        unsafe { CGShadingGetTypeID() }
    }
}

impl CGShading {
    #[doc(alias = "CGShadingCreateAxial")]
    #[cfg(all(feature = "CGColorSpace", feature = "CGFunction"))]
    #[inline]
    pub fn new_axial(
        space: Option<&CGColorSpace>,
        start: CGPoint,
        end: CGPoint,
        function: Option<&CGFunction>,
        extend_start: bool,
        extend_end: bool,
    ) -> Option<CFRetained<CGShading>> {
        extern "C-unwind" {
            fn CGShadingCreateAxial(
                space: Option<&CGColorSpace>,
                start: CGPoint,
                end: CGPoint,
                function: Option<&CGFunction>,
                extend_start: bool,
                extend_end: bool,
            ) -> Option<NonNull<CGShading>>;
        }
        let ret =
            unsafe { CGShadingCreateAxial(space, start, end, function, extend_start, extend_end) };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    #[doc(alias = "CGShadingCreateAxialWithContentHeadroom")]
    #[cfg(all(feature = "CGColorSpace", feature = "CGFunction"))]
    #[inline]
    pub fn new_axial_with_content_headroom(
        headroom: c_float,
        space: Option<&CGColorSpace>,
        start: CGPoint,
        end: CGPoint,
        function: Option<&CGFunction>,
        extend_start: bool,
        extend_end: bool,
    ) -> Option<CFRetained<CGShading>> {
        extern "C-unwind" {
            fn CGShadingCreateAxialWithContentHeadroom(
                headroom: c_float,
                space: Option<&CGColorSpace>,
                start: CGPoint,
                end: CGPoint,
                function: Option<&CGFunction>,
                extend_start: bool,
                extend_end: bool,
            ) -> Option<NonNull<CGShading>>;
        }
        let ret = unsafe {
            CGShadingCreateAxialWithContentHeadroom(
                headroom,
                space,
                start,
                end,
                function,
                extend_start,
                extend_end,
            )
        };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    #[doc(alias = "CGShadingCreateRadial")]
    #[cfg(all(feature = "CGColorSpace", feature = "CGFunction"))]
    #[inline]
    pub fn new_radial(
        space: Option<&CGColorSpace>,
        start: CGPoint,
        start_radius: CGFloat,
        end: CGPoint,
        end_radius: CGFloat,
        function: Option<&CGFunction>,
        extend_start: bool,
        extend_end: bool,
    ) -> Option<CFRetained<CGShading>> {
        extern "C-unwind" {
            fn CGShadingCreateRadial(
                space: Option<&CGColorSpace>,
                start: CGPoint,
                start_radius: CGFloat,
                end: CGPoint,
                end_radius: CGFloat,
                function: Option<&CGFunction>,
                extend_start: bool,
                extend_end: bool,
            ) -> Option<NonNull<CGShading>>;
        }
        let ret = unsafe {
            CGShadingCreateRadial(
                space,
                start,
                start_radius,
                end,
                end_radius,
                function,
                extend_start,
                extend_end,
            )
        };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    #[doc(alias = "CGShadingCreateRadialWithContentHeadroom")]
    #[cfg(all(feature = "CGColorSpace", feature = "CGFunction"))]
    #[inline]
    pub fn new_radial_with_content_headroom(
        headroom: c_float,
        space: Option<&CGColorSpace>,
        start: CGPoint,
        start_radius: CGFloat,
        end: CGPoint,
        end_radius: CGFloat,
        function: Option<&CGFunction>,
        extend_start: bool,
        extend_end: bool,
    ) -> Option<CFRetained<CGShading>> {
        extern "C-unwind" {
            fn CGShadingCreateRadialWithContentHeadroom(
                headroom: c_float,
                space: Option<&CGColorSpace>,
                start: CGPoint,
                start_radius: CGFloat,
                end: CGPoint,
                end_radius: CGFloat,
                function: Option<&CGFunction>,
                extend_start: bool,
                extend_end: bool,
            ) -> Option<NonNull<CGShading>>;
        }
        let ret = unsafe {
            CGShadingCreateRadialWithContentHeadroom(
                headroom,
                space,
                start,
                start_radius,
                end,
                end_radius,
                function,
                extend_start,
                extend_end,
            )
        };
        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
    }

    #[doc(alias = "CGShadingGetContentHeadroom")]
    #[inline]
    pub fn content_headroom(shading: Option<&CGShading>) -> c_float {
        extern "C-unwind" {
            fn CGShadingGetContentHeadroom(shading: Option<&CGShading>) -> c_float;
        }
        unsafe { CGShadingGetContentHeadroom(shading) }
    }
}

#[cfg(all(feature = "CGColorSpace", feature = "CGFunction"))]
#[deprecated = "renamed to `CGShading::new_axial`"]
#[inline]
pub extern "C-unwind" fn CGShadingCreateAxial(
    space: Option<&CGColorSpace>,
    start: CGPoint,
    end: CGPoint,
    function: Option<&CGFunction>,
    extend_start: bool,
    extend_end: bool,
) -> Option<CFRetained<CGShading>> {
    extern "C-unwind" {
        fn CGShadingCreateAxial(
            space: Option<&CGColorSpace>,
            start: CGPoint,
            end: CGPoint,
            function: Option<&CGFunction>,
            extend_start: bool,
            extend_end: bool,
        ) -> Option<NonNull<CGShading>>;
    }
    let ret =
        unsafe { CGShadingCreateAxial(space, start, end, function, extend_start, extend_end) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(all(feature = "CGColorSpace", feature = "CGFunction"))]
#[deprecated = "renamed to `CGShading::new_axial_with_content_headroom`"]
#[inline]
pub extern "C-unwind" fn CGShadingCreateAxialWithContentHeadroom(
    headroom: c_float,
    space: Option<&CGColorSpace>,
    start: CGPoint,
    end: CGPoint,
    function: Option<&CGFunction>,
    extend_start: bool,
    extend_end: bool,
) -> Option<CFRetained<CGShading>> {
    extern "C-unwind" {
        fn CGShadingCreateAxialWithContentHeadroom(
            headroom: c_float,
            space: Option<&CGColorSpace>,
            start: CGPoint,
            end: CGPoint,
            function: Option<&CGFunction>,
            extend_start: bool,
            extend_end: bool,
        ) -> Option<NonNull<CGShading>>;
    }
    let ret = unsafe {
        CGShadingCreateAxialWithContentHeadroom(
            headroom,
            space,
            start,
            end,
            function,
            extend_start,
            extend_end,
        )
    };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(all(feature = "CGColorSpace", feature = "CGFunction"))]
#[deprecated = "renamed to `CGShading::new_radial`"]
#[inline]
pub extern "C-unwind" fn CGShadingCreateRadial(
    space: Option<&CGColorSpace>,
    start: CGPoint,
    start_radius: CGFloat,
    end: CGPoint,
    end_radius: CGFloat,
    function: Option<&CGFunction>,
    extend_start: bool,
    extend_end: bool,
) -> Option<CFRetained<CGShading>> {
    extern "C-unwind" {
        fn CGShadingCreateRadial(
            space: Option<&CGColorSpace>,
            start: CGPoint,
            start_radius: CGFloat,
            end: CGPoint,
            end_radius: CGFloat,
            function: Option<&CGFunction>,
            extend_start: bool,
            extend_end: bool,
        ) -> Option<NonNull<CGShading>>;
    }
    let ret = unsafe {
        CGShadingCreateRadial(
            space,
            start,
            start_radius,
            end,
            end_radius,
            function,
            extend_start,
            extend_end,
        )
    };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[cfg(all(feature = "CGColorSpace", feature = "CGFunction"))]
#[deprecated = "renamed to `CGShading::new_radial_with_content_headroom`"]
#[inline]
pub extern "C-unwind" fn CGShadingCreateRadialWithContentHeadroom(
    headroom: c_float,
    space: Option<&CGColorSpace>,
    start: CGPoint,
    start_radius: CGFloat,
    end: CGPoint,
    end_radius: CGFloat,
    function: Option<&CGFunction>,
    extend_start: bool,
    extend_end: bool,
) -> Option<CFRetained<CGShading>> {
    extern "C-unwind" {
        fn CGShadingCreateRadialWithContentHeadroom(
            headroom: c_float,
            space: Option<&CGColorSpace>,
            start: CGPoint,
            start_radius: CGFloat,
            end: CGPoint,
            end_radius: CGFloat,
            function: Option<&CGFunction>,
            extend_start: bool,
            extend_end: bool,
        ) -> Option<NonNull<CGShading>>;
    }
    let ret = unsafe {
        CGShadingCreateRadialWithContentHeadroom(
            headroom,
            space,
            start,
            start_radius,
            end,
            end_radius,
            function,
            extend_start,
            extend_end,
        )
    };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

#[deprecated = "renamed to `CGShading::content_headroom`"]
#[inline]
pub extern "C-unwind" fn CGShadingGetContentHeadroom(shading: Option<&CGShading>) -> c_float {
    extern "C-unwind" {
        fn CGShadingGetContentHeadroom(shading: Option<&CGShading>) -> c_float;
    }
    unsafe { CGShadingGetContentHeadroom(shading) }
}