gdk4 0.9.4

Rust bindings of the GDK 4 library
Documentation
// 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

#[cfg(feature = "v4_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
use crate::ColorState;
use crate::{ffi, GLContext, MemoryFormat, Texture};
use glib::translate::*;
#[cfg(feature = "v4_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
use glib::{
    prelude::*,
    signal::{connect_raw, SignalHandlerId},
};
#[cfg(feature = "v4_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "GdkGLTextureBuilder")]
    pub struct GLTextureBuilder(Object<ffi::GdkGLTextureBuilder, ffi::GdkGLTextureBuilderClass>);

    match fn {
        type_ => || ffi::gdk_gl_texture_builder_get_type(),
    }
}

impl GLTextureBuilder {
    #[doc(alias = "gdk_gl_texture_builder_new")]
    pub fn new() -> GLTextureBuilder {
        assert_initialized_main_thread!();
        unsafe { from_glib_full(ffi::gdk_gl_texture_builder_new()) }
    }

    #[cfg(feature = "v4_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
    #[doc(alias = "gdk_gl_texture_builder_get_color_state")]
    #[doc(alias = "get_color_state")]
    #[doc(alias = "color-state")]
    pub fn color_state(&self) -> ColorState {
        unsafe {
            from_glib_full(ffi::gdk_gl_texture_builder_get_color_state(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gdk_gl_texture_builder_get_context")]
    #[doc(alias = "get_context")]
    pub fn context(&self) -> Option<GLContext> {
        unsafe {
            from_glib_none(ffi::gdk_gl_texture_builder_get_context(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gdk_gl_texture_builder_get_format")]
    #[doc(alias = "get_format")]
    pub fn format(&self) -> MemoryFormat {
        unsafe {
            from_glib(ffi::gdk_gl_texture_builder_get_format(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gdk_gl_texture_builder_get_has_mipmap")]
    #[doc(alias = "get_has_mipmap")]
    #[doc(alias = "has-mipmap")]
    pub fn has_mipmap(&self) -> bool {
        unsafe {
            from_glib(ffi::gdk_gl_texture_builder_get_has_mipmap(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gdk_gl_texture_builder_get_height")]
    #[doc(alias = "get_height")]
    pub fn height(&self) -> i32 {
        unsafe { ffi::gdk_gl_texture_builder_get_height(self.to_glib_none().0) }
    }

    #[doc(alias = "gdk_gl_texture_builder_get_id")]
    #[doc(alias = "get_id")]
    pub fn id(&self) -> u32 {
        unsafe { ffi::gdk_gl_texture_builder_get_id(self.to_glib_none().0) }
    }

    #[doc(alias = "gdk_gl_texture_builder_get_update_region")]
    #[doc(alias = "get_update_region")]
    #[doc(alias = "update-region")]
    pub fn update_region(&self) -> Option<cairo::Region> {
        unsafe {
            from_glib_none(ffi::gdk_gl_texture_builder_get_update_region(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gdk_gl_texture_builder_get_update_texture")]
    #[doc(alias = "get_update_texture")]
    #[doc(alias = "update-texture")]
    pub fn update_texture(&self) -> Option<Texture> {
        unsafe {
            from_glib_none(ffi::gdk_gl_texture_builder_get_update_texture(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gdk_gl_texture_builder_get_width")]
    #[doc(alias = "get_width")]
    pub fn width(&self) -> i32 {
        unsafe { ffi::gdk_gl_texture_builder_get_width(self.to_glib_none().0) }
    }

    #[cfg(feature = "v4_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
    #[doc(alias = "gdk_gl_texture_builder_set_color_state")]
    #[doc(alias = "color-state")]
    pub fn set_color_state(&self, color_state: &ColorState) {
        unsafe {
            ffi::gdk_gl_texture_builder_set_color_state(
                self.to_glib_none().0,
                color_state.to_glib_none().0,
            );
        }
    }

    #[cfg(feature = "v4_16")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
    #[doc(alias = "color-state")]
    pub fn connect_color_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_color_state_trampoline<
            F: Fn(&GLTextureBuilder) + Send + Sync + 'static,
        >(
            this: *mut ffi::GdkGLTextureBuilder,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(
                self.as_ptr() as *mut _,
                b"notify::color-state\0".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_color_state_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}

#[cfg(feature = "v4_12")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
impl Default for GLTextureBuilder {
    fn default() -> Self {
        Self::new()
    }
}

unsafe impl Send for GLTextureBuilder {}
unsafe impl Sync for GLTextureBuilder {}