wip: vst2 host?

This commit is contained in:
🪞👃🪞 2024-06-20 20:12:26 +03:00
parent 228805d30d
commit 4b0055a21c
7 changed files with 151 additions and 42 deletions

View file

@ -2,14 +2,16 @@ use crate::prelude::*;
pub struct Chain {
name: String,
devices: Vec<Box<dyn Device>>
devices: Vec<Box<dyn Device>>,
focused: usize,
}
impl Chain {
pub fn new (name: &str, devices: Vec<Box<dyn Device>>) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
Ok(DynamicDevice::new(render, handle, process, Self {
name: name.into(),
devices
devices,
focused: 0
}))
}
}
@ -28,18 +30,17 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
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 result = device.render(buf, Rect {
x: area.x,
y: area.y + y,
y,
width: area.width,
height: area.height.saturating_sub(y)
height: 21//area.height.saturating_sub(y)
})?;
//buf.set_string(area.x, y, format!("{y}---TOP---+{h}"), Style::default().red());
//let result = Rect { x: 0, y: 0, width: result.width, height: 21 };
x = x.max(result.width);
y = y + result.height;
y = y + 1;
//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());
@ -48,7 +49,12 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
//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(Rect { x: area.x, y: area.y, width: x, height: y })
Ok(draw_box(buf, Rect {
x: area.x,
y: area.y,
width: area.width,
height: y - area.y,
}))
}
pub fn handle (_: &mut Chain, _: &AppEvent) -> Usually<bool> {