mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
41 lines
2.1 KiB
Rust
41 lines
2.1 KiB
Rust
use crate::*;
|
|
pub struct PoolView<'a>(pub bool, pub &'a MidiPool);
|
|
content!(TuiOut: |self: PoolView<'a>| {
|
|
let Self(compact, model) = self;
|
|
let MidiPool { clips, mode, .. } = self.1;
|
|
let color = self.1.clip().map(|c|c.read().unwrap().color).unwrap_or_else(||TuiTheme::g(32).into());
|
|
let on_bg = |x|x;//Bsp::b(Repeat(" "), Tui::bg(color.darkest.rgb, x));
|
|
let border = |x|x;//Outer(Style::default().fg(color.dark.rgb).bg(color.darkest.rgb)).enclose(x);
|
|
let iter = | |model.clips().clone().into_iter();
|
|
Tui::bg(Color::Reset, Fixed::y(clips.read().unwrap().len() as u16, on_bg(border(Map::new(iter, move|clip, i|{
|
|
let item_height = 1;
|
|
let item_offset = i as u16 * item_height;
|
|
let selected = i == model.clip_index();
|
|
let MidiClip { ref name, color, length, .. } = *clip.read().unwrap();
|
|
let bg = if selected { color.light.rgb } else { color.base.rgb };
|
|
let fg = color.lightest.rgb;
|
|
let name = if *compact { format!(" {i:>3}") } else { format!(" {i:>3} {name}") };
|
|
let length = if *compact { String::default() } else { format!("{length} ") };
|
|
Fixed::y(1, map_south(item_offset, item_height, Tui::bg(bg, lay!(
|
|
Fill::x(Align::w(Tui::fg(fg, Tui::bold(selected, name)))),
|
|
Fill::x(Align::e(Tui::fg(fg, Tui::bold(selected, length)))),
|
|
Fill::x(Align::w(When::new(selected, Tui::bold(true, Tui::fg(TuiTheme::g(255), "▶"))))),
|
|
Fill::x(Align::e(When::new(selected, Tui::bold(true, Tui::fg(TuiTheme::g(255), "◀"))))),
|
|
))))
|
|
})))))
|
|
});
|
|
content!(TuiOut: |self: ClipLength| {
|
|
let bars = ||self.bars_string();
|
|
let beats = ||self.beats_string();
|
|
let ticks = ||self.ticks_string();
|
|
match self.focus {
|
|
None =>
|
|
row!(" ", bars(), ".", beats(), ".", ticks()),
|
|
Some(ClipLengthFocus::Bar) =>
|
|
row!("[", bars(), "]", beats(), ".", ticks()),
|
|
Some(ClipLengthFocus::Beat) =>
|
|
row!(" ", bars(), "[", beats(), "]", ticks()),
|
|
Some(ClipLengthFocus::Tick) =>
|
|
row!(" ", bars(), ".", beats(), "[", ticks()),
|
|
}
|
|
});
|