reenable inc/dec phrase

This commit is contained in:
🪞👃🪞 2024-07-11 21:32:12 +03:00
parent c3040cef1c
commit 2c8f4857dd
11 changed files with 217 additions and 585 deletions

View file

@ -4,7 +4,6 @@ pub struct TransportView {
pub record: bool,
pub overdub: bool,
pub monitor: bool,
pub frame: usize,
pub quant: usize,
pub ppq: usize,
pub bpm: usize,
@ -18,7 +17,6 @@ impl TransportView {
monitor: app.track().map(|t|t.1.monitoring).unwrap_or(false),
record: app.track().map(|t|t.1.recording).unwrap_or(false),
overdub: app.track().map(|t|t.1.overdub).unwrap_or(false),
frame: app.playhead,
quant: app.quant,
ppq: app.timebase.ppq() as usize,
bpm: app.timebase.bpm() as usize,
@ -28,14 +26,16 @@ impl TransportView {
}
}
render!(TransportView |self, buf, area| {
let Self { ppq, frame, bpm, quant, pulse, usecs, .. } = self;
let frame = *frame as f64;
let Rect { x, y, width, .. } = 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([
let mut area = area;
area.height = if area.width > 100 { 1 } else { 2 };
let Self { ppq, bpm, quant, pulse, usecs, .. } = self;
fill_bg(buf, area, Color::Rgb(20, 45, 5));
let dim = Style::default().dim();
let not_dim = Style::default().not_dim();
let red = not_dim.red();
let green = not_dim.green();
let yellow = not_dim.yellow();
Split::right([
// Play/Pause button
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
@ -55,49 +55,37 @@ render!(TransportView |self, buf, area| {
// Record button/indicator
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"⏺ REC".blit(buf, x, y, Some(if self.record {
Style::default().bold().red()
} else {
Style::default().bold().dim()
}))
"⏺ REC".blit(buf, x, y, Some(if self.record { red } else { dim }))
},
// Overdub button/indicator
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"⏺ DUB".blit(buf, x, y, Some(if self.overdub {
Style::default().bold().yellow()
} else {
Style::default().bold().dim()
}))
"⏺ DUB".blit(buf, x, y, Some(if self.overdub { yellow } else { dim }))
},
// Monitor button/indicator
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"⏺ MON".blit(buf, x, y, Some(if self.monitor {
Style::default().bold().green()
} else {
Style::default().bold().dim()
}))
"⏺ MON".blit(buf, x, y, Some(if self.monitor { green } else { dim }))
},
// Beats per minute
&|buf: &mut Buffer, Rect { x, y, .. }: Rect|{
"BPM".blit(buf, x, y, Some(style))?;
format!("{}.{:03}", bpm, bpm % 1).blit(buf, x + 4, y, Some(style.bold()))?;
"BPM".blit(buf, x, y, Some(not_dim))?;
format!("{}.{:03}", bpm, bpm % 1).blit(buf, x + 4, y, Some(not_dim.bold()))?;
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()))?;
"QUANT".blit(buf, x, y, Some(not_dim))?;
ppq_to_name(*quant).blit(buf, x + 6, y, Some(not_dim.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()))?;
"SYNC".blit(buf, x, y, Some(not_dim))?;
"4/4".blit(buf, x + 5, y, Some(not_dim.bold()))?;
Ok(Rect { x, y, width: 12, height: 1 })
},
@ -111,7 +99,5 @@ render!(TransportView |self, buf, area| {
timer.blit(buf, x + width - timer.len() as u16 - 1, y, Some(Style::default().not_dim()))
}
]).render(buf, area)?;
area.height = 1;
Ok(area)
]).render(buf, area)
});