// 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::Point;
use glib::translate::*;

glib::wrapper! {
    pub struct Rect(BoxedInline<ffi::graphene_rect_t>);

    match fn {
        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_rect_get_type(), ptr as *mut _) as *mut ffi::graphene_rect_t,
        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_rect_get_type(), ptr as *mut _),
        type_ => || ffi::graphene_rect_get_type(),
    }
}

impl Rect {
    #[doc(alias = "graphene_rect_contains_point")]
    pub fn contains_point(&self, p: &Point) -> bool {
        unsafe { ffi::graphene_rect_contains_point(self.to_glib_none().0, p.to_glib_none().0) }
    }

    #[doc(alias = "graphene_rect_contains_rect")]
    pub fn contains_rect(&self, b: &Rect) -> bool {
        unsafe { ffi::graphene_rect_contains_rect(self.to_glib_none().0, b.to_glib_none().0) }
    }

    #[doc(alias = "graphene_rect_equal")]
    fn equal(&self, b: &Rect) -> bool {
        unsafe { ffi::graphene_rect_equal(self.to_glib_none().0, b.to_glib_none().0) }
    }

    #[doc(alias = "graphene_rect_expand")]
    #[must_use]
    pub fn expand(&self, p: &Point) -> Rect {
        unsafe {
            let mut res = Rect::uninitialized();
            ffi::graphene_rect_expand(
                self.to_glib_none().0,
                p.to_glib_none().0,
                res.to_glib_none_mut().0,
            );
            res
        }
    }

    #[doc(alias = "graphene_rect_get_area")]
    #[doc(alias = "get_area")]
    pub fn area(&self) -> f32 {
        unsafe { ffi::graphene_rect_get_area(self.to_glib_none().0) }
    }

    #[doc(alias = "graphene_rect_get_bottom_left")]
    #[doc(alias = "get_bottom_left")]
    pub fn bottom_left(&self) -> Point {
        unsafe {
            let mut p = Point::uninitialized();
            ffi::graphene_rect_get_bottom_left(self.to_glib_none().0, p.to_glib_none_mut().0);
            p
        }
    }

    #[doc(alias = "graphene_rect_get_bottom_right")]
    #[doc(alias = "get_bottom_right")]
    pub fn bottom_right(&self) -> Point {
        unsafe {
            let mut p = Point::uninitialized();
            ffi::graphene_rect_get_bottom_right(self.to_glib_none().0, p.to_glib_none_mut().0);
            p
        }
    }

    #[doc(alias = "graphene_rect_get_center")]
    #[doc(alias = "get_center")]
    pub fn center(&self) -> Point {
        unsafe {
            let mut p = Point::uninitialized();
            ffi::graphene_rect_get_center(self.to_glib_none().0, p.to_glib_none_mut().0);
            p
        }
    }

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

    #[doc(alias = "graphene_rect_get_top_left")]
    #[doc(alias = "get_top_left")]
    pub fn top_left(&self) -> Point {
        unsafe {
            let mut p = Point::uninitialized();
            ffi::graphene_rect_get_top_left(self.to_glib_none().0, p.to_glib_none_mut().0);
            p
        }
    }

    #[doc(alias = "graphene_rect_get_top_right")]
    #[doc(alias = "get_top_right")]
    pub fn top_right(&self) -> Point {
        unsafe {
            let mut p = Point::uninitialized();
            ffi::graphene_rect_get_top_right(self.to_glib_none().0, p.to_glib_none_mut().0);
            p
        }
    }

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

    #[doc(alias = "graphene_rect_get_x")]
    #[doc(alias = "get_x")]
    pub fn x(&self) -> f32 {
        unsafe { ffi::graphene_rect_get_x(self.to_glib_none().0) }
    }

    #[doc(alias = "graphene_rect_get_y")]
    #[doc(alias = "get_y")]
    pub fn y(&self) -> f32 {
        unsafe { ffi::graphene_rect_get_y(self.to_glib_none().0) }
    }

