Impl setting opacity of text bg via arg

This commit is contained in:
Stephen Seo 2022-08-10 14:05:39 +09:00
parent d4208d0b89
commit adf0125e1e
2 changed files with 12 additions and 5 deletions

View file

@ -619,7 +619,7 @@ impl MPDDisplay {
w: filename_dimensions.w, w: filename_dimensions.w,
h: filename_dimensions.h, h: filename_dimensions.h,
}, },
Color::from_rgba(0, 0, 0, 160), Color::from_rgba(0, 0, 0, self.opts.text_bg_opacity),
)?; )?;
} }
if !self.opts.disable_show_album { if !self.opts.disable_show_album {
@ -631,7 +631,7 @@ impl MPDDisplay {
w: album_dimensions.w, w: album_dimensions.w,
h: album_dimensions.h, h: album_dimensions.h,
}, },
Color::from_rgba(0, 0, 0, 160), Color::from_rgba(0, 0, 0, self.opts.text_bg_opacity),
)?; )?;
} }
if !self.opts.disable_show_artist { if !self.opts.disable_show_artist {
@ -643,7 +643,7 @@ impl MPDDisplay {
w: artist_dimensions.w, w: artist_dimensions.w,
h: artist_dimensions.h, h: artist_dimensions.h,
}, },
Color::from_rgba(0, 0, 0, 160), Color::from_rgba(0, 0, 0, self.opts.text_bg_opacity),
)?; )?;
} }
if !self.opts.disable_show_title { if !self.opts.disable_show_title {
@ -655,7 +655,7 @@ impl MPDDisplay {
w: title_dimensions.w, w: title_dimensions.w,
h: title_dimensions.h, h: title_dimensions.h,
}, },
Color::from_rgba(0, 0, 0, 160), Color::from_rgba(0, 0, 0, self.opts.text_bg_opacity),
)?; )?;
} }
let mesh: Mesh = mesh_builder let mesh: Mesh = mesh_builder
@ -667,7 +667,7 @@ impl MPDDisplay {
w: timer_dimensions.w, w: timer_dimensions.w,
h: timer_dimensions.h, h: timer_dimensions.h,
}, },
Color::from_rgba(0, 0, 0, 160), Color::from_rgba(0, 0, 0, self.opts.text_bg_opacity),
)? )?
.build(ctx)?; .build(ctx)?;

View file

@ -49,6 +49,13 @@ pub struct Opt {
case_insensitive = true, case_insensitive = true,
)] )]
log_level: debug_log::LogLevel, log_level: debug_log::LogLevel,
#[structopt(
short,
long,
help = "sets the opacity of the text background (0-255)",
default_value = "190"
)]
text_bg_opacity: u8,
} }
fn main() -> Result<(), String> { fn main() -> Result<(), String> {