mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
2-line transport bar on narrow screen
This commit is contained in:
parent
672d81f353
commit
61af72c281
2 changed files with 30 additions and 21 deletions
|
|
@ -26,7 +26,7 @@ impl<'a> Render for ChainView<'a> {
|
|||
);
|
||||
}
|
||||
lozenge_left(buf, x, y, height, style);
|
||||
let (area, _plugins) = if let Some(ref chain) = self.track {
|
||||
let (area, _plugins) = if self.track.is_some() {
|
||||
if self.vertical {
|
||||
self.draw_as_column(buf, area, style)?
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -13,31 +13,40 @@ pub struct TransportView<'a> {
|
|||
impl<'a> Render for TransportView<'a> {
|
||||
fn render (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let Rect { x, y, width, .. } = area;
|
||||
draw_play_stop(buf, x + 1, y, &self.playing);
|
||||
draw_rec(buf, x + 12, y, self.record);
|
||||
draw_dub(buf, x + 19, y, self.overdub);
|
||||
draw_mon(buf, x + 26, y, self.monitor);
|
||||
draw_bpm(buf, x + 33, y, self.timebase.bpm() as usize, self.quant);
|
||||
draw_timer(buf, x + width - 1, y, &self.timebase, self.frame);
|
||||
Ok(Rect { x, y, width, height: 1 })
|
||||
if width > 100 {
|
||||
draw_play_stop(buf, x + 1, y, &self.playing);
|
||||
draw_rec(buf, x + 12, y, self.record);
|
||||
draw_dub(buf, x + 19, y, self.overdub);
|
||||
draw_mon(buf, x + 26, y, self.monitor);
|
||||
draw_bpm(buf, x + 33, y, self.timebase.bpm() as usize, self.quant);
|
||||
draw_timer(buf, x + width - 1, y,
|
||||
self.timebase.ppq() as usize,
|
||||
self.timebase.frame_to_pulse(self.frame as f64) as usize,
|
||||
self.timebase.frame_to_usec(self.frame as f64) as usize,
|
||||
);
|
||||
Ok(Rect { x, y, width, height: 1 })
|
||||
} else {
|
||||
draw_play_stop(buf, x + 1, y, &self.playing);
|
||||
draw_bpm(buf, x + 12, y, self.timebase.bpm() as usize, self.quant);
|
||||
draw_timer(buf, x + width - 1, y,
|
||||
self.timebase.ppq() as usize,
|
||||
self.timebase.frame_to_pulse(self.frame as f64) as usize,
|
||||
self.timebase.frame_to_usec(self.frame as f64) as usize,
|
||||
);
|
||||
draw_rec(buf, x + 1, y + 1, self.record);
|
||||
draw_dub(buf, x + 8, y + 1, self.overdub);
|
||||
draw_mon(buf, x + 15, y + 1, self.monitor);
|
||||
Ok(Rect { x, y, width, height: 2 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw_timer (buf: &mut Buffer, x: u16, y: u16, timebase: &Arc<Timebase>, frame: usize) {
|
||||
let ppq = timebase.ppq() as usize;
|
||||
|
||||
let pulse = timebase.pulse_to_frame(frame as f64) as usize;
|
||||
let (beats, pulses) = (pulse / ppq, pulse % ppq);
|
||||
let (bars, beats) = (beats / 4, beats % 4);
|
||||
|
||||
let usecs = timebase.frame_to_usec(frame as f64) as usize;
|
||||
pub fn draw_timer (buf: &mut Buffer, x: u16, y: u16, ppq: usize, pulse: usize, usecs: usize) {
|
||||
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} {}.{}.{pulses:02}",
|
||||
bars as usize + 1,
|
||||
beats as usize + 1
|
||||
);
|
||||
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()));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue