unified compact flag in groovebox

This commit is contained in:
🪞👃🪞 2025-01-02 18:40:29 +01:00
parent c9a79b1f29
commit 511ff91864
12 changed files with 129 additions and 188 deletions

View file

@ -1,19 +1,26 @@
use crate::*;
pub struct SampleList<'a>(&'a Sampler, &'a MidiEditor);
pub struct SampleList<'a> {
compact: bool,
sampler: &'a Sampler,
editor: &'a MidiEditor
}
impl<'a> SampleList<'a> {
pub fn new (sampler: &'a Sampler, editor: &'a MidiEditor) -> Self {
Self(sampler, editor)
pub fn new (compact: bool, sampler: &'a Sampler, editor: &'a MidiEditor) -> Self {
Self { compact, sampler, editor }
}
}
render!(Tui: (self: SampleList<'a>) => {
let Self(sampler, editor) = self;
let Self { compact, sampler, editor } = self;
let note_lo = editor.note_lo().load(Relaxed);
let note_pt = editor.note_point();
let note_hi = editor.note_hi();
Fill::xy(Tui::map(move||(note_lo..=note_hi).rev(), move|note, i| {
let offset = |a|Push::y(i as u16, Align::n(Fixed::y(1, Fill::x(a))));
let mut bg = if note == note_pt { TuiTheme::g(64) } else { Color::Reset };
let mut fg = TuiTheme::g(160);
if let Some((index, _)) = sampler.recording {
@ -24,11 +31,14 @@ render!(Tui: (self: SampleList<'a>) => {
} else if sampler.mapped[note].is_some() {
fg = TuiTheme::g(224);
}
let offset = |a|Push::y(i as u16, Align::n(Fixed::y(1, Fill::x(a))));
offset(Tui::bg(bg, if let Some(sample) = &sampler.mapped[note] {
Tui::fg(fg, format!("{note:3} ?????? "))
offset(Tui::fg_bg(fg, bg, format!("{note:3} {}", if *compact {
""
} else if let Some(sample) = &sampler.mapped[note] {
"??????"
} else {
Tui::fg(fg, format!("{note:3} (none) "))
}))
"(none)"
})))
}))
});