1use std::fmt;
4
5use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9 #[doc(alias = "PangoRectangle")]
10 pub struct Rectangle(BoxedInline<ffi::PangoRectangle>);
11}
12
13impl Rectangle {
14 #[inline]
15 pub fn new(x: i32, y: i32, width: i32, height: i32) -> Self {
16 unsafe {
17 Self::unsafe_from(ffi::PangoRectangle {
18 x,
19 y,
20 width,
21 height,
22 })
23 }
24 }
25
26 #[inline]
27 pub fn x(&self) -> i32 {
28 self.inner.x
29 }
30
31 #[inline]
32 pub fn set_x(&mut self, x: i32) {
33 self.inner.x = x;
34 }
35
36 #[inline]
37 pub fn y(&self) -> i32 {
38 self.inner.y
39 }
40
41 #[inline]
42 pub fn set_y(&mut self, y: i32) {
43 self.inner.y = y;
44 }
45
46 #[inline]
47 pub fn width(&self) -> i32 {
48 self.inner.width
49 }
50
51 #[inline]
52 pub fn set_width(&mut self, width: i32) {
53 self.inner.width = width;
54 }
55
56 #[inline]
57 pub fn height(&self) -> i32 {
58 self.inner.height
59 }
60
61 #[inline]
62 pub fn set_height(&mut self, height: i32) {
63 self.inner.height = height;
64 }
65}
66
67impl fmt::Debug for Rectangle {
68 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
69 f.debug_struct("Rectangle")
70 .field("x", &self.x())
71 .field("y", &self.y())
72 .field("width", &self.width())
73 .field("height", &self.height())
74 .finish()
75 }
76}