mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-10 13:46:42 +01:00
wip: "multiple cascading refactors"
https://loglog.games/blog/leaving-rust-gamedev/#orphan-rule-should-be-optional is on point
This commit is contained in:
parent
20afc397ea
commit
fa8282a9d5
18 changed files with 175 additions and 222 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::*;
|
||||
|
||||
/// Stores and displays time-related state.
|
||||
pub struct TransportToolbar {
|
||||
pub struct TransportToolbar<E: Engine> {
|
||||
/// Enable metronome?
|
||||
pub metronome: bool,
|
||||
/// Current sample rate, tempo, and PPQ.
|
||||
|
|
@ -16,13 +16,13 @@ pub struct TransportToolbar {
|
|||
|
||||
pub focused: bool,
|
||||
pub focus: usize,
|
||||
pub playing: TransportPlayPauseButton,
|
||||
pub bpm: TransportBPM,
|
||||
pub quant: TransportQuantize,
|
||||
pub sync: TransportSync,
|
||||
pub clock: TransportClock,
|
||||
pub playing: TransportPlayPauseButton<E>,
|
||||
pub bpm: TransportBPM<E>,
|
||||
pub quant: TransportQuantize<E>,
|
||||
pub sync: TransportSync<E>,
|
||||
pub clock: TransportClock<E>,
|
||||
}
|
||||
impl TransportToolbar {
|
||||
impl<E: Engine> TransportToolbar<E> {
|
||||
pub fn standalone () -> Usually<Arc<RwLock<Self>>> {
|
||||
let mut transport = Self::new(None);
|
||||
transport.focused = true;
|
||||
|
|
@ -34,7 +34,7 @@ impl TransportToolbar {
|
|||
transport.write().unwrap().jack = Some(
|
||||
jack.activate(
|
||||
&transport.clone(),
|
||||
|state: &Arc<RwLock<TransportToolbar>>, client, scope| {
|
||||
|state: &Arc<RwLock<TransportToolbar<E>>>, client, scope| {
|
||||
state.write().unwrap().process(client, scope)
|
||||
}
|
||||
)?
|
||||
|
|
@ -48,22 +48,27 @@ impl TransportToolbar {
|
|||
focus: 0,
|
||||
|
||||
playing: TransportPlayPauseButton {
|
||||
_engine: Default::default(),
|
||||
value: Some(TransportState::Stopped),
|
||||
focused: true
|
||||
},
|
||||
bpm: TransportBPM {
|
||||
_engine: Default::default(),
|
||||
value: timebase.bpm(),
|
||||
focused: false
|
||||
},
|
||||
quant: TransportQuantize {
|
||||
_engine: Default::default(),
|
||||
value: 24,
|
||||
focused: false
|
||||
},
|
||||
sync: TransportSync {
|
||||
_engine: Default::default(),
|
||||
value: timebase.ppq() as usize * 4,
|
||||
focused: false
|
||||
},
|
||||
clock: TransportClock {
|
||||
_engine: Default::default(),
|
||||
frame: 0,
|
||||
pulse: 0,
|
||||
ppq: 0,
|
||||
|
|
@ -142,7 +147,7 @@ impl TransportToolbar {
|
|||
self.timebase.frame_to_usec(self.clock.frame as f64) as usize
|
||||
}
|
||||
}
|
||||
impl Focus<5, Tui> for TransportToolbar {
|
||||
impl Focus<5, Tui> for TransportToolbar<Tui> {
|
||||
fn focus (&self) -> usize {
|
||||
self.focus
|
||||
}
|
||||
|
|
@ -168,7 +173,7 @@ impl Focus<5, Tui> for TransportToolbar {
|
|||
]
|
||||
}
|
||||
}
|
||||
impl Focusable<Tui> for TransportToolbar {
|
||||
impl Focusable<Tui> for TransportToolbar<Tui> {
|
||||
fn is_focused (&self) -> bool {
|
||||
self.focused
|
||||
}
|
||||
|
|
@ -176,16 +181,19 @@ impl Focusable<Tui> for TransportToolbar {
|
|||
self.focused = focused
|
||||
}
|
||||
}
|
||||
process!(TransportToolbar |self, _client, scope| {
|
||||
self.update(&scope);
|
||||
Control::Continue
|
||||
});
|
||||
impl<E: Engine> Process for TransportToolbar<E> {
|
||||
fn process (&mut self, _: &Client, scope: &ProcessScope) -> Control {
|
||||
self.update(&scope);
|
||||
Control::Continue
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TransportPlayPauseButton {
|
||||
pub struct TransportPlayPauseButton<E: Engine> {
|
||||
pub _engine: PhantomData<E>,
|
||||
pub value: Option<TransportState>,
|
||||
pub focused: bool
|
||||
}
|
||||
impl Focusable<Tui> for TransportPlayPauseButton {
|
||||
impl Focusable<Tui> for TransportPlayPauseButton<Tui> {
|
||||
fn is_focused (&self) -> bool {
|
||||
self.focused
|
||||
}
|
||||
|
|
@ -194,11 +202,12 @@ impl Focusable<Tui> for TransportPlayPauseButton {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct TransportBPM {
|
||||
pub struct TransportBPM<E: Engine> {
|
||||
pub _engine: PhantomData<E>,
|
||||
pub value: f64,
|
||||
pub focused: bool
|
||||
}
|
||||
impl Focusable<Tui> for TransportBPM {
|
||||
impl Focusable<Tui> for TransportBPM<Tui> {
|
||||
fn is_focused (&self) -> bool {
|
||||
self.focused
|
||||
}
|
||||
|
|
@ -207,11 +216,12 @@ impl Focusable<Tui> for TransportBPM {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct TransportQuantize {
|
||||
pub struct TransportQuantize<E: Engine> {
|
||||
pub _engine: PhantomData<E>,
|
||||
pub value: usize,
|
||||
pub focused: bool
|
||||
}
|
||||
impl Focusable<Tui> for TransportQuantize {
|
||||
impl Focusable<Tui> for TransportQuantize<Tui> {
|
||||
fn is_focused (&self) -> bool {
|
||||
self.focused
|
||||
}
|
||||
|
|
@ -220,11 +230,12 @@ impl Focusable<Tui> for TransportQuantize {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct TransportSync {
|
||||
pub struct TransportSync<E: Engine> {
|
||||
pub _engine: PhantomData<E>,
|
||||
pub value: usize,
|
||||
pub focused: bool
|
||||
}
|
||||
impl Focusable<Tui> for TransportSync {
|
||||
impl Focusable<Tui> for TransportSync<Tui> {
|
||||
fn is_focused (&self) -> bool {
|
||||
self.focused
|
||||
}
|
||||
|
|
@ -233,14 +244,15 @@ impl Focusable<Tui> for TransportSync {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct TransportClock {
|
||||
pub struct TransportClock<E: Engine> {
|
||||
pub _engine: PhantomData<E>,
|
||||
pub frame: usize,
|
||||
pub pulse: usize,
|
||||
pub ppq: usize,
|
||||
pub usecs: usize,
|
||||
pub focused: bool,
|
||||
}
|
||||
impl Focusable<Tui> for TransportClock {
|
||||
impl Focusable<Tui> for TransportClock<Tui> {
|
||||
fn is_focused (&self) -> bool {
|
||||
self.focused
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue