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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
use glib::translate::*;
use std::fmt;
glib::wrapper! {
#[doc(alias = "GtkBorder")]
pub struct Border(BoxedInline<ffi::GtkBorder>);
match fn {
copy => |ptr| ffi::gtk_border_copy(mut_override(ptr)),
free => |ptr| ffi::gtk_border_free(ptr),
type_ => || ffi::gtk_border_get_type(),
}
}
impl Border {
#[doc(alias = "gtk_border_new")]
pub fn new() -> Self {
assert_initialized_main_thread!();
unsafe { Self::uninitialized() }
}
pub fn builder() -> BorderBuilder {
BorderBuilder::default()
}
pub fn left(&self) -> i16 {
self.inner.left
}
pub fn set_left(&mut self, left: i16) {
self.inner.left = left;
}
pub fn right(&self) -> i16 {
self.inner.right
}
pub fn set_right(&mut self, right: i16) {
self.inner.right = right;
}
pub fn top(&self) -> i16 {
self.inner.top
}
pub fn set_top(&mut self, top: i16) {
self.inner.top = top;
}
pub fn bottom(&self) -> i16 {
self.inner.bottom
}
pub fn set_bottom(&mut self, bottom: i16) {
self.inner.bottom = bottom;
}
}
impl Default for Border {
fn default() -> Self {
Self::new()
}
}
impl fmt::Debug for Border {
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
fmt.debug_struct("Border")
.field("left", &self.left())
.field("right", &self.right())
.field("top", &self.top())
.field("bottom", &self.bottom())
.finish()
}
}
impl PartialEq for Border {
fn eq(&self, other: &Self) -> bool {
self.left() == other.left()
&& self.right() == other.right()
&& self.top() == other.top()
&& self.bottom() == other.bottom()
}
}
impl Eq for Border {}
#[derive(Clone, Default)]
#[must_use = "The builder must be built to be used"]
pub struct BorderBuilder {
left: Option<i16>,
right: Option<i16>,
bottom: Option<i16>,
top: Option<i16>,
}
impl BorderBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn left(mut self, left: i16) -> Self {
self.left = Some(left);
self
}
pub fn right(mut self, right: i16) -> Self {
self.right = Some(right);
self
}
pub fn bottom(mut self, bottom: i16) -> Self {
self.bottom = Some(bottom);
self
}
pub fn top(mut self, top: i16) -> Self {
self.top = Some(top);
self
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> Border {
let mut border = Border::default();
if let Some(left) = self.left {
border.set_left(left);
}
if let Some(right) = self.right {
border.set_right(right);
}
if let Some(bottom) = self.bottom {
border.set_bottom(bottom);
}
if let Some(top) = self.top {
border.set_top(top);
}
border
}
}