clutter/auto/size.rs
1use glib::translate::*;
2
3glib_wrapper! {
4 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
5 pub struct Size(Boxed<ffi::ClutterSize>);
6
7 match fn {
8 copy => |ptr| ffi::clutter_size_copy(mut_override(ptr)),
9 free => |ptr| ffi::clutter_size_free(ptr),
10 get_type => || ffi::clutter_size_get_type(),
11 }
12}
13
14impl Size {
15 /// Allocates a new `Size`.
16 ///
17 /// # Returns
18 ///
19 /// the newly allocated `Size`.
20 /// Use `Size::free` to free its resources.
21 pub fn alloc() -> Size {
22 unsafe { from_glib_full(ffi::clutter_size_alloc()) }
23 }
24
25 /// Compares two `Size` for equality.
26 /// ## `b`
27 /// a `Size` to compare
28 ///
29 /// # Returns
30 ///
31 /// `true` if the two `Size` are equal
32 pub fn equals(&self, b: &Size) -> bool {
33 unsafe {
34 from_glib(ffi::clutter_size_equals(
35 self.to_glib_none().0,
36 b.to_glib_none().0,
37 ))
38 }
39 }
40
41 /// Initializes a `Size` with the given dimensions.
42 /// ## `width`
43 /// the width
44 /// ## `height`
45 /// the height
46 ///
47 /// # Returns
48 ///
49 /// the initialized `Size`
50 pub fn init(&mut self, width: f32, height: f32) -> Option<Size> {
51 unsafe {
52 from_glib_none(ffi::clutter_size_init(
53 self.to_glib_none_mut().0,
54 width,
55 height,
56 ))
57 }
58 }
59}