wip: layout

This commit is contained in:
🪞👃🪞 2024-06-12 23:21:56 +03:00
parent ac865824cc
commit d627d257ad
13 changed files with 220 additions and 131 deletions

View file

@ -15,7 +15,7 @@ impl Chain {
}
pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
-> Usually<(u16, u16)>
-> Usually<Rect>
{
let Rect { x, y, width, height } = area;
let area = Rect { x, y, width: 40, height: 30 };
@ -26,25 +26,25 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
let mut x = 0u16;
y = y + 1;
for device in state.devices.iter() {
let (w, h) = device.render(buf, Rect {
let result = device.render(buf, Rect {
x: area.x,
y: area.y + y,
width: area.width,
height: area.height - y
height: area.height.saturating_sub(y)
})?;
//buf.set_string(area.x, y, format!("{y}---TOP---+{h}"), Style::default().red());
x = x.max(w);
y = y + h;
x = x.max(result.width);
y = y + result.height;
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());
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))
Ok(Rect { x: area.x, y: area.y, width: x, height: y })
}
pub fn handle (state: &mut Chain, event: &EngineEvent) -> Result<(), Box<dyn Error>> {