This commit is contained in:
🪞👃🪞 2024-07-03 15:33:48 +03:00
parent 8c3cf53c67
commit ea529b7734
5 changed files with 91 additions and 91 deletions

View file

@ -16,21 +16,67 @@ pub struct ChainView<'a> {
impl<'a> Render for ChainView<'a> {
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
let style = Some(Style::default().green().dim());
if self.focused {
let Rect { x, y, width, height} = area;
lozenge_left(buf, x, y, height, style);
lozenge_right(buf, x + width - 1, y, height, style);
};
let style = Some(if self.focused {
Style::default().green()
} else {
Style::default().green().dim()
});
let (area, _plugins) = if let Some(ref chain) = self.chain {
draw_as_row(&*chain, buf, area, style)?
} else {
(area, vec![])
};
let Rect { x, y, width, height} = area;
lozenge_left(buf, x, y, height, style);
lozenge_right(buf, x + width - 1, y, height, style);
Ok(area)
}
}
pub fn draw_as_row (
state: &Chain, buf: &mut Buffer, area: Rect, style: Option<Style>
) -> Usually<(Rect, Vec<Rect>)> {
let Rect { mut x, y, width, height } = area;
let mut h = 0u16;
let mut frames = vec![];
for (i, device) in state.items.iter().enumerate() {
let x2 = 0u16;
let _y2 = 1u16;
//for port in device.midi_ins()?.iter() {
//port.blit(buf, x, y + y2, Some(Style::default()));
//x2 = x2.max(port.len() as u16);
//y2 = y2 + 1;
//}
//for port in device.audio_ins()?.iter() {
//port.blit(buf, x, y + y2, Some(Style::default()));
//x2 = x2.max(port.len() as u16);
//y2 = y2 + 1;
//}
let width = width.saturating_sub(x).saturating_sub(x2);
let frame = device.render(buf, Rect { x: x + x2, y, width, height })?;
lozenge_left(buf, x + x2, y, frame.height, style);
lozenge_right(buf, x + x2 + frame.width - 1, y, frame.height, style);
//let mut y2 = 1u16;
//for port in device.midi_outs()?.iter() {
//port.blit(buf, x + x2 + frame.width, y + y2, Some(Style::default()));
//x2 = x2.max(port.len() as u16);
//y2 = y2 + 1;
//}
//for port in device.audio_outs()?.iter() {
//port.blit(buf, x + x2 + frame.width, y + y2, Some(Style::default()));
//x2 = x2.max(port.len() as u16);
//y2 = y2 + 1;
//}
frames.push(frame);
h = h.max(frame.height);
x = x + frame.width;
}
let label = "[Add device…]";
label.blit(buf, x + 1, area.y + 1, Some(Style::default().dim()));
x = x + 1 + label.len() as u16 + 1;
Ok((Rect { x: area.x, y: area.y, width, height: h }, frames))
}
pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
-> Usually<Rect>
{
@ -59,56 +105,6 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
Ok(result)
}
pub fn draw_as_row (
state: &Chain, buf: &mut Buffer, area: Rect, _: Option<Style>
) -> Usually<(Rect, Vec<Rect>)> {
let Rect { mut x, y, width, height } = area;
let mut h = 0u16;
let mut frames = vec![];
for (i, device) in state.items.iter().enumerate() {
let x2 = 0u16;
let _y2 = 1u16;
//for port in device.midi_ins()?.iter() {
//port.blit(buf, x, y + y2, Some(Style::default()));
//x2 = x2.max(port.len() as u16);
//y2 = y2 + 1;
//}
//for port in device.audio_ins()?.iter() {
//port.blit(buf, x, y + y2, Some(Style::default()));
//x2 = x2.max(port.len() as u16);
//y2 = y2 + 1;
//}
let width = width.saturating_sub(x).saturating_sub(x2);
let style = Some(if i == state.focus {
if state.focused {
Style::default().green().not_dim()
} else {
Style::default().green().dim()
}
} else {
Style::default().dim()
});
lozenge_left(buf, x + x2, y, height, style);
let frame = device.render(buf, Rect { x: x + x2, y, width, height })?;
lozenge_right(buf, x + x2 + frame.width - 1, y, height, style);
//let mut y2 = 1u16;
//for port in device.midi_outs()?.iter() {
//port.blit(buf, x + x2 + frame.width, y + y2, Some(Style::default()));
//x2 = x2.max(port.len() as u16);
//y2 = y2 + 1;
//}
//for port in device.audio_outs()?.iter() {
//port.blit(buf, x + x2 + frame.width, y + y2, Some(Style::default()));
//x2 = x2.max(port.len() as u16);
//y2 = y2 + 1;
//}
frames.push(frame);
h = h.max(frame.height);
x = x + frame.width;
}
Ok((Rect { x: area.x, y: area.y, width, height: h }, frames))
}
pub fn draw_as_column (
state: &Chain, buf: &mut Buffer, area: Rect, selected: Option<Style>
) -> Usually<Rect> {

View file

@ -64,7 +64,7 @@ impl<'a> SceneGridView<'a> {
let w = (title.len() as u16).max(10) + 3;
x = x + w;
}
"Add track…".blit(self.buf, x + 2, y, Some(Style::default().dim()));
"[C-t] Add track…".blit(self.buf, x + 2, y + 1, Some(Style::default().dim()));
Ok(self.area)
}
@ -100,7 +100,7 @@ impl<'a> SceneGridView<'a> {
}
let hi = (0 == self.cursor.0) &&
(self.scenes.len() + 1 == self.cursor.1);
"Add scene…".blit(self.buf, x, y + index as u16, Some(if hi {
"[Add scene…]".blit(self.buf, x, y + index as u16, Some(if hi {
self.highlight(true)
} else {
Style::default().dim()
@ -130,7 +130,7 @@ impl<'a> SceneGridView<'a> {
format!("????")
}
} else {
format!(" ·········")
format!(" ·········")
};
label.blit(self.buf, x, y + index, style);
}
@ -138,7 +138,7 @@ impl<'a> SceneGridView<'a> {
}
let hi = (track + 1 == self.cursor.0) &&
(self.scenes.len() + 1 == self.cursor.1);
" + Add clip".blit(self.buf, x, y + index as u16, Some(if hi {
"[Add clip…]".blit(self.buf, x, y + index as u16, Some(if hi {
self.highlight(true)
} else {
Style::default().dim()