control transport values

This commit is contained in:
🪞👃🪞 2024-07-12 16:56:19 +03:00
parent 33e5f47526
commit 45021bc77a
10 changed files with 168 additions and 86 deletions

View file

@ -11,9 +11,9 @@ render!(TransportToolbar |self, buf, area| {
let bpm = self.bpm();
let pulse = self.pulse();
let usecs = self.usecs();
let Self { quant, focused, entered, .. } = self;
let Self { quant, sync, focused, entered, .. } = self;
fill_bg(buf, area, Nord::bg_lo(*focused, *entered));
let area = Split::right([
Split::right([
// Play/Pause button
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
@ -38,21 +38,33 @@ render!(TransportToolbar |self, buf, area| {
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"BPM".blit(buf, x, y, Some(not_dim))?;
let width = format!("{}.{:03}", bpm, bpm % 1).blit(buf, x, y + 1, Some(not_dim_bold))?.width;
Ok(Rect { x, y, width: (width + 2).max(10), height: 2 })
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
if self.focused && self.entered && self.selected == TransportFocus::BPM {
Corners(Style::default().green().not_dim()).draw(buf, Rect { x: area.x - 1, ..area })?;
}
Ok(area)
},
// Quantization
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"QUANT".blit(buf, x, y, Some(not_dim))?;
let width = ppq_to_name(*quant).blit(buf, x, y + 1, Some(not_dim_bold))?.width;
Ok(Rect { x, y, width: (width + 2).max(10), height: 2 })
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
if self.focused && self.entered && self.selected == TransportFocus::Quant {
Corners(Style::default().green().not_dim()).draw(buf, Rect { x: area.x - 1, ..area })?;
}
Ok(area)
},
// Clip launch sync
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"SYNC".blit(buf, x, y, Some(not_dim))?;
let width = "4/4".blit(buf, x, y + 1, Some(not_dim_bold))?.width;
Ok(Rect { x, y, width: (width + 2).max(10), height: 2 })
let width = ppq_to_name(*sync).blit(buf, x, y + 1, Some(not_dim_bold))?.width;
let area = Rect { x, y, width: (width + 2).max(10), height: 2 };
if self.focused && self.entered && self.selected == TransportFocus::Sync {
Corners(Style::default().green().not_dim()).draw(buf, Rect { x: area.x - 1, ..area })?;
}
Ok(area)
},
// Clock
@ -65,13 +77,7 @@ render!(TransportToolbar |self, buf, area| {
timer.blit(buf, x + width - timer.len() as u16 - 1, y, Some(not_dim))
}
]).render(buf, area)?;
Ok(if *focused && *entered {
Corners(Style::default().green().not_dim()).draw(buf, area)?
} else {
area
})
]).render(buf, area)
});
// Record button/indicator