Skip to content

Commit 0404bab

Browse files
committed
WIP: add bg_colour to WidgetStyle
1 parent a4ddb7d commit 0404bab

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

src/options/config/style.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ pub struct Styles {
117117
pub(crate) selected_text_style: Style,
118118
pub(crate) table_header_style: Style,
119119
pub(crate) widget_title_style: Style,
120+
pub(crate) bg_color_style: Style,
120121
pub(crate) graph_style: Style,
121122
pub(crate) graph_legend_style: Style,
122123
pub(crate) high_battery: Style,
@@ -207,6 +208,7 @@ impl Styles {
207208
set_style!(self.graph_legend_style, config.graphs, legend_text);
208209

209210
// General widget text.
211+
set_colour!(self.bg_color_style, config.widgets, bg_color);
210212
set_style!(self.widget_title_style, config.widgets, widget_title);
211213
set_style!(self.text_style, config.widgets, text);
212214
set_style!(self.selected_text_style, config.widgets, selected_text);

src/options/config/style/themes/default.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ impl Styles {
5959
selected_text_style: DEFAULT_SELECTED_TEXT_STYLE,
6060
table_header_style: color!(HIGHLIGHT_COLOUR).add_modifier(Modifier::BOLD),
6161
widget_title_style: color!(TEXT_COLOUR),
62+
bg_color_style: Style::default(),
6263
graph_style: color!(TEXT_COLOUR),
6364
graph_legend_style: color!(TEXT_COLOUR),
6465
high_battery: color!(Color::Green),

src/options/config/style/themes/gruvbox.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use tui::{
2-
style::{Color, Modifier},
2+
style::{Color, Modifier, Style},
33
widgets::BorderType,
44
};
55

@@ -58,6 +58,7 @@ impl Styles {
5858
text_style: hex!("#ebdbb2"),
5959
selected_text_style: hex!("#1d2021").bg(hex_colour!("#ebdbb2")),
6060
table_header_style: hex!("#83a598").add_modifier(Modifier::BOLD),
61+
bg_color_style: Style::default(),
6162
widget_title_style: hex!("#ebdbb2"),
6263
graph_style: hex!("#ebdbb2"),
6364
graph_legend_style: hex!("#ebdbb2"),
@@ -123,6 +124,7 @@ impl Styles {
123124
text_style: hex!("#3c3836"),
124125
selected_text_style: hex!("#ebdbb2").bg(hex_colour!("#3c3836")),
125126
table_header_style: hex!("#076678").add_modifier(Modifier::BOLD),
127+
bg_color_style: Style::default(),
126128
widget_title_style: hex!("#3c3836"),
127129
graph_style: hex!("#3c3836"),
128130
graph_legend_style: hex!("#3c3836"),

src/options/config/style/themes/nord.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use tui::{
2-
style::{Color, Modifier},
2+
style::{Color, Modifier, Style},
33
widgets::BorderType,
44
};
55

@@ -46,6 +46,7 @@ impl Styles {
4646
text_style: hex!("#e5e9f0"),
4747
selected_text_style: hex!("#2e3440").bg(hex_colour!("#88c0d0")),
4848
table_header_style: hex!("#81a1c1").add_modifier(Modifier::BOLD),
49+
bg_color_style: Style::default(),
4950
widget_title_style: hex!("#e5e9f0"),
5051
graph_style: hex!("#e5e9f0"),
5152
graph_legend_style: hex!("#e5e9f0"),
@@ -99,6 +100,7 @@ impl Styles {
99100
text_style: hex!("#2e3440"),
100101
selected_text_style: hex!("#f5f5f5").bg(hex_colour!("#5e81ac")),
101102
table_header_style: hex!("#5e81ac").add_modifier(Modifier::BOLD),
103+
bg_color_style: Style::default(),
102104
widget_title_style: hex!("#2e3440"),
103105
graph_style: hex!("#2e3440"),
104106
graph_legend_style: hex!("#2e3440"),

src/options/config/style/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ fn convert_name_to_colour(color_name: &str) -> Result<Color, String> {
9696
"white" => Ok(Color::White),
9797
_ => Err(format!(
9898
"'{color_name}' is an invalid named color.
99-
100-
The following are supported named colors:
99+
100+
The following are supported named colors:
101101
+--------+-------------+---------------------+
102102
| Reset | Magenta | Light Yellow |
103103
+--------+-------------+---------------------+

src/options/config/style/widgets.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,7 @@ pub(crate) struct WidgetStyle {
3333

3434
/// Widget borders type.
3535
pub(crate) widget_border_type: Option<WidgetBorderType>,
36+
37+
/// Background color for widgets in general
38+
pub(crate) bg_color: Option<ColorStr>,
3639
}

0 commit comments

Comments
 (0)