// 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::{LayoutChild, ffi};
use glib::{
    prelude::*,
    signal::{SignalHandlerId, connect_raw},
    translate::*,
};
use std::boxed::Box as Box_;

glib::wrapper! {
    #[doc(alias = "GtkOverlayLayoutChild")]
    pub struct OverlayLayoutChild(Object<ffi::GtkOverlayLayoutChild, ffi::GtkOverlayLayoutChildClass>) @extends LayoutChild;

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

impl OverlayLayoutChild {
    #[doc(alias = "gtk_overlay_layout_child_get_clip_overlay")]
    #[doc(alias = "get_clip_overlay")]
    #[doc(alias = "clip-overlay")]
    pub fn is_clip_overlay(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_overlay_layout_child_get_clip_overlay(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_overlay_layout_child_get_measure")]
    #[doc(alias = "get_measure")]
    #[doc(alias = "measure")]
    pub fn is_measure(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_overlay_layout_child_get_measure(
                self.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gtk_overlay_layout_child_set_clip_overlay")]
    #[doc(alias = "clip-overlay")]
    pub fn set_clip_overlay(&self, clip_overlay: bool) {
        unsafe {
            ffi::gtk_overlay_layout_child_set_clip_overlay(
                self.to_glib_none().0,
                clip_overlay.into_glib(),
            );
        }
    }

    #[doc(alias = "gtk_overlay_layout_child_set_measure")]
    #[doc(alias = "measure")]
    pub fn set_measure(&self, measure: bool) {
        unsafe {
            ffi::gtk_overlay_layout_child_set_measure(self.to_glib_none().0, measure.into_glib());
        }
    }

    #[doc(alias = "clip-overlay")]
    pub fn connect_clip_overlay_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_clip_overlay_trampoline<
            F: Fn(&OverlayLayoutChild) + 'static,
        >(
            this: *mut ffi::GtkOverlayLayoutChild,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                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 _,
                c"notify::clip-overlay".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_clip_overlay_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }

    #[doc(alias = "measure")]
    pub fn connect_measure_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_measure_trampoline<F: Fn(&OverlayLayoutChild) + 'static>(
            this: *mut ffi::GtkOverlayLayoutChild,
            _param_spec: glib::ffi::gpointer,
            f: glib::ffi::gpointer,
        ) {
            unsafe {
                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 _,
                c"notify::measure".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
                    notify_measure_trampoline::<F> as *const (),
                )),
                Box_::into_raw(f),
            )
        }
    }
}
