// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::ffi;
use glib::translate::*;

glib::wrapper! {
    #[derive(Debug, PartialOrd, Ord, Hash)]
    pub struct ComponentTransfer(Boxed<ffi::GskComponentTransfer>);

    match fn {
        copy => |ptr| ffi::gsk_component_transfer_copy(ptr),
        free => |ptr| ffi::gsk_component_transfer_free(ptr),
        type_ => || ffi::gsk_component_transfer_get_type(),
    }
}

impl ComponentTransfer {
    #[doc(alias = "gsk_component_transfer_new_discrete")]
    pub fn new_discrete(values: &[f32]) -> ComponentTransfer {
        assert_initialized_main_thread!();
        let n = values.len() as _;
        unsafe {
            from_glib_full(ffi::gsk_component_transfer_new_discrete(
                n,
                values.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gsk_component_transfer_new_gamma")]
    pub fn new_gamma(amp: f32, exp: f32, ofs: f32) -> ComponentTransfer {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gsk_component_transfer_new_gamma(amp, exp, ofs)) }
    }

    #[doc(alias = "gsk_component_transfer_new_identity")]
    pub fn new_identity() -> ComponentTransfer {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gsk_component_transfer_new_identity()) }
    }

    #[doc(alias = "gsk_component_transfer_new_levels")]
    pub fn new_levels(n: f32) -> ComponentTransfer {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gsk_component_transfer_new_levels(n)) }
    }

    #[doc(alias = "gsk_component_transfer_new_linear")]
    pub fn new_linear(m: f32, b: f32) -> ComponentTransfer {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gsk_component_transfer_new_linear(m, b)) }
    }

    #[doc(alias = "gsk_component_transfer_new_table")]
    pub fn new_table(values: &[f32]) -> ComponentTransfer {
        assert_initialized_main_thread!();
        let n = values.len() as _;
        unsafe {
            from_glib_full(ffi::gsk_component_transfer_new_table(
                n,
                values.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gsk_component_transfer_equal")]
    fn equal(&self, other: &ComponentTransfer) -> bool {
        assert_initialized_main_thread!();
        unsafe {
            from_glib(ffi::gsk_component_transfer_equal(
                ToGlibPtr::<*const ffi::GskComponentTransfer>::to_glib_none(self).0
                    as glib::ffi::gconstpointer,
                ToGlibPtr::<*const ffi::GskComponentTransfer>::to_glib_none(other).0
                    as glib::ffi::gconstpointer,
            ))
        }
    }
}

impl PartialEq for ComponentTransfer {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.equal(other)
    }
}

impl Eq for ComponentTransfer {}
