clutter/auto/
vertex.rs

1use glib::translate::*;
2
3glib_wrapper! {
4    #[derive(Debug, PartialOrd, Ord)] // Hash
5    pub struct Vertex(Boxed<ffi::ClutterVertex>);
6
7    match fn {
8        copy => |ptr| ffi::clutter_vertex_copy(mut_override(ptr)),
9        free => |ptr| ffi::clutter_vertex_free(ptr),
10        get_type => || ffi::clutter_vertex_get_type(),
11    }
12}
13
14impl Vertex {
15    /// Allocates a new, empty `Vertex`.
16    ///
17    /// # Returns
18    ///
19    /// the newly allocated `Vertex`.
20    ///  Use `Vertex::free` to free its resources
21    pub fn alloc() -> Vertex {
22        unsafe { from_glib_full(ffi::clutter_vertex_alloc()) }
23    }
24
25    /// Creates a new `Vertex` for the point in 3D space
26    /// identified by the 3 coordinates `x`, `y`, `z`.
27    ///
28    /// This function is the logical equivalent of:
29    ///
30    ///
31    /// ```text
32    ///   clutter_vertex_init (clutter_vertex_alloc (), x, y, z);
33    /// ```
34    /// ## `x`
35    /// X coordinate
36    /// ## `y`
37    /// Y coordinate
38    /// ## `z`
39    /// Z coordinate
40    ///
41    /// # Returns
42    ///
43    /// the newly allocated `Vertex`.
44    ///  Use `Vertex::free` to free the resources
45    pub fn new(x: f32, y: f32, z: f32) -> Vertex {
46        unsafe { from_glib_full(ffi::clutter_vertex_new(x, y, z)) }
47    }
48
49    /// Compares `self` and `vertex_b` for equality
50    /// ## `vertex_b`
51    /// a `Vertex`
52    ///
53    /// # Returns
54    ///
55    /// `true` if the passed `Vertex` are equal
56    fn equal(&self, vertex_b: &Vertex) -> bool {
57        unsafe {
58            from_glib(ffi::clutter_vertex_equal(
59                self.to_glib_none().0,
60                vertex_b.to_glib_none().0,
61            ))
62        }
63    }
64
65    /// Initializes `self` with the given coordinates.
66    /// ## `x`
67    /// X coordinate
68    /// ## `y`
69    /// Y coordinate
70    /// ## `z`
71    /// Z coordinate
72    ///
73    /// # Returns
74    ///
75    /// the initialized `Vertex`
76    pub fn init(&mut self, x: f32, y: f32, z: f32) -> Option<Vertex> {
77        unsafe { from_glib_none(ffi::clutter_vertex_init(self.to_glib_none_mut().0, x, y, z)) }
78    }
79}
80
81impl PartialEq for Vertex {
82    #[inline]
83    fn eq(&self, other: &Self) -> bool {
84        self.equal(other)
85    }
86}
87
88#[doc(hidden)]
89impl Uninitialized for Vertex {
90    #[inline]
91    unsafe fn uninitialized() -> Self {
92        Self::alloc()
93    }
94}
95
96impl Eq for Vertex {}