use crate::*; /// Stores and displays time-related info. pub struct TransportTui { pub jack: Arc>, pub clock: ClockModel, pub size: Measure, pub cursor: (usize, usize), pub focus: FocusState, } impl std::fmt::Debug for TransportTui { fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { f.debug_struct("TransportTui") .field("jack", &self.jack) .field("size", &self.size) .field("cursor", &self.cursor) .finish() } } /// Create app state from JACK handle. impl TryFrom<&Arc>> for TransportTui { type Error = Box; fn try_from (jack: &Arc>) -> Usually { Ok(Self { jack: jack.clone(), clock: ClockModel::from(jack), size: Measure::new(), cursor: (0, 0), focus: FocusState::Entered(TransportFocus::PlayPause) }) } } impl HasClock for TransportTui { fn clock (&self) -> &ClockModel { &self.clock } } /// Which item of the transport toolbar is focused #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum TransportFocus { Bpm, Sync, PlayPause, Clock, Quant, } impl FocusWrap for TransportFocus { fn wrap <'a, W: Widget> (self, focus: TransportFocus, content: &'a W) -> impl Widget + 'a { let focused = focus == self; let corners = focused.then_some(CORNERS); let highlight = focused.then_some(Background(Color::Rgb(60, 70, 50))); lay!(corners, highlight, *content) } } impl FocusWrap for Option { fn wrap <'a, W: Widget> (self, focus: TransportFocus, content: &'a W) -> impl Widget + 'a { let focused = Some(focus) == self; let corners = focused.then_some(CORNERS); let highlight = focused.then_some(Background(Color::Rgb(60, 70, 50))); lay!(corners, highlight, *content) } } impl_focus!(TransportTui TransportFocus [ //&[Menu], &[ PlayPause, Bpm, Sync, Quant, Clock, ], ]); #[derive(Copy, Clone)] pub struct TransportStatusBar; impl StatusBar for TransportStatusBar { type State = (); fn hotkey_fg () -> Color { TuiTheme::hotkey_fg() } fn update (&mut self, state: &()) { todo!() } } impl Content for TransportStatusBar { type Engine = Tui; fn content (&self) -> impl Widget { todo!(); "" } }