thedes_tui/progress_bar/
style.rs1use thedes_tui_core::{
2 color::{BasicColor, Color, ColorPair},
3 geometry::Coord,
4};
5
6#[derive(Debug, Clone)]
7pub struct Style {
8 title_y: Coord,
9 title_colors: ColorPair,
10 pad_after_title: Coord,
11 bar_size: Coord,
12 bar_colors: ColorPair,
13 pad_after_bar: Coord,
14 perc_colors: ColorPair,
15 pad_after_perc: Coord,
16 absolute_colors: ColorPair,
17 pad_after_abs: Coord,
18 status_colors: ColorPair,
19 background: Color,
20}
21
22impl Default for Style {
23 fn default() -> Self {
24 Self {
25 title_y: 1,
26 title_colors: ColorPair::default(),
27 pad_after_title: 2,
28 pad_after_bar: 0,
29 pad_after_perc: 1,
30 pad_after_abs: 1,
31 bar_size: 32,
32 bar_colors: ColorPair {
33 foreground: BasicColor::White.into(),
34 background: BasicColor::DarkGray.into(),
35 },
36 absolute_colors: ColorPair::default(),
37 perc_colors: ColorPair::default(),
38 status_colors: ColorPair::default(),
39 background: BasicColor::Black.into(),
40 }
41 }
42}
43
44impl Style {
45 pub fn new() -> Self {
46 Self::default()
47 }
48
49 pub fn with_title_y(self, value: Coord) -> Self {
50 Self { title_y: value, ..self }
51 }
52
53 pub fn title_y(&self) -> Coord {
54 self.title_y
55 }
56
57 pub fn with_title_colors(self, value: ColorPair) -> Self {
58 Self { title_colors: value, ..self }
59 }
60
61 pub fn title_colors(&self) -> ColorPair {
62 self.title_colors
63 }
64
65 pub fn with_pad_after_title(self, value: Coord) -> Self {
66 Self { pad_after_title: value, ..self }
67 }
68
69 pub fn pad_after_title(&self) -> Coord {
70 self.pad_after_title
71 }
72
73 pub fn with_bar_size(self, value: Coord) -> Self {
74 Self { bar_size: value, ..self }
75 }
76
77 pub fn bar_size(&self) -> Coord {
78 self.bar_size
79 }
80
81 pub fn with_bar_colors(self, value: ColorPair) -> Self {
82 Self { bar_colors: value, ..self }
83 }
84
85 pub fn bar_colors(&self) -> ColorPair {
86 self.bar_colors
87 }
88
89 pub fn with_pad_after_bar(self, value: Coord) -> Self {
90 Self { pad_after_bar: value, ..self }
91 }
92
93 pub fn pad_after_bar(&self) -> Coord {
94 self.pad_after_bar
95 }
96
97 pub fn with_perc_colors(self, value: ColorPair) -> Self {
98 Self { perc_colors: value, ..self }
99 }
100
101 pub fn perc_colors(&self) -> ColorPair {
102 self.perc_colors
103 }
104
105 pub fn with_pad_after_perc(self, value: Coord) -> Self {
106 Self { pad_after_perc: value, ..self }
107 }
108
109 pub fn pad_after_perc(&self) -> Coord {
110 self.pad_after_perc
111 }
112
113 pub fn with_absolute_colors(self, value: ColorPair) -> Self {
114 Self { absolute_colors: value, ..self }
115 }
116
117 pub fn absolute_colors(&self) -> ColorPair {
118 self.absolute_colors
119 }
120
121 pub fn with_pad_after_abs(self, value: Coord) -> Self {
122 Self { pad_after_abs: value, ..self }
123 }
124
125 pub fn pad_after_abs(&self) -> Coord {
126 self.pad_after_abs
127 }
128
129 pub fn with_status_colors(self, value: ColorPair) -> Self {
130 Self { status_colors: value, ..self }
131 }
132
133 pub fn status_colors(&self) -> ColorPair {
134 self.status_colors
135 }
136
137 pub fn with_background(self, value: Color) -> Self {
138 Self { background: value, ..self }
139 }
140
141 pub fn background(&self) -> Color {
142 self.background
143 }
144}