1use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9 pub struct Size(BoxedInline<ffi::graphene_size_t>);
10
11 match fn {
12 copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_size_get_type(), ptr as *mut _) as *mut ffi::graphene_size_t,
13 free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_size_get_type(), ptr as *mut _),
14 type_ => || ffi::graphene_size_get_type(),
15 }
16}
17
18impl Size {
19 #[doc(alias = "graphene_size_equal")]
20 fn equal(&self, b: &Size) -> bool {
21 unsafe { ffi::graphene_size_equal(self.to_glib_none().0, b.to_glib_none().0) }
22 }
23
24 #[doc(alias = "graphene_size_interpolate")]
25 #[must_use]
26 pub fn interpolate(&self, b: &Size, factor: f64) -> Size {
27 unsafe {
28 let mut res = Size::uninitialized();
29 ffi::graphene_size_interpolate(
30 self.to_glib_none().0,
31 b.to_glib_none().0,
32 factor,
33 res.to_glib_none_mut().0,
34 );
35 res
36 }
37 }
38
39 #[doc(alias = "graphene_size_scale")]
40 #[must_use]
41 pub fn scale(&self, factor: f32) -> Size {
42 unsafe {
43 let mut res = Size::uninitialized();
44 ffi::graphene_size_scale(self.to_glib_none().0, factor, res.to_glib_none_mut().0);
45 res
46 }
47 }
48
49 #[doc(alias = "graphene_size_zero")]
50 pub fn zero() -> Size {
51 assert_initialized_main_thread!();
52 unsafe { from_glib_none(ffi::graphene_size_zero()) }
53 }
54}
55
56impl PartialEq for Size {
57 #[inline]
58 fn eq(&self, other: &Self) -> bool {
59 self.equal(other)
60 }
61}
62
63impl Eq for Size {}