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, } /// 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(&Arc::new(jack.read().unwrap().transport())), size: Measure::new(), cursor: (0, 0), focus: FocusState::Entered(TransportFocus::PlayPause) }) } } /// 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!(); "" } }