animate/legacy/matrix.rs
1use glib::translate::*;
2use std::mem;
3
4glib_wrapper! {
5 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
6 pub struct Matrix(Boxed<ffi::ClutterMatrix>);
7
8 match fn {
9 copy => |ptr| gobject_sys::g_boxed_copy(ffi::clutter_matrix_get_type(), ptr as *mut _) as *mut ffi::ClutterMatrix,
10 free => |ptr| gobject_sys::g_boxed_free(ffi::clutter_matrix_get_type(), ptr as *mut _),
11 get_type => || ffi::clutter_matrix_get_type(),
12 }
13}
14
15impl Matrix {
16 //pub fn init_from_array(&mut self, values: /*Unimplemented*/FixedArray TypeId { ns_id: 0, id: 20 }; 16) -> Option<Matrix> {
17 // unsafe { TODO: call clutter_sys:clutter_matrix_init_from_array() }
18 //}
19
20 /// Initializes the `Matrix` `self` with the contents of the
21 /// `Matrix` `b`.
22 /// ## `b`
23 /// the `Matrix` to copy
24 ///
25 /// # Returns
26 ///
27 /// the initialized `Matrix`
28 pub fn init_from_matrix(&mut self, b: &Matrix) -> Option<Matrix> {
29 unsafe {
30 from_glib_none(ffi::clutter_matrix_init_from_matrix(
31 self.to_glib_none_mut().0,
32 b.to_glib_none().0,
33 ))
34 }
35 }
36
37 /// Initializes `self` with the identity matrix, i.e.:
38 ///
39 ///
40 /// ```text
41 /// .xx = 1.0, .xy = 0.0, .xz = 0.0, .xw = 0.0
42 /// .yx = 0.0, .yy = 1.0, .yz = 0.0, .yw = 0.0
43 /// .zx = 0.0, .zy = 0.0, .zz = 1.0, .zw = 0.0
44 /// .wx = 0.0, .wy = 0.0, .wz = 0.0, .ww = 1.0
45 /// ```
46 ///
47 /// # Returns
48 ///
49 /// the initialized `Matrix`
50 pub fn init_identity(&mut self) -> Option<Matrix> {
51 unsafe { from_glib_none(ffi::clutter_matrix_init_identity(self.to_glib_none_mut().0)) }
52 }
53
54 /// Allocates enough memory to hold a `Matrix`.
55 ///
56 /// # Returns
57 ///
58 /// the newly allocated `Matrix`
59 pub fn alloc() -> Option<Matrix> {
60 unsafe { from_glib_full(ffi::clutter_matrix_alloc()) }
61 }
62}
63
64#[doc(hidden)]
65impl Uninitialized for Matrix {
66 #[inline]
67 unsafe fn uninitialized() -> Self {
68 Self::alloc().unwrap()
69 }
70}