mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
24 lines
1.2 KiB
Rust
24 lines
1.2 KiB
Rust
use crate::*;
|
|
|
|
pub struct PoolView<'a>(pub bool, pub &'a PoolModel);
|
|
render!(TuiOut: (self: PoolView<'a>) => {
|
|
let Self(compact, model) = self;
|
|
let PoolModel { phrases, mode, .. } = self.1;
|
|
let color = self.1.phrase().read().unwrap().color;
|
|
Outer(
|
|
Style::default().fg(color.dark.rgb).bg(color.darkest.rgb)
|
|
).enclose(Map(||model.phrases().iter(), |clip, i|{
|
|
let item_height = 1;
|
|
let item_offset = i as u16 * item_height;
|
|
let selected = i == model.phrase_index();
|
|
let MidiClip { ref name, color, length, .. } = *clip.read().unwrap();
|
|
let name = if *compact { format!(" {i:>3}") } else { format!(" {i:>3} {name}") };
|
|
let length = if *compact { String::default() } else { format!("{length} ") };
|
|
map_south(item_offset, item_height, Tui::bg(if selected { color.light.rgb } else { color.base.rgb }, lay!(
|
|
Align::w(Tui::fg(color.lightest.rgb, Tui::bold(selected, name))),
|
|
Align::e(Tui::fg(color.lightest.rgb, Tui::bold(selected, length))),
|
|
Align::w(When(selected, Tui::bold(true, Tui::fg(TuiTheme::g(255), "▶")))),
|
|
Align::e(When(selected, Tui::bold(true, Tui::fg(TuiTheme::g(255), "◀")))),
|
|
)))
|
|
}))
|
|
});
|