fix sampler alignment

This commit is contained in:
🪞👃🪞 2025-01-02 14:59:26 +01:00
parent ddff9b3a60
commit 6663f4efcb

View file

@ -135,7 +135,7 @@ render!(Tui: (self: Groovebox) => {
Bsp::w(
Fixed::x(pool_w, Align::e(Fill::y(PoolView(&self.pool)))),
Fill::xy(Bsp::e(
Align::w(Fixed::x(sampler_w, Fill::xy(GrooveboxSamples(self)))),
Fixed::x(sampler_w, Align::w(Fill::y(GrooveboxSamples(self)))),
Bsp::s(
Fill::x(Align::c(Bsp::e(
PhraseSelector::play_phrase(&self.player),
@ -158,8 +158,7 @@ render!(Tui: (self: GrooveboxSamples<'a>) => {
let note_lo = self.0.editor.note_lo().load(Relaxed);
let note_pt = self.0.editor.note_point();
let note_hi = self.0.editor.note_hi();
let range = move||(note_lo..=note_hi).rev();
Fill::xy(Tui::map(range, move|note, i| {
Fill::xy(Tui::map(move||(note_lo..=note_hi).rev(), move|note, i| {
let mut bg = if note == note_pt { TuiTheme::g(64) } else { Color::Reset };
let mut fg = TuiTheme::g(160);
if let Some((index, _)) = self.0.sampler.recording {
@ -170,7 +169,8 @@ render!(Tui: (self: GrooveboxSamples<'a>) => {
} else if self.0.sampler.mapped[note].is_some() {
fg = TuiTheme::g(224);
}
Push::y(i as u16, Tui::bg(bg, if let Some(sample) = &self.0.sampler.mapped[note] {
let offset = |a|Push::y(i as u16, Align::n(Fixed::y(1, Fill::x(a))));
offset(Tui::bg(bg, if let Some(sample) = &self.0.sampler.mapped[note] {
Tui::fg(fg, format!("{note:3} ?????? "))
} else {
Tui::fg(fg, format!("{note:3} (none) "))