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
// Take a look at the license at the top of the repository in the LICENSE file.

use crate::Size;
use glib::translate::*;
use std::fmt;

impl Size {
    /// Initializes a [`Size`][crate::Size] using the given `width` and `height`.
    /// ## `width`
    /// the width
    /// ## `height`
    /// the height
    ///
    /// # Returns
    ///
    /// the initialized [`Size`][crate::Size]
    #[doc(alias = "graphene_size_init")]
    pub fn new(width: f32, height: f32) -> Self {
        assert_initialized_main_thread!();
        unsafe {
            let mut siz = Self::uninitialized();
            ffi::graphene_size_init(siz.to_glib_none_mut().0, width, height);
            siz
        }
    }

    pub fn width(&self) -> f32 {
        self.inner.width
    }

    pub fn set_width(&mut self, width: f32) {
        self.inner.width = width;
    }

    pub fn height(&self) -> f32 {
        self.inner.height
    }

    pub fn set_height(&mut self, height: f32) {
        self.inner.height = height;
    }
}

impl fmt::Debug for Size {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.debug_struct("Size")
            .field("width", &self.width())
            .field("height", &self.height())
            .finish()
    }
}