use crate::*; impl Content for TransportToolbar { type Engine = Tui; fn content (&self) -> impl Widget { 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> ( self, parent_focus: bool, focus: Self, widget: &'a W ) -> impl Widget + '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) } }