lanes and grids

This commit is contained in:
🪞👃🪞 2024-06-12 18:38:16 +03:00
parent 788dc1ccde
commit ac865824cc
12 changed files with 213 additions and 112 deletions

View file

@ -14,7 +14,38 @@ impl Chain {
}
}
pub fn render (state: &Chain, buf: &mut Buffer, area: Rect) {}
pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
-> Usually<(u16, u16)>
{
let Rect { x, y, width, height } = area;
let area = Rect { x, y, width: 40, height: 30 };
let mut y = area.y;
buf.set_string(area.x, y, "", Style::default().black());
buf.set_string(area.x + area.width - 1, y, "", Style::default().black());
buf.set_string(area.x + 2, y, "Input...", Style::default().dim());
let mut x = 0u16;
y = y + 1;
for device in state.devices.iter() {
let (w, h) = device.render(buf, Rect {
x: area.x,
y: area.y + y,
width: area.width,
height: area.height - y
})?;
//buf.set_string(area.x, y, format!("{y}---TOP---+{h}"), Style::default().red());
x = x.max(w);
y = y + h;
y = y + 1;
buf.set_string(area.x, y, "", Style::default().black());
buf.set_string(area.x + area.width - 1, y, "", Style::default().black());
buf.set_string(area.x + 2, y, "Patch in... │ Patch out...", Style::default().dim());
y = y + 1;
//buf.set_string(area.x, y, format!("{y}---BOT---"), Style::default().red());
//buf.set_string(area.x + area.width - 1, area.y + 1, "│", Style::default().black());
//buf.set_string(area.x + 2, y, "Patch...", Style::default().dim());
}
Ok((x, y))
}
pub fn handle (state: &mut Chain, event: &EngineEvent) -> Result<(), Box<dyn Error>> {
Ok(())