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
});
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_right(buf, x + width - 1, y, height, style);
}
@ -78,11 +78,8 @@ impl<'a> ArrangerView<'a> {
break
}
if focus_column {
fill_bg(
buf,
Rect { x: x2, y, width: *w, height },
bg_color
);
let bg_area = Rect { x: x2, y, width: *w, height };
fill_bg(buf, bg_area, bg_color);
}
x2 = x2 + w;
}

View file

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