mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
lanes and grids
This commit is contained in:
parent
788dc1ccde
commit
ac865824cc
12 changed files with 213 additions and 112 deletions
|
|
@ -5,18 +5,23 @@ pub struct Rows(pub Vec<Box<dyn Device>>);
|
|||
pub struct Columns(pub Vec<Box<dyn Device>>);
|
||||
|
||||
impl Device for Rows {
|
||||
fn handle (&mut self, event: &EngineEvent) -> Result<(), Box<dyn Error>> {
|
||||
fn handle (&mut self, event: &EngineEvent) -> Usually<()> {
|
||||
Ok(())
|
||||
}
|
||||
fn render (&self, buf: &mut Buffer, area: Rect) {
|
||||
for i in 0..3 {
|
||||
self.0[i].render(buf, Rect {
|
||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<(u16, u16)> {
|
||||
let mut x = 0u16;
|
||||
let mut y = 0u16;
|
||||
for device in self.0.iter() {
|
||||
let (w, h) = device.render(buf, Rect {
|
||||
x: area.x,
|
||||
y: area.height / 3 * i as u16,
|
||||
y: area.y + y,
|
||||
width: area.width,
|
||||
height: area.height / 3
|
||||
})
|
||||
height: area.height - y
|
||||
})?;
|
||||
x = x.max(w);
|
||||
y = y + h;
|
||||
}
|
||||
Ok((x, y))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -24,14 +29,19 @@ impl Device for Columns {
|
|||
fn handle (&mut self, event: &EngineEvent) -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
fn render (&self, buf: &mut Buffer, area: Rect) {
|
||||
for i in 0..3 {
|
||||
self.0[i].render(buf, Rect {
|
||||
x: area.width / 3 * i as u16,
|
||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<(u16, u16)> {
|
||||
let mut x = 0u16;
|
||||
let mut y = 0u16;
|
||||
for device in self.0.iter() {
|
||||
let (w, h) = device.render(buf, Rect {
|
||||
x: area.x + x,
|
||||
y: area.y,
|
||||
width: area.width / 3,
|
||||
width: area.width - x,
|
||||
height: area.height
|
||||
})
|
||||
})?;
|
||||
x = x + w;
|
||||
y = y.max(h);
|
||||
}
|
||||
Ok((x, y))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue