mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
refactor transport into render-only struct
This commit is contained in:
parent
a7344f8a72
commit
cc2b59d772
4 changed files with 51 additions and 22 deletions
|
|
@ -180,22 +180,29 @@ pub fn process (state: &mut Launcher, _: &Client, _: &ProcessScope) -> Control {
|
|||
pub fn render (state: &Launcher, buf: &mut Buffer, mut area: Rect) -> Usually<Rect> {
|
||||
//area.width = 80; // DOS mode
|
||||
//area.height = 25;
|
||||
let Rect { x, y, width, height } = area;
|
||||
{
|
||||
use crate::device::transport::*;
|
||||
draw_play_stop(buf, x + 1, y, &state.playing);
|
||||
draw_rec(buf, x + 12, y, state.sequencer().map(|s|s.recording).unwrap_or(false));
|
||||
draw_dub(buf, x + 19, y, state.sequencer().map(|s|s.overdub).unwrap_or(false));
|
||||
draw_mon(buf, x + 26, y, state.sequencer().map(|s|s.monitoring).unwrap_or(false));
|
||||
draw_bpm(buf, x + 33, y, state.timebase.bpm() as usize);
|
||||
draw_timer(buf, x + width - 1, y, &state.timebase, state.current_frame);
|
||||
}
|
||||
let mut y = y + 1;
|
||||
let Rect { x, mut y, width, height } = area;
|
||||
|
||||
y = y + crate::device::Transport {
|
||||
timebase: &state.timebase,
|
||||
playing: state.playing,
|
||||
record: state.sequencer().map(|s|s.recording).unwrap_or(false),
|
||||
overdub: state.sequencer().map(|s|s.overdub).unwrap_or(false),
|
||||
monitor: state.sequencer().map(|s|s.monitoring).unwrap_or(false),
|
||||
frame: state.current_frame
|
||||
}.render(buf, area)?.height;
|
||||
|
||||
y = y + LauncherGrid::new(
|
||||
state, buf, Rect { x, y, width, height: height/3 }, state.view.is_tracks()
|
||||
).draw()?.height;
|
||||
y = y + draw_section_chains(state, buf, Rect { x, y, width, height: height/3 })?.height;
|
||||
y = y + draw_section_sequencer(state, buf, Rect { x, y, width, height: height - y })?.height;
|
||||
|
||||
y = y + draw_section_chains(
|
||||
state, buf, Rect { x, y, width, height: height/3 }
|
||||
)?.height;
|
||||
|
||||
y = y + draw_section_sequencer(
|
||||
state, buf, Rect { x, y, width, height: height - y }
|
||||
)?.height;
|
||||
|
||||
area.height = y;
|
||||
if state.show_help {
|
||||
let style = Some(Style::default().bold().white().not_dim().on_black().italic());
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ mod looper; pub use self::looper::Looper;
|
|||
mod mixer; pub use self::mixer::Mixer;
|
||||
mod sequencer; pub use self::sequencer::{Sequencer, Phrase};
|
||||
mod track; pub use self::track::Track;
|
||||
mod transport;
|
||||
mod transport; pub use self::transport::Transport;
|
||||
|
|
|
|||
|
|
@ -157,19 +157,19 @@ fn render (s: &Sequencer, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
|||
pub fn draw_header (s: &Sequencer, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let Rect { x, y, width, .. } = area;
|
||||
let style = Style::default().gray();
|
||||
crate::device::transport::draw_play_stop(buf, x + 2, y + 1, &s.playing);
|
||||
crate::device::Transport {
|
||||
timebase: &s.timebase,
|
||||
playing: s.playing,
|
||||
record: s.recording,
|
||||
overdub: s.overdub,
|
||||
monitor: s.monitoring,
|
||||
frame: 0
|
||||
}.render(buf, area)?;
|
||||
let separator = format!("├{}┤", "-".repeat((width - 2).into()));
|
||||
separator.blit(buf, x, y + 2, Some(style.dim()));
|
||||
crate::device::transport::draw_rec(buf, x + 13, y + 1, s.recording);
|
||||
crate::device::transport::draw_dub(buf, x + 20, y + 1, s.overdub);
|
||||
crate::device::transport::draw_mon(buf, x + 27, y + 1, s.monitoring);
|
||||
let _ = draw_clips(s, buf, area)?;
|
||||
Ok(Rect { x, y, width, height: 3 })
|
||||
}
|
||||
pub fn draw_timer (buf: &mut Buffer, x: u16, y: u16, timer: &str) {
|
||||
let style = Some(Style::default().gray().bold().not_dim());
|
||||
timer.blit(buf, x - timer.len() as u16, y, style);
|
||||
}
|
||||
pub fn draw_clips (s: &Sequencer, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
|
||||
let Rect { x, y, .. } = area;
|
||||
let style = Style::default().gray();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,28 @@
|
|||
use crate::core::*;
|
||||
use crate::layout::*;
|
||||
|
||||
pub struct Transport<'a> {
|
||||
pub timebase: &'a Arc<Timebase>,
|
||||
pub playing: TransportState,
|
||||
pub record: bool,
|
||||
pub overdub: bool,
|
||||
pub monitor: bool,
|
||||
pub frame: usize,
|
||||
}
|
||||
|
||||
impl<'a> Render for Transport<'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);
|
||||
draw_timer(buf, x + width - 1, y, &self.timebase, self.frame);
|
||||
Ok(Rect { x, y, width, height: 1 })
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw_timer (buf: &mut Buffer, x: u16, y: u16, timebase: &Arc<Timebase>, frame: usize) {
|
||||
let ppq = timebase.ppq() as usize;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue