Sharpen up layout
This commit is contained in:
+3
-3
@@ -114,13 +114,13 @@ impl ModuleImpl for Backlight {
|
||||
"backlight",
|
||||
)?;
|
||||
draw_bar(
|
||||
&mut buf.subdimensions((128, 0, 432, 24))?,
|
||||
&mut buf.subdimensions((128, 0, 464, 24))?,
|
||||
&c,
|
||||
432,
|
||||
464,
|
||||
24,
|
||||
self.brightness(),
|
||||
)?;
|
||||
draw_box(&mut buf.subdimensions((128, 0, 432, 24))?, &c, (432, 24))?;
|
||||
draw_box(&mut buf.subdimensions((128, 0, 464, 24))?, &c, (464, 24))?;
|
||||
Ok(vec![buf.get_signed_bounds()])
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -213,17 +213,17 @@ impl ModuleImpl for UpowerBattery {
|
||||
"battery",
|
||||
)?;
|
||||
draw_bar(
|
||||
&mut buf.subdimensions((128, 0, 432, 24))?,
|
||||
&mut buf.subdimensions((128, 0, 464, 24))?,
|
||||
&bar_color,
|
||||
432,
|
||||
464,
|
||||
24,
|
||||
(inner.capacity as f32) / 100.0,
|
||||
)?;
|
||||
|
||||
draw_box(
|
||||
&mut buf.subdimensions((128, 0, 432, 24))?,
|
||||
&mut buf.subdimensions((128, 0, 464, 24))?,
|
||||
&bar_color,
|
||||
(432, 24),
|
||||
(464, 24),
|
||||
)?;
|
||||
Ok(vec![buf.get_signed_bounds()])
|
||||
}
|
||||
|
||||
+7
-7
@@ -79,7 +79,7 @@ impl Calendar {
|
||||
};
|
||||
|
||||
self.day_cache.draw_text(
|
||||
&mut buf.subdimensions((idx * 48 + 4, (y_off * 32) + 64, 32, 16))?,
|
||||
&mut buf.subdimensions((idx * 48 + 4, (y_off * 32) + 64, 24, 16))?,
|
||||
background_color,
|
||||
&Color::new(1.0, 1.0, 1.0, 1.0),
|
||||
&wk_chr,
|
||||
@@ -105,7 +105,7 @@ impl Calendar {
|
||||
//
|
||||
let wk = time.iso_week();
|
||||
self.calendar_cache.draw_text(
|
||||
&mut buf.subdimensions((0 * 48, (y_off * 32) + 64, 38, 32))?,
|
||||
&mut buf.subdimensions((0 * 48, (y_off * 32) + 64, 32, 32))?,
|
||||
background_color,
|
||||
&Color::new(0.75, 0.75, 0.75, 1.0),
|
||||
&format!("{:02}", wk.week()),
|
||||
@@ -123,11 +123,12 @@ impl Calendar {
|
||||
};
|
||||
|
||||
self.calendar_cache.draw_text(
|
||||
&mut buf.subdimensions((x_pos * 48, (y_off * 32) + 64, 38, 32))?,
|
||||
&mut buf.subdimensions((x_pos * 48, (y_off * 32) + 64, 32, 32))?,
|
||||
background_color,
|
||||
&c,
|
||||
&format!("{:02}", time.day()),
|
||||
)?;
|
||||
|
||||
let t = time.with_day(time.day() + 1);
|
||||
if t.is_none() {
|
||||
done = true;
|
||||
@@ -139,7 +140,6 @@ impl Calendar {
|
||||
|
||||
y_off += 1;
|
||||
}
|
||||
|
||||
Ok(buf.get_signed_bounds())
|
||||
}
|
||||
}
|
||||
@@ -195,13 +195,13 @@ impl ModuleImpl for Calendar {
|
||||
.unwrap();
|
||||
}
|
||||
self.draw_month(
|
||||
&mut buf.subdimensions((0, 0, 384, 344))?,
|
||||
&mut buf.subdimensions((0, 0, 368, 320))?,
|
||||
background_color,
|
||||
&time,
|
||||
&t.pred().with_day(1).unwrap(),
|
||||
)?;
|
||||
self.draw_month(
|
||||
&mut buf.subdimensions((448, 0, 384, 344))?,
|
||||
&mut buf.subdimensions((432, 0, 368, 320))?,
|
||||
background_color,
|
||||
&time,
|
||||
&t,
|
||||
@@ -212,7 +212,7 @@ impl ModuleImpl for Calendar {
|
||||
t.with_month(t.month() + 1).unwrap()
|
||||
};
|
||||
self.draw_month(
|
||||
&mut buf.subdimensions((896, 0, 384, 344))?,
|
||||
&mut buf.subdimensions((864, 0, 368, 320))?,
|
||||
background_color,
|
||||
&time,
|
||||
&n,
|
||||
|
||||
+3
-3
@@ -55,7 +55,7 @@ impl ModuleImpl for Clock {
|
||||
buf.memset(bg);
|
||||
|
||||
self.date_cache.draw_text(
|
||||
&mut buf.subdimensions((0, 0, 448, 64))?,
|
||||
&mut buf.subdimensions((0, 0, 240 * 2 + 56, 64))?,
|
||||
bg,
|
||||
&Color::new(1.0, 1.0, 1.0, 1.0),
|
||||
&format!(
|
||||
@@ -68,10 +68,10 @@ impl ModuleImpl for Clock {
|
||||
)?;
|
||||
|
||||
self.clock_cache.draw_text_fixed_width(
|
||||
&mut buf.subdimensions((0, 64, 288 * 2 + 64, 256))?,
|
||||
&mut buf.subdimensions((0, 64, 240 * 2 + 56, 256))?,
|
||||
bg,
|
||||
&Color::new(1.0, 1.0, 1.0, 1.0),
|
||||
&[120, 120, 64, 120, 120],
|
||||
&[120, 120, 56, 120, 120],
|
||||
&format!("{:02}:{:02}", time.hour(), time.minute()),
|
||||
)?;
|
||||
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ impl ModuleImpl for Launcher {
|
||||
)?;
|
||||
|
||||
let mut x_off: i32 = 0;
|
||||
let mut width_remaining: i32 = 1280 - 64;
|
||||
let mut width_remaining: i32 = 1232 - 64;
|
||||
if self.matches.len() == 0 && self.cur.len() > 0 {
|
||||
self.font.borrow_mut().auto_draw_text(
|
||||
&mut buf
|
||||
|
||||
+6
-6
@@ -154,25 +154,25 @@ impl App {
|
||||
let (mod_tx, mod_rx) = channel();
|
||||
std::thread::spawn(move || {
|
||||
let mut modules = vec![
|
||||
Module::new(Box::new(Clock::new(tx.clone())), (0, 0, 720, 320)),
|
||||
Module::new(Box::new(Calendar::new()), (0, 368, 1280, 344)),
|
||||
Module::new(Box::new(Clock::new(tx.clone())), (0, 0, 536, 320)),
|
||||
Module::new(Box::new(Calendar::new()), (0, 368, 1232, 344)),
|
||||
];
|
||||
|
||||
if let Ok(m) = Launcher::new() {
|
||||
modules.push(Module::new(Box::new(m), (0, 768, 1280, 32)));
|
||||
modules.push(Module::new(Box::new(m), (0, 728, 1232, 32)));
|
||||
}
|
||||
|
||||
let mut vert_off = 0;
|
||||
if let Ok(m) = UpowerBattery::new(tx.clone()) {
|
||||
modules.push(Module::new(Box::new(m), (720, vert_off, 560, 32)));
|
||||
modules.push(Module::new(Box::new(m), (640, vert_off, 592, 32)));
|
||||
vert_off += 32;
|
||||
}
|
||||
if let Ok(m) = Backlight::new() {
|
||||
modules.push(Module::new(Box::new(m), (720, vert_off, 560, 32)));
|
||||
modules.push(Module::new(Box::new(m), (640, vert_off, 592, 32)));
|
||||
vert_off += 32;
|
||||
}
|
||||
if let Ok(m) = PulseAudio::new(tx.clone()) {
|
||||
modules.push(Module::new(Box::new(m), (720, vert_off, 560, 32)));
|
||||
modules.push(Module::new(Box::new(m), (640, vert_off, 592, 32)));
|
||||
}
|
||||
|
||||
mod_tx.send(modules).unwrap();
|
||||
|
||||
+3
-3
@@ -446,15 +446,15 @@ impl ModuleImpl for PulseAudio {
|
||||
&Color::new(1.0, 1.0, 1.0, 1.0),
|
||||
"volume",
|
||||
)?;
|
||||
draw_bar(&mut buf.subdimensions((128, 0, 432, 24))?, &c, 432, 24, vol)?;
|
||||
draw_bar(&mut buf.subdimensions((128, 0, 464, 24))?, &c, 464, 24, vol)?;
|
||||
let mut iter = 1.0;
|
||||
while vol > 1.0 {
|
||||
let c = &Color::new(0.75 / iter, 0.25 / iter, 0.25 / iter, 1.0);
|
||||
vol -= 1.0;
|
||||
iter += 1.0;
|
||||
draw_bar(&mut buf.subdimensions((128, 0, 432, 24))?, &c, 432, 24, vol)?;
|
||||
draw_bar(&mut buf.subdimensions((128, 0, 464, 24))?, &c, 464, 24, vol)?;
|
||||
}
|
||||
draw_box(&mut buf.subdimensions((128, 0, 432, 24))?, &c, (432, 24))?;
|
||||
draw_box(&mut buf.subdimensions((128, 0, 464, 24))?, &c, (464, 24))?;
|
||||
Ok(vec![buf.get_signed_bounds()])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user