transport toolbar layout

This commit is contained in:
🪞👃🪞 2024-10-19 23:32:20 +03:00
parent 727702778b
commit b3db10607a

View file

@ -2,7 +2,7 @@ use crate::*;
impl Content for TransportToolbar<Tui> { impl Content for TransportToolbar<Tui> {
type Engine = Tui; type Engine = Tui;
fn content (&self) -> impl Widget<Engine = Tui> { fn content (&self) -> impl Widget<Engine = Tui> {
row!( lay!(
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()),
@ -16,16 +16,20 @@ impl Content for TransportToolbar<Tui> {
Some(TransportState::Stopped) => "⏹ STOPPED", Some(TransportState::Stopped) => "⏹ STOPPED",
_ => unreachable!(), _ => unreachable!(),
} }
).min_xy(11, 2).push_x(1)), ).min_xy(11, 2).push_x(1)).align_x().fill_x(),
self.focus.wrap(self.focused, TransportToolbarFocus::Bpm, &Outset::X(1u16, row! {
"BPM ", format!("{}.{:03}", self.bpm as usize, (self.bpm * 1000.0) % 1000.0) row!(
})), self.focus.wrap(self.focused, TransportToolbarFocus::Bpm, &Outset::X(1u16, row! {
self.focus.wrap(self.focused, TransportToolbarFocus::Quant, &Outset::X(1u16, row! { "BPM ", format!("{}.{:03}", self.bpm as usize, (self.bpm * 1000.0) % 1000.0)
"QUANT ", ppq_to_name(self.quant as usize) })),
})), //self.focus.wrap(self.focused, TransportToolbarFocus::Quant, &Outset::X(1u16, row! {
self.focus.wrap(self.focused, TransportToolbarFocus::Sync, &Outset::X(1u16, row! { //"QUANT ", ppq_to_name(self.quant as usize)
"SYNC ", ppq_to_name(self.sync as usize) //})),
})), self.focus.wrap(self.focused, TransportToolbarFocus::Sync, &Outset::X(1u16, row! {
"SYNC ", ppq_to_name(self.sync as usize)
})),
).align_w().fill_x(),
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) };
@ -34,8 +38,9 @@ impl Content for TransportToolbar<Tui> {
let (minutes, seconds) = (seconds / 60, seconds % 60); let (minutes, seconds) = (seconds / 60, seconds % 60);
let time1 = format!("{bars}.{beats}.{pulses:02}"); let time1 = format!("{bars}.{beats}.{pulses:02}");
let time2 = format!("{minutes}:{seconds:02}:{msecs:03}"); let time2 = format!("{minutes}:{seconds:02}:{msecs:03}");
row!(time1.as_str(), time2.as_str()).outset_x(1) row!("B" ,time1.as_str(), " T", time2.as_str()).outset_x(1)
}), }).align_e().fill_x(),
).fill_x().bg(Color::Rgb(40, 50, 30)) ).fill_x().bg(Color::Rgb(40, 50, 30))
} }
} }