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
// 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::*;
use pango_sys;
#[cfg(any(feature = "v1_38", feature = "dox"))]
use std::mem;

glib_wrapper! {
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct Matrix(Boxed<pango_sys::PangoMatrix>);

    match fn {
        copy => |ptr| pango_sys::pango_matrix_copy(mut_override(ptr)),
        free => |ptr| pango_sys::pango_matrix_free(ptr),
        get_type => || pango_sys::pango_matrix_get_type(),
    }
}

impl Matrix {
    pub fn concat(&mut self, new_matrix: &Matrix) {
        unsafe {
            pango_sys::pango_matrix_concat(self.to_glib_none_mut().0, new_matrix.to_glib_none().0);
        }
    }

    pub fn get_font_scale_factor(&self) -> f64 {
        unsafe { pango_sys::pango_matrix_get_font_scale_factor(self.to_glib_none().0) }
    }

    #[cfg(any(feature = "v1_38", feature = "dox"))]
    pub fn get_font_scale_factors(&self) -> (f64, f64) {
        unsafe {
            let mut xscale = mem::MaybeUninit::uninit();
            let mut yscale = mem::MaybeUninit::uninit();
            pango_sys::pango_matrix_get_font_scale_factors(
                self.to_glib_none().0,
                xscale.as_mut_ptr(),
                yscale.as_mut_ptr(),
            );
            let xscale = xscale.assume_init();
            let yscale = yscale.assume_init();
            (xscale, yscale)
        }
    }

    pub fn rotate(&mut self, degrees: f64) {
        unsafe {
            pango_sys::pango_matrix_rotate(self.to_glib_none_mut().0, degrees);
        }
    }

    pub fn scale(&mut self, scale_x: f64, scale_y: f64) {
        unsafe {
            pango_sys::pango_matrix_scale(self.to_glib_none_mut().0, scale_x, scale_y);
        }
    }

    pub fn transform_distance(&self, dx: &mut f64, dy: &mut f64) {
        unsafe {
            pango_sys::pango_matrix_transform_distance(self.to_glib_none().0, dx, dy);
        }
    }

    //pub fn transform_pixel_rectangle(&self, rect: /*Unimplemented*/Option<Rectangle>) {
    //    unsafe { TODO: call pango_sys:pango_matrix_transform_pixel_rectangle() }
    //}

    pub fn transform_point(&self, x: &mut f64, y: &mut f64) {
        unsafe {
            pango_sys::pango_matrix_transform_point(self.to_glib_none().0, x, y);
        }
    }

    //pub fn transform_rectangle(&self, rect: /*Unimplemented*/Option<Rectangle>) {
    //    unsafe { TODO: call pango_sys:pango_matrix_transform_rectangle() }
    //}

    pub fn translate(&mut self, tx: f64, ty: f64) {
        unsafe {
            pango_sys::pango_matrix_translate(self.to_glib_none_mut().0, tx, ty);
        }
    }
}