From a39e694a3e80335ad1a3d072999087a676ada82a Mon Sep 17 00:00:00 2001 From: unspeaker Date: Thu, 11 Jul 2024 17:38:50 +0300 Subject: [PATCH] fix transport display --- src/view/arranger.rs | 9 +++------ src/view/transport.rs | 28 +++++++++++++++++++--------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/view/arranger.rs b/src/view/arranger.rs index e196a35e..d32e47a6 100644 --- a/src/view/arranger.rs +++ b/src/view/arranger.rs @@ -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; } diff --git a/src/view/transport.rs b/src/view/transport.rs index ad84abea..83f85ae8 100644 --- a/src/view/transport.rs +++ b/src/view/transport.rs @@ -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)?;