refactor: separate Render from Handle

This commit is contained in:
🪞👃🪞 2024-06-22 10:15:14 +03:00
parent d9b3bd150e
commit 72ead536be
12 changed files with 255 additions and 212 deletions

View file

@ -106,6 +106,22 @@ impl Sequencer {
}
}
impl Ports for Sequencer {
fn audio_ins (&self) -> Usually<Vec<String>> {
Ok(vec![])
}
fn audio_outs (&self) -> Usually<Vec<String>> {
Ok(vec![])
}
fn midi_ins (&self) -> Usually<Vec<String>> {
Ok(vec![self.input_port.short_name()?])
}
fn midi_outs (&self) -> Usually<Vec<String>> {
Ok(vec![self.output_port.short_name()?])
}
fn connect (&mut self, connect: bool, source: &str, target: &str) {}
}
fn process_in (s: &mut Sequencer, scope: &ProcessScope, transport: &::jack::TransportStatePosition) {
if !s.recording {
return
@ -227,11 +243,11 @@ fn draw_header (s: &Sequencer, buf: &mut Buffer, area: Rect, beat: usize) -> Usu
let style = Style::default().gray();
let timer = format!("{rep}.{step:02} / {reps}.{steps}");
buf.set_string(x + width - 2 - timer.len() as u16, y + 1, &timer, style.bold().not_dim());
buf.set_string(x + 2, y + 1, &format!("⏹ STOP"), if s.playing {
style.dim().bold()
if s.playing {
buf.set_string(x + 2, y + 1, &format!("▶ PLAYING"), style.not_dim().white().bold());
} else {
style.not_dim().white().bold()
});
buf.set_string(x + 2, y + 1, &format!("⏹ STOPPED"), style.dim().bold());
}
buf.set_string(x, y + 2, format!("{}", "-".repeat((area.width - 2).into())), style.dim());
//buf.set_string(x + 2, y + 2,
//&format!("▶ PLAY"), if s.playing {
@ -239,19 +255,19 @@ fn draw_header (s: &Sequencer, buf: &mut Buffer, area: Rect, beat: usize) -> Usu
//} else {
//Style::default().dim()
//});
buf.set_string(x + 10, y + 1,
buf.set_string(x + 13, y + 1,
&format!("⏺ REC"), if s.recording {
Style::default().bold().red()
} else {
Style::default().bold().dim()
});
buf.set_string(x + 17, y + 1,
buf.set_string(x + 20, y + 1,
&format!("⏺ DUB"), if s.overdub {
Style::default().bold().yellow()
} else {
Style::default().bold().dim()
});
buf.set_string(x + 24, y + 1,
buf.set_string(x + 27, y + 1,
&format!("⏺ MON"), if s.monitoring {
Style::default().bold().green()
} else {