mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
wip: refactor pt.20: 44 errors
This commit is contained in:
parent
914c2d6c09
commit
2188bccd63
25 changed files with 664 additions and 486 deletions
|
|
@ -1,16 +1,56 @@
|
|||
use crate::*;
|
||||
use tek_api::Transport;
|
||||
|
||||
pub type TransportApp = AppContainer<
|
||||
Tui,
|
||||
Transport,
|
||||
TransportView<Tui>,
|
||||
TransportViewCommand,
|
||||
TransportAudio,
|
||||
TransportStatusBar
|
||||
>;
|
||||
|
||||
impl TransportApp {
|
||||
pub fn run <'a> (jack: &Arc<RwLock<JackClient>>) -> Usually<Self> {
|
||||
let model = Arc::new(RwLock::new(Transport {
|
||||
metronome: false,
|
||||
transport: jack.read().unwrap().transport(),
|
||||
jack: jack.clone(),
|
||||
clock: Arc::new(Clock::from(Instant::default()))
|
||||
}));
|
||||
|
||||
Ok(Self::new(
|
||||
&model,
|
||||
TransportView::from(&model),
|
||||
TransportAudio(model.clone()),
|
||||
None,
|
||||
None,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/// Stores and displays time-related info.
|
||||
#[derive(Debug)]
|
||||
pub struct TransportView<E: Engine> {
|
||||
_engine: PhantomData<E>,
|
||||
pub model: Transport,
|
||||
pub model: Arc<RwLock<Transport>>,
|
||||
pub focus: TransportViewFocus,
|
||||
pub focused: bool,
|
||||
pub size: Measure<E>,
|
||||
}
|
||||
|
||||
impl<E: Engine> From<&Arc<RwLock<Transport>>> for TransportView<E> {
|
||||
fn from (model: &Arc<RwLock<Transport>>) -> Self {
|
||||
Self {
|
||||
_engine: Default::default(),
|
||||
focused: false,
|
||||
focus: TransportViewFocus::PlayPause,
|
||||
size: Measure::new(),
|
||||
model: model.clone()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Engine> TransportView<E> {
|
||||
pub fn new (jack: &Arc<RwLock<JackClient>>, clock: Option<&Arc<Clock>>) -> Self {
|
||||
Self {
|
||||
|
|
@ -22,19 +62,18 @@ impl<E: Engine> TransportView<E> {
|
|||
metronome: false,
|
||||
transport: jack.read().unwrap().transport(),
|
||||
jack: jack.clone(),
|
||||
clock: match clock {
|
||||
Some(clock) => clock.clone(),
|
||||
None => {
|
||||
let timebase = Arc::new(Timebase::default());
|
||||
Arc::new(Clock {
|
||||
playing: Some(TransportState::Stopped).into(),
|
||||
quant: 24.into(),
|
||||
sync: (timebase.ppq.get() * 4.).into(),
|
||||
current: Instant::default(),
|
||||
started: None.into(),
|
||||
})
|
||||
}
|
||||
},
|
||||
clock: if let Some(clock) = clock {
|
||||
clock.clone()
|
||||
} else {
|
||||
let current = Instant::default();
|
||||
Arc::new(Clock {
|
||||
playing: Some(TransportState::Stopped).into(),
|
||||
started: None.into(),
|
||||
quant: 24.into(),
|
||||
sync: (current.timebase.ppq.get() * 4.).into(),
|
||||
current,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue