1use crate::{ffi, Point3D, Sphere, Vec3};
6use glib::translate::*;
7
8glib::wrapper! {
9 pub struct Box(BoxedInline<ffi::graphene_box_t>);
10
11 match fn {
12 copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_box_get_type(), ptr as *mut _) as *mut ffi::graphene_box_t,
13 free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_box_get_type(), ptr as *mut _),
14 type_ => || ffi::graphene_box_get_type(),
15 }
16}
17
18impl Box {
19 #[doc(alias = "graphene_box_contains_box")]
20 pub fn contains_box(&self, b: &Box) -> bool {
21 unsafe { ffi::graphene_box_contains_box(self.to_glib_none().0, b.to_glib_none().0) }
22 }
23
24 #[doc(alias = "graphene_box_contains_point")]
25 pub fn contains_point(&self, point: &Point3D) -> bool {
26 unsafe { ffi::graphene_box_contains_point(self.to_glib_none().0, point.to_glib_none().0) }
27 }
28
29 #[doc(alias = "graphene_box_equal")]
30 fn equal(&self, b: &Box) -> bool {
31 unsafe { ffi::graphene_box_equal(self.to_glib_none().0, b.to_glib_none().0) }
32 }
33
34 #[doc(alias = "graphene_box_expand")]
35 #[must_use]
36 pub fn expand(&self, point: &Point3D) -> Box {
37 unsafe {
38 let mut res = Box::uninitialized();
39 ffi::graphene_box_expand(
40 self.to_glib_none().0,
41 point.to_glib_none().0,
42 res.to_glib_none_mut().0,
43 );
44 res
45 }
46 }
47
48 #[doc(alias = "graphene_box_expand_scalar")]
49 #[must_use]
50 pub fn expand_scalar(&self, scalar: f32) -> Box {
51 unsafe {
52 let mut res = Box::uninitialized();
53 ffi::graphene_box_expand_scalar(
54 self.to_glib_none().0,
55 scalar,
56 res.to_glib_none_mut().0,
57 );
58 res
59 }
60 }
61
62 #[doc(alias = "graphene_box_expand_vec3")]
63 #[must_use]
64 pub fn expand_vec3(&self, vec: &Vec3) -> Box {
65 unsafe {
66 let mut res = Box::uninitialized();
67 ffi::graphene_box_expand_vec3(
68 self.to_glib_none().0,
69 vec.to_glib_none().0,
70 res.to_glib_none_mut().0,
71 );
72 res
73 }
74 }
75
76 #[doc(alias = "graphene_box_get_bounding_sphere")]
77 #[doc(alias = "get_bounding_sphere")]
78 pub fn bounding_sphere(&self) -> Sphere {
79 unsafe {
80 let mut sphere = Sphere::uninitialized();
81 ffi::graphene_box_get_bounding_sphere(
82 self.to_glib_none().0,
83 sphere.to_glib_none_mut().0,
84 );
85 sphere
86 }
87 }
88
89 #[doc(alias = "graphene_box_get_center")]
90 #[doc(alias = "get_center")]
91 pub fn center(&self) -> Point3D {
92 unsafe {
93 let mut center = Point3D::uninitialized();
94 ffi::graphene_box_get_center(self.to_glib_none().0, center.to_glib_none_mut().0);
95 center
96 }
97 }
98
99 #[doc(alias = "graphene_box_get_depth")]
100 #[doc(alias = "get_depth")]
101 pub fn depth(&self) -> f32 {
102 unsafe { ffi::graphene_box_get_depth(self.to_glib_none().0) }
103 }
104
105 #[doc(alias = "graphene_box_get_height")]
106 #[doc(alias = "get_height")]
107 pub fn height(&self) -> f32 {
108 unsafe { ffi::graphene_box_get_height(self.to_glib_none().0) }
109 }
110
111 #[doc(alias = "graphene_box_get_max")]
112 #[doc(alias = "get_max")]
113 pub fn max(&self) -> Point3D {
114 unsafe {
115 let mut max = Point3D::uninitialized();
116 ffi::graphene_box_get_max(self.to_glib_none().0, max.to_glib_none_mut().0);
117 max
118 }
119 }
120
121 #[doc(alias = "graphene_box_get_min")]
122 #[doc(alias = "get_min")]
123 pub fn min(&self) -> Point3D {
124 unsafe {
125 let mut min = Point3D::uninitialized();
126 ffi::graphene_box_get_min(self.to_glib_none().0, min.to_glib_none_mut().0);
127 min
128 }
129 }
130
131 #[cfg(feature = "v1_12")]
132 #[cfg_attr(docsrs, doc(cfg(feature = "v1_12")))]
133 #[doc(alias = "graphene_box_get_minmax")]
134 #[doc(alias = "get_minmax")]
135 pub fn minmax(&self) -> (Point3D, Point3D) {
136 unsafe {
137 let mut min = Point3D::uninitialized();
138 let mut max = Point3D::uninitialized();
139 ffi::graphene_box_get_minmax(
140 self.to_glib_none().0,
141 min.to_glib_none_mut().0,
142 max.to_glib_none_mut().0,
143 );
144 (min, max)
145 }
146 }
147
148 #[doc(alias = "graphene_box_get_size")]
149 #[doc(alias = "get_size")]
150 pub fn size(&self) -> Vec3 {
151 unsafe {
152 let mut size = Vec3::uninitialized();
153 ffi::graphene_box_get_size(self.to_glib_none().0, size.to_glib_none_mut().0);
154 size
155 }
156 }
157
158 #[doc(alias = "graphene_box_get_width")]
159 #[doc(alias = "get_width")]
160 pub fn width(&self) -> f32 {
161 unsafe { ffi::graphene_box_get_width(self.to_glib_none().0) }
162 }
163
164 #[doc(alias = "graphene_box_intersection")]
165 pub fn intersection(&self, b: &Box) -> Option<Box> {
166 unsafe {
167 let mut res = Box::uninitialized();
168 let ret = ffi::graphene_box_intersection(
169 self.to_glib_none().0,
170 b.to_glib_none().0,
171 res.to_glib_none_mut().0,
172 );
173 if ret {
174 Some(res)
175 } else {
176 None
177 }
178 }
179 }
180
181 #[doc(alias = "graphene_box_union")]
182 #[must_use]
183 pub fn union(&self, b: &Box) -> Box {
184 unsafe {
185 let mut res = Box::uninitialized();
186 ffi::graphene_box_union(
187 self.to_glib_none().0,
188 b.to_glib_none().0,
189 res.to_glib_none_mut().0,
190 );
191 res
192 }
193 }
194
195 #[doc(alias = "graphene_box_empty")]
196 pub fn empty() -> Box {
197 assert_initialized_main_thread!();
198 unsafe { from_glib_none(ffi::graphene_box_empty()) }
199 }
200
201 #[doc(alias = "graphene_box_infinite")]
202 pub fn infinite() -> Box {
203 assert_initialized_main_thread!();
204 unsafe { from_glib_none(ffi::graphene_box_infinite()) }
205 }
206
207 #[doc(alias = "graphene_box_minus_one")]
208 pub fn minus_one() -> Box {
209 assert_initialized_main_thread!();
210 unsafe { from_glib_none(ffi::graphene_box_minus_one()) }
211 }
212
213 #[doc(alias = "graphene_box_one")]
214 pub fn one() -> Box {
215 assert_initialized_main_thread!();
216 unsafe { from_glib_none(ffi::graphene_box_one()) }
217 }
218
219 #[doc(alias = "graphene_box_one_minus_one")]
220 pub fn one_minus_one() -> Box {
221 assert_initialized_main_thread!();
222 unsafe { from_glib_none(ffi::graphene_box_one_minus_one()) }
223 }
224
225 #[doc(alias = "graphene_box_zero")]
226 pub fn zero() -> Box {
227 assert_initialized_main_thread!();
228 unsafe { from_glib_none(ffi::graphene_box_zero()) }
229 }
230}
231
232impl PartialEq for Box {
233 #[inline]
234 fn eq(&self, other: &Self) -> bool {
235 self.equal(other)
236 }
237}
238
239impl Eq for Box {}