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