use crate::*; impl Content for TransportToolbar { type Engine = Tui; fn content (&self) -> impl Widget { lay!( self.focus.wrap(self.focused, TransportToolbarFocus::PlayPause, &Styled( match *self.clock.playing.read().unwrap() { Some(TransportState::Stopped) => Some(GRAY_DIM.bold()), Some(TransportState::Starting) => Some(GRAY_NOT_DIM_BOLD), Some(TransportState::Rolling) => Some(WHITE_NOT_DIM_BOLD), _ => unreachable!(), }, 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, row! { "BPM ", format!("{}.{:03}", self.clock.bpm() as usize, (self.clock.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() as usize) })) ).align_w().fill_x(), self.focus.wrap(self.focused, TransportToolbarFocus::Clock, &{ let time1 = self.clock.format_current_pulse(); let time2 = self.clock.format_current_usec(); 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) } }