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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT

use glib::translate::*;

glib::wrapper! {
    pub struct Rectangle(BoxedInline<ffi::GdkRectangle>);

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

impl Rectangle {
    #[doc(alias = "gdk_rectangle_contains_point")]
    pub fn contains_point(&self, x: i32, y: i32) -> bool {
        unsafe {
            from_glib(ffi::gdk_rectangle_contains_point(
                self.to_glib_none().0,
                x,
                y,
            ))
        }
    }

    #[doc(alias = "gdk_rectangle_equal")]
    fn equal(&self, rect2: &Rectangle) -> bool {
        unsafe {
            from_glib(ffi::gdk_rectangle_equal(
                self.to_glib_none().0,
                rect2.to_glib_none().0,
            ))
        }
    }

    #[doc(alias = "gdk_rectangle_intersect")]
    pub fn intersect(&self, src2: &Rectangle) -> Option<Rectangle> {
        unsafe {
            let mut dest = Rectangle::uninitialized();
            let ret = from_glib(ffi::gdk_rectangle_intersect(
                self.to_glib_none().0,
                src2.to_glib_none().0,
                dest.to_glib_none_mut().0,
            ));
            if ret {
                Some(dest)
            } else {
                None
            }
        }
    }

    #[doc(alias = "gdk_rectangle_union")]
    #[must_use]
    pub fn union(&self, src2: &Rectangle) -> Rectangle {
        unsafe {
            let mut dest = Rectangle::uninitialized();
            ffi::gdk_rectangle_union(
                self.to_glib_none().0,
                src2.to_glib_none().0,
                dest.to_glib_none_mut().0,
            );
            dest
        }
    }
}

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

impl Eq for Rectangle {}