1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// 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, Rect};
use glib::translate::*;

glib::wrapper! {
    /// A 4 vertex quadrilateral, as represented by four [`Point`][crate::Point].
    ///
    /// The contents of a [`Quad`][crate::Quad] are private and should never be
    /// accessed directly.
    pub struct Quad(BoxedInline<ffi::graphene_quad_t>);

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

impl Quad {
    /// Computes the bounding rectangle of `self` and places it into `r`.
    ///
    /// # Returns
    ///
    ///
    /// ## `r`
    /// return location for a [`Rect`][crate::Rect]
    #[doc(alias = "graphene_quad_bounds")]
    pub fn bounds(&self) -> Rect {
        unsafe {
            let mut r = Rect::uninitialized();
            ffi::graphene_quad_bounds(self.to_glib_none().0, r.to_glib_none_mut().0);
            r
        }
    }

    /// Checks if the given [`Quad`][crate::Quad] contains the given [`Point`][crate::Point].
    /// ## `p`
    /// a [`Point`][crate::Point]
    ///
    /// # Returns
    ///
    /// `true` if the point is inside the [`Quad`][crate::Quad]
    #[doc(alias = "graphene_quad_contains")]
    pub fn contains(&self, p: &Point) -> bool {
        unsafe { ffi::graphene_quad_contains(self.to_glib_none().0, p.to_glib_none().0) }
    }
}