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