wip: refactor pt.14: 138 errors

This commit is contained in:
🪞👃🪞 2024-11-10 23:22:26 +01:00
parent fbf217e108
commit 8b68a993bc
9 changed files with 95 additions and 100 deletions

View file

@ -1,31 +1,24 @@
use crate::*;
use tek_api::Transport;
/// Stores and displays time-related state.
/// Stores and displays time-related info.
#[derive(Debug)]
pub struct TransportView<E: Engine> {
_engine: PhantomData<E>,
pub state: Transport,
pub model: Transport,
pub focus: TransportViewFocus,
pub focused: bool,
pub size: Measure<E>,
}
/// JACK process callback for transport app
impl<E: Engine> Audio for TransportView<E> {
fn process (&mut self, client: &Client, scope: &ProcessScope) -> Control {
self.state.process(client, scope);
Control::Continue
}
}
impl<E: Engine> TransportView<E> {
pub fn new (jack: &Arc<RwLock<JackClient>>, clock: Option<&Arc<Clock>>) -> Self {
Self {
_engine: Default::default(),
focused: false,
focus: TransportViewFocus::PlayPause,
state: Transport {
size: Measure::new(),
model: Transport {
metronome: false,
transport: jack.read().unwrap().transport(),
jack: jack.clone(),
@ -53,7 +46,7 @@ impl Content for TransportView<Tui> {
lay!(
self.focus.wrap(self.focused, TransportViewFocus::PlayPause, &Styled(
None,
match *self.clock.playing.read().unwrap() {
match *self.model.clock.playing.read().unwrap() {
Some(TransportState::Rolling) => "▶ PLAYING",
Some(TransportState::Starting) => "READY ...",
Some(TransportState::Stopped) => "⏹ STOPPED",
@ -63,20 +56,20 @@ impl Content for TransportView<Tui> {
row!(
self.focus.wrap(self.focused, TransportViewFocus::Bpm, &Outset::X(1u16, {
let bpm = self.clock.timebase().bpm.get();
let bpm = self.model.clock.timebase().bpm.get();
row! { "BPM ", format!("{}.{:03}", bpm as usize, (bpm * 1000.0) % 1000.0) }
})),
//let quant = self.focus.wrap(self.focused, TransportViewFocus::Quant, &Outset::X(1u16, row! {
//"QUANT ", ppq_to_name(self.quant as usize)
//})),
self.focus.wrap(self.focused, TransportViewFocus::Sync, &Outset::X(1u16, row! {
"SYNC ", pulses_to_name(self.clock.sync.get() as usize)
"SYNC ", pulses_to_name(self.model.clock.sync.get() as usize)
}))
).align_w().fill_x(),
self.focus.wrap(self.focused, TransportViewFocus::Clock, &{
let time1 = self.clock.current.format_beat();
let time2 = self.clock.current.usec.format_msu();
let time1 = self.model.clock.current.format_beat();
let time2 = self.model.clock.current.usec.format_msu();
row!("B" ,time1.as_str(), " T", time2.as_str()).outset_x(1)
}).align_e().fill_x(),