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
mod border;
mod space;
pub use border::{BorderColor, BorderComponents, BorderStyle};
pub use console::Alignment;
use space::Space;
use crate::Billboard;
#[derive(Clone, PartialEq, Debug)]
pub struct Config {
pub(crate) padding: Space,
pub(crate) margin: Space,
pub(crate) border_components: BorderComponents,
pub(crate) border_color: Option<BorderColor>,
pub(crate) box_alignment: Alignment,
pub(crate) text_alignment: Alignment,
}
impl Config {
pub fn default() -> Config {
Config {
padding: Space::uniform(2),
margin: Space::uniform(0),
border_color: None,
border_components: BorderComponents::new(BorderStyle::Single),
text_alignment: Alignment::Center,
box_alignment: Alignment::Center,
}
}
pub fn padding<'a>(&'a mut self, padding: usize) -> &'a mut Config {
self.padding = Space::uniform(padding);
self
}
pub fn margin<'a>(&'a mut self, margin: usize) -> &'a mut Config {
self.margin = Space::uniform(margin);
self
}
pub fn border_style<'a>(&'a mut self, border_style: BorderStyle) -> &'a mut Config {
self.border_components = BorderComponents::new(border_style);
self
}
pub fn text_alignment<'a>(&'a mut self, text_alignment: Alignment) -> &'a mut Config {
self.text_alignment = text_alignment;
self
}
pub fn box_alignment<'a>(&'a mut self, box_alignment: Alignment) -> &'a mut Config {
self.box_alignment = box_alignment;
self
}
pub fn border_color<'a>(&'a mut self, border_color: BorderColor) -> &'a mut Config {
self.border_color = Some(border_color);
self
}
pub fn build<'a>(&'a mut self) -> Billboard {
Billboard {
config: self.to_owned(),
}
}
}