diff --git a/src/widget/label.rs b/src/widget/label.rs index 30fb04c..5434b9f 100755 --- a/src/widget/label.rs +++ b/src/widget/label.rs @@ -11,12 +11,16 @@ use crate::{widget::Widget, layout::position::Position}; pub struct Label { text: String, - color: Color, + fg_color: Color, + bg_color: Color, } impl Widget for Label { fn draw(&self, renderer: &mut Renderer) { - renderer.set_brush(Brush::Solid(self.color)); + let pos = self.position(renderer); + renderer.set_brush(Brush::Solid(self.bg_color)); + renderer.fill_rect(pos.width(), pos.height()); + renderer.set_brush(Brush::Solid(self.fg_color)); renderer.draw_text(&self.text); } @@ -30,12 +34,18 @@ impl Label { pub fn new>(text: S) -> Self { Self { text: text.into(), - color: rgb!(0x000000FF), + fg_color: rgb!(0x000000FF), + bg_color: rgb!(0x00000000), } } pub fn color(mut self, color: Color) -> Self { - self.color = color; + self.fg_color = color; + self + } + + pub fn bg_color(mut self, bg: Color) -> Self { + self.bg_color = bg; self } }