bye chain

This commit is contained in:
🪞👃🪞 2024-07-03 18:46:19 +03:00
parent 316fe45b2a
commit 2601592d17
8 changed files with 115 additions and 164 deletions

View file

@ -11,7 +11,7 @@ pub enum ChainViewMode {
pub struct ChainView<'a> {
pub focused: bool,
pub chain: Option<&'a Chain>,
pub chain: Option<&'a Track>,
}
impl<'a> Render for ChainView<'a> {
@ -34,12 +34,12 @@ impl<'a> Render for ChainView<'a> {
}
pub fn draw_as_row (
state: &Chain, buf: &mut Buffer, area: Rect, style: Option<Style>
state: &Track, buf: &mut Buffer, area: Rect, style: Option<Style>
) -> Usually<(Rect, Vec<Rect>)> {
let Rect { mut x, y, width, height } = area;
let mut h = 3u16;
let mut frames = vec![];
for (i, device) in state.items.iter().enumerate() {
for (i, device) in state.devices.iter().enumerate() {
let x2 = 0u16;
let _y2 = 1u16;
//for port in device.midi_ins()?.iter() {
@ -74,39 +74,11 @@ pub fn draw_as_row (
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>
{
let Rect { x, y, .. } = area;
let selected = Some(if state.focused {
Style::default().green().not_dim()
} else {
Style::default().green().dim()
});
let result = match state.view {
ChainViewMode::Hidden => Rect { x, y, width: 0, height: 0 },
ChainViewMode::Compact => {
let area = Rect { x, y, width: (state.name.len() + 4) as u16, height: 3 };
buf.set_string(area.x + 2, area.y + 1, &state.name, Style::default());
draw_box_styled(buf, area, selected)
},
ChainViewMode::Row => {
draw_box_styled(buf, area, selected);
let (area, _) = Row::draw(buf, area, &state.items, 0)?;
area
},
ChainViewMode::Column => {
draw_as_column(state, buf, area, selected)?
},
};
Ok(result)
Ok((Rect { x: area.x, y: area.y, width: x, height: h }, frames))
}
pub fn draw_as_column (
state: &Chain, buf: &mut Buffer, area: Rect, selected: Option<Style>
state: &Track, buf: &mut Buffer, area: Rect, selected: Option<Style>
) -> Usually<Rect> {
//let area = Rect { x, y, width: 40, height: 30 };
//let mut y = area.y;
@ -150,7 +122,7 @@ pub fn draw_as_column (
//let (area, areas) = Column::draw(buf, area, &state.items, 0)?;
let mut w = 0u16;
let mut frames = vec![];
for device in state.items.iter() {
for device in state.devices.iter() {
let style_midi = Style::default().black().bold().on_green();
let style_audio = Style::default().black().bold().on_red();
let midi_ins = device.midi_ins()?;
@ -185,6 +157,34 @@ pub fn draw_as_column (
y = y + 1;
}
}
draw_box_styled(buf, frames[state.focus], selected);
draw_box_styled(buf, frames[state.device], selected);
Ok(area)
}
//pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
//-> Usually<Rect>
//{
//let Rect { x, y, .. } = area;
//let selected = Some(if state.focused {
//Style::default().green().not_dim()
//} else {
//Style::default().green().dim()
//});
//let result = match state.view {
//ChainViewMode::Hidden => Rect { x, y, width: 0, height: 0 },
//ChainViewMode::Compact => {
//let area = Rect { x, y, width: (state.name.len() + 4) as u16, height: 3 };
//buf.set_string(area.x + 2, area.y + 1, &state.name, Style::default());
//draw_box_styled(buf, area, selected)
//},
//ChainViewMode::Row => {
//draw_box_styled(buf, area, selected);
//let (area, _) = Row::draw(buf, area, &state.items, 0)?;
//area
//},
//ChainViewMode::Column => {
//draw_as_column(state, buf, area, selected)?
//},
//};
//Ok(result)
//}