This commit is contained in:
🪞👃🪞 2024-06-29 22:06:53 +03:00
parent 3886e34519
commit de2e2a2124
7 changed files with 119 additions and 65 deletions

View file

@ -168,43 +168,34 @@ impl PortList for Plugin {
pub fn render (state: &Plugin, buf: &mut Buffer, area: Rect)
-> Usually<Rect>
{
let Rect { x, y, width, height } = area;
let height = height.saturating_sub(3);
let style = Style::default().gray();
let Rect { x, y, height, .. } = area;
let mut width = 40u16;
match &state.plugin {
Some(PluginKind::LV2 { portList, instance, .. }) => {
for i in 0..height - 4 {
Some(PluginKind::LV2 { portList, .. }) => {
//draw_box(buf, Rect { x, y, width, height });
for i in 0..height-3 {
if let Some(port) = portList.get(i as usize) {
let label = &format!("C·· M·· {:25} = {:03}", port.name, port.default_value);
width = width.max(label.len() as u16);
label.blit(buf, x + 2, y + 3 + i as u16, None);
label.blit(buf, x + 2, y + 2 + i as u16, None);
} else {
break
}
}
draw_box(buf, Rect { x, y, width, height });
},
_ => {
buf.set_string(x + 1, y + 3, &format!(" Parameter 1 0.0"), style);
buf.set_string(x + 1, y + 4, &format!(" Parameter 2 0.0"), style);
buf.set_string(x + 1, y + 5, &format!(" Parameter 3 0.0"), style);
buf.set_string(x + 1, y + 6, &format!(" Parameter 4 0.0"), style);
}
_ => {}
};
draw_header(state, buf, area.x, area.y, width);
draw_header(state, buf, area.x, area.y, width)?;
Ok(Rect { width, ..area })
}
fn draw_header (state: &Plugin, buf: &mut Buffer, x: u16, y: u16, w: u16) -> Usually<Rect> {
let style = Style::default().gray();
buf.set_string(x + 1, y + 1,
&format!(" {}", state.name), style.white().bold());
buf.set_string(x + 13, y + 1,
&format!("{}...", &HELM[..(w as usize - 20).min(HELM.len())]), style.not_dim());
buf.set_string(x + 0, y + 2,
&format!("{}", "-".repeat(w as usize - 2)), style.dim());
Ok(Rect { x, y, width: w, height: 3 })
let style = Style::default().gray();
let label1 = format!(" {}", state.name);
label1.blit(buf, x + 1, y, Some(style.white().bold()));
let label2 = format!("{}", &HELM[..(w as usize - 10).min(HELM.len())]);
label2.blit(buf, x + 2 + label1.len() as u16, y, Some(style.not_dim()));
Ok(Rect { x, y, width: w, height: 1 })
}
pub fn handle (s: &mut Plugin, event: &AppEvent) -> Usually<bool> {