wip: tui cleanup

This commit is contained in:
🪞👃🪞 2024-09-05 13:28:05 +03:00
parent df3dac183e
commit 14d619a10a
17 changed files with 345 additions and 306 deletions

View file

@ -11,9 +11,10 @@ pub struct Plugin {
}
handle!(Plugin |self, e| handle_keymap(self, e, KEYMAP_PLUGIN));
process!(Plugin = Plugin::process);
impl<'a> Render<TuiOutput<'a>, Rect> for Plugin {
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
let Rect { x, y, height, .. } = to.area;
impl Render<Tui> for Plugin {
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
let area = to.area();
let Rect { x, y, height, .. } = area;
let mut width = 20u16;
match &self.plugin {
Some(PluginKind::LV2(LV2Plugin { port_list, instance, .. })) => {
@ -35,7 +36,7 @@ impl<'a> Render<TuiOutput<'a>, Rect> for Plugin {
} else {
None
} ;
label.blit(to.buffer, x + 2, y + 1 + i as u16 - start as u16, style)?;
label.blit(to.buffer(), x + 2, y + 1 + i as u16 - start as u16, style)?;
} else {
break
}
@ -43,8 +44,8 @@ impl<'a> Render<TuiOutput<'a>, Rect> for Plugin {
},
_ => {}
};
draw_header(self, to.buffer, to.area.x, to.area.y, width)?;
Ok(Some(Rect { width, ..to.area }))
draw_header(self, to.buffer(), area.x, area.y, width)?;
Ok(Some(Rect { width, ..to.area() }))
}
}
@ -57,7 +58,7 @@ pub enum PluginKind {
VST3,
}
impl Plugin {
pub fn new_lv2 <T, U> (name: &str, path: &str) -> Usually<JackDevice<T, U>> {
pub fn new_lv2 <E> (name: &str, path: &str) -> Usually<JackDevice<E>> {
let plugin = LV2Plugin::new(path)?;
jack_from_lv2(name, &plugin.plugin)?
.run(|ports|Box::new(Self {