graphene/auto/
size.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;
6use glib::translate::*;
7
8glib::wrapper! {
9    /// A size.
10    pub struct Size(BoxedInline<ffi::graphene_size_t>);
11
12    match fn {
13        copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::graphene_size_get_type(), ptr as *mut _) as *mut ffi::graphene_size_t,
14        free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::graphene_size_get_type(), ptr as *mut _),
15        type_ => || ffi::graphene_size_get_type(),
16    }
17}
18
19impl Size {
20    #[doc(alias = "graphene_size_equal")]
21    fn equal(&self, b: &Size) -> bool {
22        unsafe { ffi::graphene_size_equal(self.to_glib_none().0, b.to_glib_none().0) }
23    }
24
25    /// Linearly interpolates the two given [`Size`][crate::Size] using the given
26    /// interpolation `factor`.
27    /// ## `b`
28    /// a [`Size`][crate::Size]
29    /// ## `factor`
30    /// the linear interpolation factor
31    ///
32    /// # Returns
33    ///
34    ///
35    /// ## `res`
36    /// return location for the interpolated size
37    #[doc(alias = "graphene_size_interpolate")]
38    #[must_use]
39    pub fn interpolate(&self, b: &Size, factor: f64) -> Size {
40        unsafe {
41            let mut res = Size::uninitialized();
42            ffi::graphene_size_interpolate(
43                self.to_glib_none().0,
44                b.to_glib_none().0,
45                factor,
46                res.to_glib_none_mut().0,
47            );
48            res
49        }
50    }
51
52    /// Scales the components of a [`Size`][crate::Size] using the given `factor`.
53    /// ## `factor`
54    /// the scaling factor
55    ///
56    /// # Returns
57    ///
58    ///
59    /// ## `res`
60    /// return location for the scaled size
61    #[doc(alias = "graphene_size_scale")]
62    #[must_use]
63    pub fn scale(&self, factor: f32) -> Size {
64        unsafe {
65            let mut res = Size::uninitialized();
66            ffi::graphene_size_scale(self.to_glib_none().0, factor, res.to_glib_none_mut().0);
67            res
68        }
69    }
70
71    /// A constant pointer to a zero [`Size`][crate::Size], useful for
72    /// equality checks and interpolations.
73    ///
74    /// # Returns
75    ///
76    /// a constant size
77    #[doc(alias = "graphene_size_zero")]
78    pub fn zero() -> Size {
79        assert_initialized_main_thread!();
80        unsafe { from_glib_none(ffi::graphene_size_zero()) }
81    }
82}
83
84impl PartialEq for Size {
85    #[inline]
86    fn eq(&self, other: &Self) -> bool {
87        self.equal(other)
88    }
89}
90
91impl Eq for Size {}