1use crate::{ffi, Buffer, RectangleAlignment};
7use glib::translate::*;
8
9glib::wrapper! {
10 pub struct Rectangle(BoxedInline<ffi::GeglRectangle>);
11
12 match fn {
13 copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gegl_rectangle_get_type(), ptr as *mut _) as *mut ffi::GeglRectangle,
14 free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gegl_rectangle_get_type(), ptr as *mut _),
15 type_ => || ffi::gegl_rectangle_get_type(),
16 }
17}
18
19impl Rectangle {
20 #[doc(alias = "gegl_rectangle_new")]
21 pub fn new(x: i32, y: i32, width: u32, height: u32) -> Rectangle {
22 unsafe { from_glib_full(ffi::gegl_rectangle_new(x, y, width, height)) }
23 }
24
25 #[doc(alias = "gegl_rectangle_align")]
26 pub fn align(
27 &mut self,
28 rectangle: &Rectangle,
29 tile: &Rectangle,
30 alignment: RectangleAlignment,
31 ) -> bool {
32 unsafe {
33 from_glib(ffi::gegl_rectangle_align(
34 self.to_glib_none_mut().0,
35 rectangle.to_glib_none().0,
36 tile.to_glib_none().0,
37 alignment.into_glib(),
38 ))
39 }
40 }
41
42 #[doc(alias = "gegl_rectangle_align_to_buffer")]
43 pub fn align_to_buffer(
44 &mut self,
45 rectangle: &Rectangle,
46 buffer: &Buffer,
47 alignment: RectangleAlignment,
48 ) -> bool {
49 unsafe {
50 from_glib(ffi::gegl_rectangle_align_to_buffer(
51 self.to_glib_none_mut().0,
52 rectangle.to_glib_none().0,
53 buffer.to_glib_none().0,
54 alignment.into_glib(),
55 ))
56 }
57 }
58
59 #[doc(alias = "gegl_rectangle_bounding_box")]
60 pub fn bounding_box(&mut self, source1: &Rectangle, source2: &Rectangle) {
61 unsafe {
62 ffi::gegl_rectangle_bounding_box(
63 self.to_glib_none_mut().0,
64 source1.to_glib_none().0,
65 source2.to_glib_none().0,
66 );
67 }
68 }
69
70 #[doc(alias = "gegl_rectangle_contains")]
71 pub fn contains(&self, child: &Rectangle) -> bool {
72 unsafe {
73 from_glib(ffi::gegl_rectangle_contains(
74 self.to_glib_none().0,
75 child.to_glib_none().0,
76 ))
77 }
78 }
79
80 #[doc(alias = "gegl_rectangle_dump")]
81 pub fn dump(&self) {
82 unsafe {
83 ffi::gegl_rectangle_dump(self.to_glib_none().0);
84 }
85 }
86
87 #[doc(alias = "gegl_rectangle_dup")]
88 #[must_use]
89 pub fn dup(&self) -> Option<Rectangle> {
90 unsafe { from_glib_full(ffi::gegl_rectangle_dup(self.to_glib_none().0)) }
91 }
92
93 #[doc(alias = "gegl_rectangle_equal")]
94 fn equal(&self, rectangle2: &Rectangle) -> bool {
95 unsafe {
96 from_glib(ffi::gegl_rectangle_equal(
97 self.to_glib_none().0,
98 rectangle2.to_glib_none().0,
99 ))
100 }
101 }
102
103 #[doc(alias = "gegl_rectangle_equal_coords")]
104 pub fn equal_coords(&self, x: i32, y: i32, width: i32, height: i32) -> bool {
105 unsafe {
106 from_glib(ffi::gegl_rectangle_equal_coords(
107 self.to_glib_none().0,
108 x,
109 y,
110 width,
111 height,
112 ))
113 }
114 }
115
116 #[doc(alias = "gegl_rectangle_intersect")]
117 pub fn intersect(&mut self, src1: &Rectangle, src2: &Rectangle) -> bool {
118 unsafe {
119 from_glib(ffi::gegl_rectangle_intersect(
120 self.to_glib_none_mut().0,
121 src1.to_glib_none().0,
122 src2.to_glib_none().0,
123 ))
124 }
125 }
126
127 #[doc(alias = "gegl_rectangle_is_empty")]
128 pub fn is_empty(&self) -> bool {
129 unsafe { from_glib(ffi::gegl_rectangle_is_empty(self.to_glib_none().0)) }
130 }
131
132 #[doc(alias = "gegl_rectangle_is_infinite_plane")]
133 pub fn is_infinite_plane(&self) -> bool {
134 unsafe { from_glib(ffi::gegl_rectangle_is_infinite_plane(self.to_glib_none().0)) }
135 }
136
137 #[doc(alias = "gegl_rectangle_set")]
138 pub fn set(&mut self, x: i32, y: i32, width: u32, height: u32) {
139 unsafe {
140 ffi::gegl_rectangle_set(self.to_glib_none_mut().0, x, y, width, height);
141 }
142 }
143
144 #[doc(alias = "gegl_rectangle_subtract")]
145 pub fn subtract(&mut self, minuend: &Rectangle, subtrahend: &Rectangle) -> i32 {
146 unsafe {
147 ffi::gegl_rectangle_subtract(
148 self.to_glib_none_mut().0,
149 minuend.to_glib_none().0,
150 subtrahend.to_glib_none().0,
151 )
152 }
153 }
154
155 #[doc(alias = "gegl_rectangle_subtract_bounding_box")]
156 pub fn subtract_bounding_box(&mut self, minuend: &Rectangle, subtrahend: &Rectangle) -> bool {
157 unsafe {
158 from_glib(ffi::gegl_rectangle_subtract_bounding_box(
159 self.to_glib_none_mut().0,
160 minuend.to_glib_none().0,
161 subtrahend.to_glib_none().0,
162 ))
163 }
164 }
165
166 #[doc(alias = "gegl_rectangle_xor")]
167 pub fn xor(&mut self, source1: &Rectangle, source2: &Rectangle) -> i32 {
168 unsafe {
169 ffi::gegl_rectangle_xor(
170 self.to_glib_none_mut().0,
171 source1.to_glib_none().0,
172 source2.to_glib_none().0,
173 )
174 }
175 }
176}
177
178impl PartialEq for Rectangle {
179 #[inline]
180 fn eq(&self, other: &Self) -> bool {
181 self.equal(other)
182 }
183}
184
185impl Eq for Rectangle {}