and it once again compiles

This commit is contained in:
🪞👃🪞 2024-08-09 21:59:14 +03:00
parent 6dd4caeb42
commit 430c51e305
31 changed files with 466 additions and 694 deletions

View file

@ -0,0 +1,43 @@
use crate::*;
use tek_core::Direction;
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<Rect> {
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),
}
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)
}
}
}