mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-10 13:46:42 +01:00
add top-level transport UI to launcher
This commit is contained in:
parent
a4a2f645b1
commit
4c9eed6fce
3 changed files with 126 additions and 65 deletions
|
|
@ -112,7 +112,7 @@ impl Sequencer {
|
|||
}).activate(client)
|
||||
}
|
||||
|
||||
fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
|
||||
pub fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
|
||||
|
||||
// Update time
|
||||
let mut sequence = &mut self.sequences[self.sequence].notes;
|
||||
|
|
@ -267,24 +267,15 @@ fn render (s: &Sequencer, buf: &mut Buffer, mut area: Rect) -> Usually<Rect> {
|
|||
}))
|
||||
}
|
||||
|
||||
fn draw_header (s: &Sequencer, buf: &mut Buffer, area: Rect, beat: usize) -> Usually<Rect> {
|
||||
pub fn draw_header (s: &Sequencer, buf: &mut Buffer, area: Rect, beat: usize) -> Usually<Rect> {
|
||||
let Rect { x, y, width, .. } = area;
|
||||
let rep = beat / s.steps;
|
||||
let step = beat % s.steps;
|
||||
let reps = s.steps / s.resolution;
|
||||
let steps = s.steps % s.resolution;
|
||||
let Rect { x, y, width, .. } = area;
|
||||
draw_timer(buf, x + width - 2, y + 1, rep, step, reps, steps);
|
||||
let style = Style::default().gray();
|
||||
let timer = format!("{rep}.{step:02} / {reps}.{steps}");
|
||||
timer.blit(buf, x + width - 2 - timer.len() as u16, y + 1, Some(style.bold().not_dim()));
|
||||
match s.playing {
|
||||
TransportState::Rolling => "▶ PLAYING",
|
||||
TransportState::Starting => "READY ...",
|
||||
TransportState::Stopped => "⏹ STOPPED",
|
||||
}.blit(buf, x + 2, y + 1, Some(match s.playing {
|
||||
TransportState::Stopped => style.dim().bold(),
|
||||
TransportState::Starting => style.not_dim().bold(),
|
||||
TransportState::Rolling => style.not_dim().white().bold()
|
||||
}));
|
||||
draw_play_stop(buf, x + 2, y + 1, &s.playing);
|
||||
let separator = format!("├{}┤", "-".repeat((area.width - 2).into()));
|
||||
separator.blit(buf, x, y + 2, Some(style.dim()));
|
||||
draw_rec(buf, x + 13, y + 1, s.recording);
|
||||
|
|
@ -293,23 +284,41 @@ fn draw_header (s: &Sequencer, buf: &mut Buffer, area: Rect, beat: usize) -> Usu
|
|||
let clips = draw_clips(s, buf, area)?;
|
||||
Ok(Rect { x, y, width: area.width, height: 3 })
|
||||
}
|
||||
|
||||
fn draw_rec (buf: &mut Buffer, x: u16, y: u16, on: bool) {
|
||||
pub fn draw_timer (
|
||||
buf: &mut Buffer, x: u16, y: u16, rep: usize, step: usize, reps: usize, steps: usize
|
||||
) {
|
||||
let style = Style::default().gray();
|
||||
let timer = format!("{rep}.{step:02} / {reps}.{steps}");
|
||||
timer.blit(buf, x - timer.len() as u16, y, Some(style.bold().not_dim()));
|
||||
}
|
||||
pub fn draw_play_stop (buf: &mut Buffer, x: u16, y: u16, state: &TransportState) {
|
||||
let style = Style::default().gray();
|
||||
match state {
|
||||
TransportState::Rolling => "▶ PLAYING",
|
||||
TransportState::Starting => "READY ...",
|
||||
TransportState::Stopped => "⏹ STOPPED",
|
||||
}.blit(buf, x, y, Some(match state {
|
||||
TransportState::Stopped => style.dim().bold(),
|
||||
TransportState::Starting => style.not_dim().bold(),
|
||||
TransportState::Rolling => style.not_dim().white().bold()
|
||||
}));
|
||||
}
|
||||
pub fn draw_rec (buf: &mut Buffer, x: u16, y: u16, on: bool) {
|
||||
"⏺ REC".blit(buf, x, y, Some(if on {
|
||||
Style::default().bold().red()
|
||||
} else {
|
||||
Style::default().bold().dim()
|
||||
}))
|
||||
}
|
||||
fn draw_dub (buf: &mut Buffer, x: u16, y: u16, on: bool) {
|
||||
"⏺ DUB".blit(buf, x + 20, y + 1, Some(if on {
|
||||
pub fn draw_dub (buf: &mut Buffer, x: u16, y: u16, on: bool) {
|
||||
"⏺ DUB".blit(buf, x, y, Some(if on {
|
||||
Style::default().bold().yellow()
|
||||
} else {
|
||||
Style::default().bold().dim()
|
||||
}))
|
||||
}
|
||||
fn draw_mon (buf: &mut Buffer, x: u16, y: u16, on: bool) {
|
||||
"⏺ MON".blit(buf, x + 27, y + 1, Some(if on {
|
||||
pub fn draw_mon (buf: &mut Buffer, x: u16, y: u16, on: bool) {
|
||||
"⏺ MON".blit(buf, x, y, Some(if on {
|
||||
Style::default().bold().green()
|
||||
} else {
|
||||
Style::default().bold().dim()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue