Add a vertical bar widget
Getty Ritter
5 years ago
57 | 57 |
match section["name"].as_str().ok_or(format_err!(""))? {
|
58 | 58 |
"box" => target.push(Box::new(w::SmallBox)),
|
59 | 59 |
"battery" => target.push(Box::new(w::Battery::new()?)),
|
| 60 |
"caesura" => target.push(Box::new(w::Caesura)),
|
60 | 61 |
"sep" => target = &mut conf.right,
|
61 | 62 |
"stdin" => target.push(Box::new(w::Stdin::new())),
|
62 | 63 |
"time" => target.push(Box::new(w::Time::new())),
|
63 | 64 |
_ => (),
|
64 | 65 |
}
|
65 | 66 |
}
|
| 67 |
|
66 | 68 |
if let Some(color) = table.get("background") {
|
67 | 69 |
conf.bg_color = color_from_hex(color.as_str().ok_or(format_err!("`background` not a str"))?)?;
|
68 | 70 |
}
|
92 | 92 |
}
|
93 | 93 |
}
|
94 | 94 |
|
| 95 |
pub struct Caesura;
|
95 | 96 |
|
| 97 |
impl Widget for Caesura {
|
| 98 |
fn draw(&self, d: &Drawing, loc: Located) -> i32 {
|
| 99 |
let x = loc.target_x(d, 1);
|
| 100 |
d.ctx.move_to(x, d.buffer);
|
| 101 |
d.ctx.line_to(x, d.size.ht as f64 - d.buffer);
|
| 102 |
d.ctx.stroke();
|
| 103 |
2
|
| 104 |
}
|
| 105 |
}
|
96 | 106 |
|
97 | 107 |
pub struct Battery {
|
98 | 108 |
file_list: Vec<std::path::PathBuf>,
|