use crate::*; use tek_core::Direction; render!(Track |self, buf, area| 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(buf, area)); pub struct TrackView<'a> { pub chain: Option<&'a Track>, pub direction: Direction, pub focused: bool, pub entered: bool, } impl<'a> Render for TrackView<'a> { fn render (&self, buf: &mut Buffer, mut area: Rect) -> Usually { 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!() }, } fill_bg(buf, area, Nord::bg_lo(self.focused, self.entered)); let devices: Vec<&(dyn Render + Send + Sync)> = chain.devices.as_slice() .iter() .map(|d|d as &(dyn Render + Send + Sync)) .collect(); let (area, areas) = self.direction .split_focus(0, devices.as_slice(), if self.focused { Style::default().green().dim() } else { Style::default().dim() }) .render_areas(buf, area)?; if self.focused && self.entered && areas.len() > 0 { Corners(Style::default().green().not_dim()).draw(buf, areas[0])?; } Ok(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(buf, x, y, Some(Style::default().dim().bold()))?; Ok(area) } } }