mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
61 lines
2.3 KiB
Rust
61 lines
2.3 KiB
Rust
use crate::*;
|
|
use tek_core::Direction;
|
|
|
|
impl<'a> Render<Tui> for Track<Tui> {
|
|
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
|
TrackView {
|
|
chain: Some(&self),
|
|
direction: tek_core::Direction::Right,
|
|
focused: true,
|
|
entered: true,
|
|
//pub channels: u8,
|
|
//pub input_ports: Vec<Port<AudioIn>>,
|
|
//pub pre_gain_meter: f64,
|
|
//pub gain: f64,
|
|
//pub insert_ports: Vec<Port<AudioOut>>,
|
|
//pub return_ports: Vec<Port<AudioIn>>,
|
|
//pub post_gain_meter: f64,
|
|
//pub post_insert_meter: f64,
|
|
//pub level: f64,
|
|
//pub pan: f64,
|
|
//pub output_ports: Vec<Port<AudioOut>>,
|
|
//pub post_fader_meter: f64,
|
|
//pub route: String,
|
|
}.render(to)
|
|
}
|
|
}
|
|
pub struct TrackView<'a, T, U> {
|
|
pub chain: Option<&'a Track<T, U>>,
|
|
pub direction: Direction,
|
|
pub focused: bool,
|
|
pub entered: bool,
|
|
}
|
|
impl<'a> Render<Tui> for TrackView<'a, Tui> {
|
|
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
|
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))
|
|
}
|
|
}
|
|
}
|