diff --git a/src/device/chain/mod.rs b/src/device/chain/mod.rs index d4f2c9eb..b275ecb1 100644 --- a/src/device/chain/mod.rs +++ b/src/device/chain/mod.rs @@ -9,7 +9,8 @@ pub struct Chain { pub focused: bool, pub focus: usize, pub items: Vec>, - pub view: ChainView + pub view: ChainView, + pub adding: bool, } pub enum ChainView { @@ -26,7 +27,8 @@ impl Chain { focused: false, focus: 0, items: items.unwrap_or_else(||vec![]), - view: ChainView::Column + view: ChainView::Column, + adding: false })) } } @@ -61,7 +63,7 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect) } else { Style::default().green().dim() }); - Ok(match state.view { + let result = match state.view { ChainView::Hidden => Rect { x, y, width: 0, height: 0 }, ChainView::Compact => { let area = Rect { x, y, width: (state.name.len() + 4) as u16, height: 3 }; @@ -76,45 +78,8 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect) ChainView::Column => { draw_as_column(state, buf, area, selected)? }, - }) - //let area = Rect { x, y, width: 40, height: 30 }; - //let mut y = area.y; - //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, "Input...", Style::default().dim()); - //let mut x = 0u16; - //for (i, device) in state.items.iter().enumerate() { - //let result = device.render(buf, Rect { - //x: area.x, - //y, - //width: area.width, - //height: 21//area.height.saturating_sub(y) - //})?; - //if i == state.focus { - //if state.focused { - //draw_box_styled(buf, result, Some(Style::default().green().not_dim())) - //} else { - //draw_box_styled_dotted(buf, result, Some(Style::default().green().dim())) - //}; - //}; - ////let result = Rect { x: 0, y: 0, width: result.width, height: 21 }; - //x = x.max(result.width); - //y = y + result.height; - ////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()); - //y = y + 1; - ////buf.set_string(area.x, y, format!("{y}---BOT---"), Style::default().red()); - ////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(draw_box(buf, Rect { - //x: area.x, - //y: area.y, - //width: area.width, - //height: y - area.y, - //})) + }; + Ok(result) } pub fn draw_as_row ( @@ -124,7 +89,7 @@ pub fn draw_as_row ( let mut h = 0u16; let mut frames = vec![]; for (i, device) in state.items.iter().enumerate() { - let mut x2 = 1u16; + let mut x2 = 0u16; let mut y2 = 1u16; //for port in device.midi_ins()?.iter() { //port.blit(buf, x, y + y2, Some(Style::default())); @@ -170,6 +135,44 @@ pub fn draw_as_row ( pub fn draw_as_column ( state: &Chain, buf: &mut Buffer, area: Rect, selected: Option