Skip to content

Commit

Permalink
Add background color setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jerzywilczek committed Jan 24, 2024
1 parent 088d87c commit 45edd47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/config/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ impl Theme {
widget: WidgetTheme {
frame_color: default_colors::CYAN,
title_color: default_colors::CYAN,
background_color: Some(SerdeColor(tui::style::Color::Rgb(0x00, 0x2b, 0x36))),
},

plot: PlotTheme {
Expand Down Expand Up @@ -116,13 +117,16 @@ pub struct WidgetTheme {
pub frame_color: SerdeColor,
#[serde(default = "default_colors::cyan")]
pub title_color: SerdeColor,
#[serde(default)]
pub background_color: Option<SerdeColor>,
}

impl Default for WidgetTheme {
fn default() -> Self {
Self {
frame_color: SerdeColor(Color::Cyan),
title_color: SerdeColor(Color::Cyan),
background_color: None,
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ pub mod processes;

/// Renders the user interface widgets.
pub fn render<B: Backend>(app: &mut App, frame: &mut Frame<'_, B>) {
let block_style = Style::default().fg(*app.config.theme.widget.frame_color);
let title_style = Style::default().fg(*app.config.theme.widget.title_color);
let mut block_style = Style::default().fg(*app.config.theme.widget.frame_color);
block_style.bg = app.config.theme.widget.background_color.map(|c| c.0);

let mut title_style = Style::default().fg(*app.config.theme.widget.title_color);
title_style.bg = app.config.theme.widget.background_color.map(|c| c.0);

let block = Block::default()
.borders(Borders::all())
.border_type(BorderType::Rounded);
Expand Down

0 comments on commit 45edd47

Please sign in to comment.