mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
47 lines
2.1 KiB
Rust
47 lines
2.1 KiB
Rust
use crate::*;
|
|
impl Content for TransportToolbar<Tui> {
|
|
type Engine = Tui;
|
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
|
lay!(
|
|
self.focus.wrap(self.focused, TransportToolbarFocus::PlayPause, &Styled(
|
|
None,
|
|
match *self.clock.playing.read().unwrap() {
|
|
Some(TransportState::Rolling) => "▶ PLAYING",
|
|
Some(TransportState::Starting) => "READY ...",
|
|
Some(TransportState::Stopped) => "⏹ STOPPED",
|
|
_ => unreachable!(),
|
|
}
|
|
).min_xy(11, 2).push_x(1)).align_x().fill_x(),
|
|
|
|
row!(
|
|
self.focus.wrap(self.focused, TransportToolbarFocus::Bpm, &Outset::X(1u16, {
|
|
let bpm = self.clock.timebase().bpm.get();
|
|
row! { "BPM ", format!("{}.{:03}", bpm as usize, (bpm * 1000.0) % 1000.0) }
|
|
})),
|
|
//let quant = self.focus.wrap(self.focused, TransportToolbarFocus::Quant, &Outset::X(1u16, row! {
|
|
//"QUANT ", ppq_to_name(self.quant as usize)
|
|
//})),
|
|
self.focus.wrap(self.focused, TransportToolbarFocus::Sync, &Outset::X(1u16, row! {
|
|
"SYNC ", pulses_to_name(self.clock.sync.get() as usize)
|
|
}))
|
|
).align_w().fill_x(),
|
|
|
|
self.focus.wrap(self.focused, TransportToolbarFocus::Clock, &{
|
|
let time1 = self.clock.current.format_beat();
|
|
let time2 = self.clock.current.usec.format_msu();
|
|
row!("B" ,time1.as_str(), " T", time2.as_str()).outset_x(1)
|
|
}).align_e().fill_x(),
|
|
|
|
).fill_x().bg(Color::Rgb(40, 50, 30))
|
|
}
|
|
}
|
|
impl TransportToolbarFocus {
|
|
pub fn wrap <'a, W: Widget<Engine = Tui>> (
|
|
self, parent_focus: bool, focus: Self, widget: &'a W
|
|
) -> impl Widget<Engine = Tui> + 'a {
|
|
let focused = parent_focus && focus == self;
|
|
let corners = focused.then_some(CORNERS);
|
|
let highlight = focused.then_some(Background(Color::Rgb(60, 70, 50)));
|
|
lay!(corners, highlight, *widget)
|
|
}
|
|
}
|