fix transport display

This commit is contained in:
🪞👃🪞 2024-07-11 17:38:50 +03:00
parent 888ed642d0
commit a39e694a3e
2 changed files with 22 additions and 15 deletions

View file

@ -60,7 +60,7 @@ impl<'a> ArrangerView<'a> {
Color::Reset Color::Reset
}); });
if self.focused && self.entered { if self.focused && self.entered {
QuarterV(Style::default().green().dim()).draw(buf, Rect { x, y, width, height }); QuarterV(Style::default().green().dim()).draw(buf, Rect { x, y, width, height })?;
//lozenge_left(buf, x, y, height, style); //lozenge_left(buf, x, y, height, style);
//lozenge_right(buf, x + width - 1, y, height, style); //lozenge_right(buf, x + width - 1, y, height, style);
} }
@ -78,11 +78,8 @@ impl<'a> ArrangerView<'a> {
break break
} }
if focus_column { if focus_column {
fill_bg( let bg_area = Rect { x: x2, y, width: *w, height };
buf, fill_bg(buf, bg_area, bg_color);
Rect { x: x2, y, width: *w, height },
bg_color
);
} }
x2 = x2 + w; x2 = x2 + w;
} }

View file

@ -34,6 +34,7 @@ render!(TransportView |self, buf, area| {
fill_bg(buf, Rect { fill_bg(buf, Rect {
x, y, width, height: if width > 100 { 1 } else { 2 } x, y, width, height: if width > 100 { 1 } else { 2 }
}, Color::Rgb(20, 45, 5)); }, Color::Rgb(20, 45, 5));
let style = Style::default().not_dim();
let mut area = Split::right([ let mut area = Split::right([
// Play/Pause button // Play/Pause button
@ -79,26 +80,35 @@ render!(TransportView |self, buf, area| {
})) }))
}, },
// Time settings // Beats per minute
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{ &|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
let style = Style::default().not_dim();
"BPM".blit(buf, x, y, Some(style))?; "BPM".blit(buf, x, y, Some(style))?;
format!("{}.{:03}", bpm, bpm % 1).blit(buf, x + 4, y, Some(style.bold()))?; format!("{}.{:03}", bpm, bpm % 1).blit(buf, x + 4, y, Some(style.bold()))?;
"SYNC".blit(buf, x + 13, y, Some(style))?; Ok(Rect { x, y, width: 13, height: 1 })
"4/4".blit(buf, x + 18, y, Some(style.bold()))?; },
"QUANT".blit(buf, x + 23, y, Some(style))?;
ppq_to_name(*quant).blit(buf, x + 29, y, Some(style.bold()))?; // Quantization
Ok(Rect { x, y, width: 40, height: 1 }) &|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"QUANT".blit(buf, x, y, Some(style))?;
ppq_to_name(*quant).blit(buf, x + 6, y, Some(style.bold()))?;
Ok(Rect { x, y, width: 12, height: 1 })
},
// Clip launch sync
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"SYNC".blit(buf, x, y, Some(style))?;
"4/4".blit(buf, x + 5, y, Some(style.bold()))?;
Ok(Rect { x, y, width: 12, height: 1 })
}, },
// Clock // Clock
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{ &|buf: &mut Buffer, Rect { x, y, width, .. }: Rect|{
let (beats, pulses) = (pulse / ppq, pulse % ppq); let (beats, pulses) = (pulse / ppq, pulse % ppq);
let (bars, beats) = ((beats / 4) + 1, (beats % 4) + 1); let (bars, beats) = ((beats / 4) + 1, (beats % 4) + 1);
let (seconds, msecs) = (usecs / 1000000, usecs / 1000 % 1000); let (seconds, msecs) = (usecs / 1000000, usecs / 1000 % 1000);
let (minutes, seconds) = (seconds / 60, seconds % 60); let (minutes, seconds) = (seconds / 60, seconds % 60);
let timer = format!("{minutes}:{seconds:02}:{msecs:03} {bars}.{beats}.{pulses:02}"); let timer = format!("{minutes}:{seconds:02}:{msecs:03} {bars}.{beats}.{pulses:02}");
timer.blit(buf, x - timer.len() as u16, y, Some(Style::default().not_dim())) timer.blit(buf, x + width - timer.len() as u16 - 1, y, Some(Style::default().not_dim()))
} }
]).render(buf, area)?; ]).render(buf, area)?;