use image::DynamicImage;
use util::color::Color;
use error::BarError;
use bar;
#[derive(Clone)]
pub struct BarBuilder {
pub(crate) background_image: Option<DynamicImage>,
pub(crate) background_color: Color,
pub(crate) foreground_color: Color,
pub(crate) output: Option<String>,
pub(crate) font: Option<String>,
pub(crate) name: String,
pub(crate) height: u16,
pub(crate) text_yoffset: i16,
_new_lock: (),
}
impl BarBuilder {
pub fn new() -> Self {
BarBuilder::default()
}
pub fn foreground_color(mut self, color: Color) -> Self {
self.foreground_color = color;
self
}
pub fn background_color(mut self, color: Color) -> Self {
self.background_color = color;
self
}
pub fn background_image(mut self, image: DynamicImage) -> Self {
self.background_image = Some(image);
self
}
pub fn name<T: Into<String>>(mut self, name: T) -> Self {
self.name = name.into();
self
}
pub fn font<T: Into<String>>(mut self, font: T) -> Self {
self.font = Some(font.into());
self
}
pub fn height(mut self, height: u16) -> Self {
self.height = height;
self
}
pub fn output<T: Into<String>>(mut self, output: T) -> Self {
self.output = Some(output.into());
self
}
pub fn text_yoffset(mut self, text_yoffset: i16) -> Self {
self.text_yoffset = text_yoffset;
self
}
pub fn spawn(self) -> Result<bar::Bar, BarError> {
let bar = bar::Bar::new(self)?;
Ok(bar)
}
}
impl Default for BarBuilder {
fn default() -> Self {
BarBuilder {
background_image: None,
background_color: Color::new(0, 0, 0, 255),
foreground_color: Color::new(255, 255, 255, 255),
output: None,
name: "leechbar".into(),
font: None,
height: 30,
text_yoffset: 0,
_new_lock: (),
}
}
}