graphene/auto/
rect.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, Point};
6use glib::translate::*;
7
8glib::wrapper! {
9    pub struct Rect(BoxedInline<ffi::graphene_rect_t>);
10
11    match fn {
12        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_rect_get_type(), ptr as *mut _) as *mut ffi::graphene_rect_t,
13        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_rect_get_type(), ptr as *mut _),
14        type_ => || ffi::graphene_rect_get_type(),
15    }
16}
17
18impl Rect {
19    #[doc(alias = "graphene_rect_contains_point")]
20    pub fn contains_point(&self, p: &Point) -> bool {
21        unsafe { ffi::graphene_rect_contains_point(self.to_glib_none().0, p.to_glib_none().0) }
22    }
23
24    #[doc(alias = "graphene_rect_contains_rect")]
25    pub fn contains_rect(&self, b: &Rect) -> bool {
26        unsafe { ffi::graphene_rect_contains_rect(self.to_glib_none().0, b.to_glib_none().0) }
27    }
28
29    #[doc(alias = "graphene_rect_equal")]
30    fn equal(&self, b: &Rect) -> bool {
31        unsafe { ffi::graphene_rect_equal(self.to_glib_none().0, b.to_glib_none().0) }
32    }
33
34    #[doc(alias = "graphene_rect_expand")]
35    #[must_use]
36    pub fn expand(&self, p: &Point) -> Rect {
37        unsafe {
38            let mut res = Rect::uninitialized();
39            ffi::graphene_rect_expand(
40                self.to_glib_none().0,
41                p.to_glib_none().0,
42                res.to_glib_none_mut().0,
43            );
44            res
45        }
46    }
47
48    #[doc(alias = "graphene_rect_get_area")]
49    #[doc(alias = "get_area")]
50    pub fn area(&self) -> f32 {
51        unsafe { ffi::graphene_rect_get_area(self.to_glib_none().0) }
52    }
53
54    #[doc(alias = "graphene_rect_get_bottom_left")]
55    #[doc(alias = "get_bottom_left")]
56    pub fn bottom_left(&self) -> Point {
57        unsafe {
58            let mut p = Point::uninitialized();
59            ffi::graphene_rect_get_bottom_left(self.to_glib_none().0, p.to_glib_none_mut().0);
60            p
61        }
62    }
63
64    #[doc(alias = "graphene_rect_get_bottom_right")]
65    #[doc(alias = "get_bottom_right")]
66    pub fn bottom_right(&self) -> Point {
67        unsafe {
68            let mut p = Point::uninitialized();
69            ffi::graphene_rect_get_bottom_right(self.to_glib_none().0, p.to_glib_none_mut().0);
70            p
71        }
72    }
73
74    #[doc(alias = "graphene_rect_get_center")]
75    #[doc(alias = "get_center")]
76    pub fn center(&self) -> Point {
77        unsafe {
78            let mut p = Point::uninitialized();
79            ffi::graphene_rect_get_center(self.to_glib_none().0, p.to_glib_none_mut().0);
80            p
81        }
82    }
83
84    #[doc(alias = "graphene_rect_get_height")]
85    #[doc(alias = "get_height")]
86    pub fn height(&self) -> f32 {
87        unsafe { ffi::graphene_rect_get_height(self.to_glib_none().0) }
88    }
89
90    #[doc(alias = "graphene_rect_get_top_left")]
91    #[doc(alias = "get_top_left")]
92    pub fn top_left(&self) -> Point {
93        unsafe {
94            let mut p = Point::uninitialized();
95            ffi::graphene_rect_get_top_left(self.to_glib_none().0, p.to_glib_none_mut().0);
96            p
97        }
98    }
99
100    #[doc(alias = "graphene_rect_get_top_right")]
101    #[doc(alias = "get_top_right")]
102    pub fn top_right(&self) -> Point {
103        unsafe {
104            let mut p = Point::uninitialized();
105            ffi::graphene_rect_get_top_right(self.to_glib_none().0, p.to_glib_none_mut().0);
106            p
107        }
108    }
109
110    #[doc(alias = "graphene_rect_get_width")]
111    #[doc(alias = "get_width")]
112    pub fn width(&self) -> f32 {
113        unsafe { ffi::graphene_rect_get_width(self.to_glib_none().0) }
114    }
115
116    #[doc(alias = "graphene_rect_get_x")]
117    #[doc(alias = "get_x")]
118    pub fn x(&self) -> f32 {
119        unsafe { ffi::graphene_rect_get_x(self.to_glib_none().0) }
120    }
121
122    #[doc(alias = "graphene_rect_get_y")]
123    #[doc(alias = "get_y")]
124    pub fn y(&self) -> f32 {
125        unsafe { ffi::graphene_rect_get_y(self.to_glib_none().0) }
126    }
127
128    #[doc(alias = "graphene_rect_inset")]
129    pub fn inset(&mut self, d_x: f32, d_y: f32) {
130        unsafe {
131            ffi::graphene_rect_inset(self.to_glib_none_mut().0, d_x, d_y);
132        }
133    }
134
135    #[doc(alias = "graphene_rect_inset_r")]
136    #[must_use]
137    pub fn inset_r(&self, d_x: f32, d_y: f32) -> Rect {
138        unsafe {
139            let mut res = Rect::uninitialized();
140            ffi::graphene_rect_inset_r(self.to_glib_none().0, d_x, d_y, res.to_glib_none_mut().0);
141            res
142        }
143    }
144
145    #[doc(alias = "graphene_rect_interpolate")]
146    #[must_use]
147    pub fn interpolate(&self, b: &Rect, factor: f64) -> Rect {
148        unsafe {
149            let mut res = Rect::uninitialized();
150            ffi::graphene_rect_interpolate(
151                self.to_glib_none().0,
152                b.to_glib_none().0,
153                factor,
154                res.to_glib_none_mut().0,
155            );
156            res
157        }
158    }
159
160    #[doc(alias = "graphene_rect_intersection")]
161    pub fn intersection(&self, b: &Rect) -> Option<Rect> {
162        unsafe {
163            let mut res = Rect::uninitialized();
164            let ret = ffi::graphene_rect_intersection(
165                self.to_glib_none().0,
166                b.to_glib_none().0,
167                res.to_glib_none_mut().0,
168            );
169            if ret {
170                Some(res)
171            } else {
172                None
173            }
174        }
175    }
176
177    #[doc(alias = "graphene_rect_normalize")]
178    pub fn normalize(&mut self) {
179        unsafe {
180            ffi::graphene_rect_normalize(self.to_glib_none_mut().0);
181        }
182    }
183
184    #[doc(alias = "graphene_rect_normalize_r")]
185    #[must_use]
186    pub fn normalize_r(&self) -> Rect {
187        unsafe {
188            let mut res = Rect::uninitialized();
189            ffi::graphene_rect_normalize_r(self.to_glib_none().0, res.to_glib_none_mut().0);
190            res
191        }
192    }
193
194    #[doc(alias = "graphene_rect_offset")]
195    pub fn offset(&mut self, d_x: f32, d_y: f32) {
196        unsafe {
197            ffi::graphene_rect_offset(self.to_glib_none_mut().0, d_x, d_y);
198        }
199    }
200
201    #[doc(alias = "graphene_rect_offset_r")]
202    #[must_use]
203    pub fn offset_r(&self, d_x: f32, d_y: f32) -> Rect {
204        unsafe {
205            let mut res = Rect::uninitialized();
206            ffi::graphene_rect_offset_r(self.to_glib_none().0, d_x, d_y, res.to_glib_none_mut().0);
207            res
208        }
209    }
210
211    #[doc(alias = "graphene_rect_round_extents")]
212    #[must_use]
213    pub fn round_extents(&self) -> Rect {
214        unsafe {
215            let mut res = Rect::uninitialized();
216            ffi::graphene_rect_round_extents(self.to_glib_none().0, res.to_glib_none_mut().0);
217            res
218        }
219    }
220
221    #[doc(alias = "graphene_rect_scale")]
222    #[must_use]
223    pub fn scale(&self, s_h: f32, s_v: f32) -> Rect {
224        unsafe {
225            let mut res = Rect::uninitialized();
226            ffi::graphene_rect_scale(self.to_glib_none().0, s_h, s_v, res.to_glib_none_mut().0);
227            res
228        }
229    }
230
231    #[doc(alias = "graphene_rect_union")]
232    #[must_use]
233    pub fn union(&self, b: &Rect) -> Rect {
234        unsafe {
235            let mut res = Rect::uninitialized();
236            ffi::graphene_rect_union(
237                self.to_glib_none().0,
238                b.to_glib_none().0,
239                res.to_glib_none_mut().0,
240            );
241            res
242        }
243    }
244
245    #[doc(alias = "graphene_rect_zero")]
246    pub fn zero() -> Rect {
247        assert_initialized_main_thread!();
248        unsafe { from_glib_none(ffi::graphene_rect_zero()) }
249    }
250}
251
252impl PartialEq for Rect {
253    #[inline]
254    fn eq(&self, other: &Self) -> bool {
255        self.equal(other)
256    }
257}
258
259impl Eq for Rect {}