    #[doc(alias = "graphene_rect_inset")]
    pub fn inset(&mut self, d_x: f32, d_y: f32) {
        unsafe {
            ffi::graphene_rect_inset(self.to_glib_none_mut().0, d_x, d_y);
        }
    }

    #[doc(alias = "graphene_rect_inset_r")]
    #[must_use]
    pub fn inset_r(&self, d_x: f32, d_y: f32) -> Rect {
        unsafe {
            let mut res = Rect::uninitialized();
            ffi::graphene_rect_inset_r(self.to_glib_none().0, d_x, d_y, res.to_glib_none_mut().0);
            res
        }
    }

    #[doc(alias = "graphene_rect_interpolate")]
    #[must_use]
    pub fn interpolate(&self, b: &Rect, factor: f64) -> Rect {
        unsafe {
            let mut res = Rect::uninitialized();
            ffi::graphene_rect_interpolate(
                self.to_glib_none().0,
                b.to_glib_none().0,
                factor,
                res.to_glib_none_mut().0,
            );
            res
        }
    }

    #[doc(alias = "graphene_rect_intersection")]
    pub fn intersection(&self, b: &Rect) -> Option<Rect> {
        unsafe {
            let mut res = Rect::uninitialized();
            let ret = ffi::graphene_rect_intersection(
                self.to_glib_none().0,
                b.to_glib_none().0,
                res.to_glib_none_mut().0,
            );
            if ret {
                Some(res)
            } else {
                None
            }
        }
    }

    #[doc(alias = "graphene_rect_normalize")]
    pub fn normalize(&mut self) {
        unsafe {
            ffi::graphene_rect_normalize(self.to_glib_none_mut().0);
        }
    }

    #[doc(alias = "graphene_rect_normalize_r")]
    #[must_use]
    pub fn normalize_r(&self) -> Rect {
        unsafe {
            let mut res = Rect::uninitialized();
            ffi::graphene_rect_normalize_r(self.to_glib_none().0, res.to_glib_none_mut().0);
            res
        }
    }

    #[doc(alias = "graphene_rect_offset")]
    pub fn offset(&mut self, d_x: f32, d_y: f32) {
        unsafe {
            ffi::graphene_rect_offset(self.to_glib_none_mut().0, d_x, d_y);
        }
    }

    #[doc(alias = "graphene_rect_offset_r")]
    #[must_use]
    pub fn offset_r(&self, d_x: f32, d_y: f32) -> Rect {
        unsafe {
            let mut res = Rect::uninitialized();
            ffi::graphene_rect_offset_r(self.to_glib_none().0, d_x, d_y, res.to_glib_none_mut().0);
            res
        }
    }

    #[doc(alias = "graphene_rect_round_extents")]
    #[must_use]
    pub fn round_extents(&self) -> Rect {
        unsafe {
            let mut res = Rect::uninitialized();
            ffi::graphene_rect_round_extents(self.to_glib_none().0, res.to_glib_none_mut().0);
            res
        }
    }

    #[doc(alias = "graphene_rect_scale")]
    #[must_use]
    pub fn scale(&self, s_h: f32, s_v: f32) -> Rect {
        unsafe {
            let mut res = Rect::uninitialized();
            ffi::graphene_rect_scale(self.to_glib_none().0, s_h, s_v, res.to_glib_none_mut().0);
            res
        }
    }

    #[doc(alias = "graphene_rect_union")]
    #[must_use]
    pub fn union(&self, b: &Rect) -> Rect {
        unsafe {
            let mut res = Rect::uninitialized();
            ffi::graphene_rect_union(
                self.to_glib_none().0,
                b.to_glib_none().0,
                res.to_glib_none_mut().0,
            );
            res
        }
    }

    #[doc(alias = "graphene_rect_zero")]
    pub fn zero() -> Rect {
        assert_initialized_main_thread!();
        unsafe { from_glib_none(ffi::graphene_rect_zero()) }
    }
}

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

impl Eq for Rect {}
