Impl disabling showing specific info texts

This commit is contained in:
Stephen Seo 2021-12-15 19:40:23 +09:00
parent 570b6ab33c
commit 0077d460c6

View file

@ -274,7 +274,7 @@ impl MPDDisplay {
*offset_y -= height + TEXT_OFFSET_Y_SPACING; *offset_y -= height + TEXT_OFFSET_Y_SPACING;
}; };
if !self.filename_text.contents().is_empty() { if !self.filename_text.contents().is_empty() && !self.opts.disable_show_filename {
set_transform( set_transform(
&mut self.filename_text, &mut self.filename_text,
&mut self.filename_transform, &mut self.filename_transform,
@ -287,7 +287,7 @@ impl MPDDisplay {
log("filename text is empty"); log("filename text is empty");
} }
if !self.artist_text.contents().is_empty() { if !self.artist_text.contents().is_empty() && !self.opts.disable_show_artist {
set_transform( set_transform(
&mut self.artist_text, &mut self.artist_text,
&mut self.artist_transform, &mut self.artist_transform,
@ -300,7 +300,7 @@ impl MPDDisplay {
log("artist text is empty"); log("artist text is empty");
} }
if !self.title_text.contents().is_empty() { if !self.title_text.contents().is_empty() && !self.opts.disable_show_title {
set_transform( set_transform(
&mut self.title_text, &mut self.title_text,
&mut self.title_transform, &mut self.title_transform,
@ -327,8 +327,9 @@ impl MPDDisplay {
let title_dimensions = self.title_text.dimensions(ctx); let title_dimensions = self.title_text.dimensions(ctx);
let timer_dimensions = self.timer_text.dimensions(ctx); let timer_dimensions = self.timer_text.dimensions(ctx);
let mesh: Mesh = MeshBuilder::new() let mut mesh_builder: MeshBuilder = MeshBuilder::new();
.rectangle( if !self.opts.disable_show_filename {
mesh_builder.rectangle(
DrawMode::fill(), DrawMode::fill(),
Rect { Rect {
x: TEXT_X_OFFSET, x: TEXT_X_OFFSET,
@ -337,8 +338,10 @@ impl MPDDisplay {
h: filename_dimensions.h, h: filename_dimensions.h,
}, },
Color::from_rgba(0, 0, 0, 160), Color::from_rgba(0, 0, 0, 160),
)? )?;
.rectangle( }
if !self.opts.disable_show_artist {
mesh_builder.rectangle(
DrawMode::fill(), DrawMode::fill(),
Rect { Rect {
x: TEXT_X_OFFSET, x: TEXT_X_OFFSET,
@ -347,8 +350,10 @@ impl MPDDisplay {
h: artist_dimensions.h, h: artist_dimensions.h,
}, },
Color::from_rgba(0, 0, 0, 160), Color::from_rgba(0, 0, 0, 160),
)? )?;
.rectangle( }
if !self.opts.disable_show_title {
mesh_builder.rectangle(
DrawMode::fill(), DrawMode::fill(),
Rect { Rect {
x: TEXT_X_OFFSET, x: TEXT_X_OFFSET,
@ -357,7 +362,9 @@ impl MPDDisplay {
h: title_dimensions.h, h: title_dimensions.h,
}, },
Color::from_rgba(0, 0, 0, 160), Color::from_rgba(0, 0, 0, 160),
)? )?;
}
let mesh: Mesh = mesh_builder
.rectangle( .rectangle(
DrawMode::fill(), DrawMode::fill(),
Rect { Rect {
@ -504,29 +511,35 @@ impl EventHandler for MPDDisplay {
mesh.draw(ctx, DrawParam::default())?; mesh.draw(ctx, DrawParam::default())?;
} }
self.filename_text.draw( if !self.opts.disable_show_filename {
ctx, self.filename_text.draw(
DrawParam { ctx,
trans: self.filename_transform, DrawParam {
..Default::default() trans: self.filename_transform,
}, ..Default::default()
)?; },
)?;
}
self.artist_text.draw( if !self.opts.disable_show_artist {
ctx, self.artist_text.draw(
DrawParam { ctx,
trans: self.artist_transform, DrawParam {
..Default::default() trans: self.artist_transform,
}, ..Default::default()
)?; },
)?;
}
self.title_text.draw( if !self.opts.disable_show_title {
ctx, self.title_text.draw(
DrawParam { ctx,
trans: self.title_transform, DrawParam {
..Default::default() trans: self.title_transform,
}, ..Default::default()
)?; },
)?;
}
self.timer_text.draw( self.timer_text.draw(
ctx, ctx,