comments and formatting

This commit is contained in:
🪞👃🪞 2024-10-01 05:31:09 +03:00
parent 0574eb79ef
commit 4dcb9abef1

View file

@ -1899,12 +1899,8 @@ impl<E: Engine> TransportToolbar<E> {
Ok(()) Ok(())
} }
pub fn update (&mut self, scope: &ProcessScope) -> (bool, usize, usize, usize, usize, f64) { pub fn update (&mut self, scope: &ProcessScope) -> (bool, usize, usize, usize, usize, f64) {
let CycleTimes { let times = scope.cycle_times().unwrap();
current_frames, let CycleTimes { current_frames, current_usecs, next_usecs, period_usecs } = times;
current_usecs,
next_usecs,
period_usecs
} = scope.cycle_times().unwrap();
let chunk_size = scope.n_frames() as usize; let chunk_size = scope.n_frames() as usize;
let transport = self.transport.as_ref().unwrap().query().unwrap(); let transport = self.transport.as_ref().unwrap().query().unwrap();
self.frame = transport.pos.frame() as usize; self.frame = transport.pos.frame() as usize;
@ -1912,10 +1908,7 @@ impl<E: Engine> TransportToolbar<E> {
if self.playing != Some(transport.state) { if self.playing != Some(transport.state) {
match transport.state { match transport.state {
TransportState::Rolling => { TransportState::Rolling => {
self.started = Some(( self.started = Some((current_frames as usize, current_usecs as usize));
current_frames as usize,
current_usecs as usize,
));
}, },
TransportState::Stopped => { TransportState::Stopped => {
self.started = None; self.started = None;
@ -2019,6 +2012,7 @@ impl Content for TransportToolbar<Tui> {
fn content (&self) -> impl Widget<Engine = Tui> { fn content (&self) -> impl Widget<Engine = Tui> {
row! { row! {
// play/pause
self.focus.wrap(self.focused, TransportToolbarFocus::PlayPause, &Styled( self.focus.wrap(self.focused, TransportToolbarFocus::PlayPause, &Styled(
match self.playing { match self.playing {
Some(TransportState::Stopped) => Some(GRAY_DIM.bold()), Some(TransportState::Stopped) => Some(GRAY_DIM.bold()),
@ -2034,19 +2028,23 @@ impl Content for TransportToolbar<Tui> {
} }
).min_xy(11, 2).push_x(1)), ).min_xy(11, 2).push_x(1)),
// bpm
self.focus.wrap(self.focused, TransportToolbarFocus::Bpm, &Outset::X(1u16, col! { self.focus.wrap(self.focused, TransportToolbarFocus::Bpm, &Outset::X(1u16, col! {
"BPM", "BPM",
format!("{}.{:03}", self.bpm as usize, (self.bpm * 1000.0) % 1000.0).as_str() format!("{}.{:03}", self.bpm as usize, (self.bpm * 1000.0) % 1000.0).as_str()
})), })),
// quant
self.focus.wrap(self.focused, TransportToolbarFocus::Quant, &Outset::X(1u16, col! { self.focus.wrap(self.focused, TransportToolbarFocus::Quant, &Outset::X(1u16, col! {
"QUANT", ppq_to_name(self.quant as usize) "QUANT", ppq_to_name(self.quant as usize)
})), })),
// sync
self.focus.wrap(self.focused, TransportToolbarFocus::Sync, &Outset::X(1u16, col! { self.focus.wrap(self.focused, TransportToolbarFocus::Sync, &Outset::X(1u16, col! {
"SYNC", ppq_to_name(self.sync as usize) "SYNC", ppq_to_name(self.sync as usize)
})), })),
// clock
self.focus.wrap(self.focused, TransportToolbarFocus::Clock, &{ self.focus.wrap(self.focused, TransportToolbarFocus::Clock, &{
let Self { frame: _frame, pulse, ppq, usecs, .. } = self; let Self { frame: _frame, pulse, ppq, usecs, .. } = self;
let (beats, pulses) = if *ppq > 0 { (pulse / ppq, pulse % ppq) } else { (0, 0) }; let (beats, pulses) = if *ppq > 0 { (pulse / ppq, pulse % ppq) } else { (0, 0) };
@ -2073,7 +2071,7 @@ impl Focusable<Tui> for TransportToolbar<Tui> {
} }
#[derive(Clone, Copy, PartialEq)] #[derive(Clone, Copy, PartialEq)]
enum TransportToolbarFocus { PlayPause, Bpm, Quant, Sync, Clock, } pub enum TransportToolbarFocus { PlayPause, Bpm, Quant, Sync, Clock, }
impl TransportToolbarFocus { impl TransportToolbarFocus {
pub fn wrap <'a, W: Widget<Engine = Tui>> ( pub fn wrap <'a, W: Widget<Engine = Tui>> (
self, parent_focus: bool, focus: Self, widget: &'a W self, parent_focus: bool, focus: Self, widget: &'a W