use crate::*; use tek_core::Direction; impl<'a> Render for Track { fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps { TrackView { chain: Some(&self), direction: tek_core::Direction::Right, focused: true, entered: true, //pub channels: u8, //pub input_ports: Vec>, //pub pre_gain_meter: f64, //pub gain: f64, //pub insert_ports: Vec>, //pub return_ports: Vec>, //pub post_gain_meter: f64, //pub post_insert_meter: f64, //pub level: f64, //pub pan: f64, //pub output_ports: Vec>, //pub post_fader_meter: f64, //pub route: String, }.render(to) } } pub struct TrackView<'a, T, U> { pub chain: Option<&'a Track>, pub direction: Direction, pub focused: bool, pub entered: bool, } impl<'a> Render for TrackView<'a, Tui> { fn render (&self, to: &mut Tui) -> Perhaps { let mut area = to.area(); if let Some(chain) = self.chain { match self.direction { Direction::Down => area.width = area.width.min(40), Direction::Right => area.width = area.width.min(10), _ => { unimplemented!() }, } to.fill_bg(to.area(), Nord::bg_lo(self.focused, self.entered)); let mut split = Split::new(self.direction); for device in chain.devices.as_slice().iter() { split = split.add_ref(device); } let (area, areas) = split.render_areas(to)?; if self.focused && self.entered && areas.len() > 0 { Corners(Style::default().green().not_dim()).draw(to.buffer, areas[0])?; } Ok(Some(area)) } else { let Rect { x, y, width, height } = area; let label = "No chain selected"; let x = x + (width - label.len() as u16) / 2; let y = y + height / 2; label.blit(to.buffer(), x, y, Some(Style::default().dim().bold()))?; Ok(Some(area)) } } }