diff --git a/crates/tek_api/src/api_color.rs b/crates/tek_api/src/api_color.rs index e69de29b..c23e6ba7 100644 --- a/crates/tek_api/src/api_color.rs +++ b/crates/tek_api/src/api_color.rs @@ -0,0 +1,6 @@ +use crate::*; + +pub trait HasColor { + fn color (&self) -> ItemColor; + fn color_mut (&self) -> &mut ItemColor; +} diff --git a/crates/tek_api/src/lib.rs b/crates/tek_api/src/lib.rs index 5de273d5..a81cd01e 100644 --- a/crates/tek_api/src/lib.rs +++ b/crates/tek_api/src/lib.rs @@ -9,15 +9,16 @@ pub(crate) use tek_core::jack::{ }; submod! { - //api_jack api_clip + api_clock + api_color + api_jack + api_phrase + api_player + api_playhead api_scene api_track - api_clock - api_jack - api_player - api_phrase - api_playhead + //api_mixer //api_channel //api_plugin @@ -26,13 +27,6 @@ submod! { //api_sampler //api_sampler_sample //api_sampler_voice - - //model_scene - //model_track - //model_clock - //model_phrase - //model_player - //model_pool } pub trait JackActivate: Sized { diff --git a/crates/tek_tui/src/lib.rs b/crates/tek_tui/src/lib.rs index 1299b8ea..1fa1fd28 100644 --- a/crates/tek_tui/src/lib.rs +++ b/crates/tek_tui/src/lib.rs @@ -38,6 +38,11 @@ submod! { //tui_sampler_cmd tui_sequencer tui_sequencer_cmd + tui_sequencer_jack + tui_sequencer_view + tui_sequencer_focus + tui_sequencer_status + tui_status tui_theme tui_transport diff --git a/crates/tek_tui/src/tui_arranger_view.rs b/crates/tek_tui/src/tui_arranger_view.rs index 2f59d0d2..66913683 100644 --- a/crates/tek_tui/src/tui_arranger_view.rs +++ b/crates/tek_tui/src/tui_arranger_view.rs @@ -65,30 +65,6 @@ impl Content for ArrangerTui { } } -impl TransportViewState for ArrangerTui { - fn focus (&self) -> TransportFocus { - self.focus - } - fn focused (&self) -> bool { - self.focused - } - fn transport_state (&self) -> Option { - *self.playing().read().unwrap() - } - fn bpm_value (&self) -> f64 { - self.bpm().get() - } - fn sync_value (&self) -> f64 { - self.sync().get() - } - fn format_beat (&self) -> String { - self.current().format_beat() - } - fn format_msu (&self) -> String { - self.current().usec.format_msu() - } -} - fn track_widths (tracks: &[ArrangerTrack]) -> Vec<(usize, usize)> { let mut widths = vec![]; let mut total = 0; @@ -480,3 +456,33 @@ pub fn arranger_content_horizontal ( ) ) } + +impl TransportViewState for ArrangerTui { + fn focus (&self) -> TransportFocus { + self.focus + } + fn focused (&self) -> bool { + self.focused + } + fn transport_state (&self) -> Option { + *self.playing().read().unwrap() + } + fn bpm_value (&self) -> f64 { + self.bpm().get() + } + fn sync_value (&self) -> f64 { + self.sync().get() + } + fn format_beat (&self) -> String { + self.current().format_beat() + } + fn format_msu (&self) -> String { + self.current().usec.format_msu() + } +} + +impl PhrasesViewState for ArrangerTui { +} + +impl PhraseViewState for ArrangerTui { +} diff --git a/crates/tek_tui/src/tui_sequencer.rs b/crates/tek_tui/src/tui_sequencer.rs index fe53fa33..c5963deb 100644 --- a/crates/tek_tui/src/tui_sequencer.rs +++ b/crates/tek_tui/src/tui_sequencer.rs @@ -69,105 +69,12 @@ pub enum SequencerFocus { PhraseEditor, } -/// Status bar for sequencer app -#[derive(Copy, Clone)] -pub enum SequencerStatusBar { - Transport, - PhrasePool, - PhraseEditor, -} - -impl Content for SequencerTui { - type Engine = Tui; - fn content (&self) -> impl Widget { - col!( - widget(&TransportRefView(self)), - Split::right(20, - widget(&PhrasesView(self)), - widget(&PhraseView(self)), - ).min_y(20) - ) - } -} - impl Audio for SequencerTui { fn process (&mut self, client: &Client, scope: &ProcessScope) -> Control { self.model.process(client, scope) } } -impl StatusBar for SequencerStatusBar { - type State = (); - fn hotkey_fg () -> Color { - TuiTheme::hotkey_fg() - } - fn update (&mut self, state: &()) { - todo!() - } -} - -impl Content for SequencerStatusBar { - type Engine = Tui; - fn content (&self) -> impl Widget { - todo!(); - "" - } -} - -impl HasFocus for SequencerTui { - type Item = SequencerFocus; -} - -impl FocusEnter for SequencerTui { - fn focus_enter (&mut self) { - let focused = self.focused(); - if !self.entered { - self.entered = true; - // TODO - } - } - fn focus_exit (&mut self) { - if self.entered { - self.entered = false; - // TODO - } - } - fn focus_entered (&self) -> Option { - if self.entered { - Some(self.focused()) - } else { - None - } - } -} - -impl FocusGrid for SequencerTui { - type Item = SequencerFocus; - fn focus_cursor (&self) -> (usize, usize) { - self.cursor - } - fn focus_cursor_mut (&mut self) -> &mut (usize, usize) { - &mut self.cursor - } - fn focus_layout (&self) -> &[&[Self::Item]] { - use SequencerFocus::*; - &[ - &[Menu, Menu ], - &[Transport, Transport ], - &[PhrasePool, PhraseEditor], - ] - } - fn focus_update (&mut self) { - // TODO - } -} - -impl JackApi for SequencerTui { - fn jack (&self) -> &Arc> { - &self.jack - } -} - impl HasPhrases for SequencerTui { fn phrases (&self) -> &Vec>> { &self.phrases @@ -197,101 +104,3 @@ impl HasPhrase for SequencerTui { todo!() } } - -impl MidiInputApi for SequencerTui { - fn midi_ins(&self) -> &Vec> { - todo!() - } - fn midi_ins_mut(&self) -> &mut Vec> { - todo!() - } - fn recording(&self) -> bool { - todo!() - } - fn recording_mut(&mut self) -> &mut bool { - todo!() - } - fn monitoring(&self) -> bool { - todo!() - } - fn monitoring_mut(&mut self) -> &mut bool { - todo!() - } - fn overdub(&self) -> bool { - todo!() - } - fn overdub_mut(&mut self) -> &mut bool { - todo!() - } - fn notes_in(&self) -> &Arc> { - todo!() - } -} - -impl MidiOutputApi for SequencerTui { - fn midi_outs (&self) -> &Vec> { - todo!() - } - fn midi_outs_mut (&mut self) -> &mut Vec> { - todo!() - } - fn midi_note (&mut self) -> &mut Vec { - todo!() - } - fn notes_out (&self) -> &Arc> { - todo!() - } -} - -impl ClockApi for SequencerTui { - fn timebase (&self) -> &Arc { - todo!() - } - fn quant (&self) -> &Quantize { - todo!() - } - fn sync (&self) -> &LaunchSync { - todo!() - } -} - -impl PlayheadApi for SequencerTui { - fn current(&self) -> &Instant { - todo!() - } - fn transport(&self) -> &Transport { - todo!() - } - fn playing(&self) -> &RwLock> { - todo!() - } - fn started(&self) -> &RwLock> { - todo!() - } -} - -impl PlayerApi for SequencerTui {} - -impl TransportViewState for SequencerTui { - fn focus (&self) -> TransportFocus { - self.focus - } - fn focused (&self) -> bool { - self.focused - } - fn transport_state (&self) -> Option { - *self.playing().read().unwrap() - } - fn bpm_value (&self) -> f64 { - self.bpm().get() - } - fn sync_value (&self) -> f64 { - self.sync().get() - } - fn format_beat (&self) -> String { - self.current().format_beat() - } - fn format_msu (&self) -> String { - self.current().usec.format_msu() - } -} diff --git a/crates/tek_tui/src/tui_sequencer_focus.rs b/crates/tek_tui/src/tui_sequencer_focus.rs new file mode 100644 index 00000000..8d23b539 --- /dev/null +++ b/crates/tek_tui/src/tui_sequencer_focus.rs @@ -0,0 +1,50 @@ +use crate::*; + +impl HasFocus for SequencerTui { + type Item = SequencerFocus; +} + +impl FocusEnter for SequencerTui { + type Item = SequencerFocus; + fn focus_enter (&mut self) { + let focused = self.focused(); + if !self.entered { + self.entered = true; + // TODO + } + } + fn focus_exit (&mut self) { + if self.entered { + self.entered = false; + // TODO + } + } + fn focus_entered (&self) -> Option { + if self.entered { + Some(self.focused()) + } else { + None + } + } +} + +impl FocusGrid for SequencerTui { + type Item = SequencerFocus; + fn focus_cursor (&self) -> (usize, usize) { + self.cursor + } + fn focus_cursor_mut (&mut self) -> &mut (usize, usize) { + &mut self.cursor + } + fn focus_layout (&self) -> &[&[Self::Item]] { + use SequencerFocus::*; + &[ + &[Menu, Menu ], + &[Transport, Transport ], + &[PhrasePool, PhraseEditor], + ] + } + fn focus_update (&mut self) { + // TODO + } +} diff --git a/crates/tek_tui/src/tui_sequencer_jack.rs b/crates/tek_tui/src/tui_sequencer_jack.rs new file mode 100644 index 00000000..a591a9f9 --- /dev/null +++ b/crates/tek_tui/src/tui_sequencer_jack.rs @@ -0,0 +1,81 @@ +use crate::*; + +impl JackApi for SequencerTui { + fn jack (&self) -> &Arc> { + &self.jack + } +} + +impl MidiInputApi for SequencerTui { + fn midi_ins(&self) -> &Vec> { + todo!() + } + fn midi_ins_mut(&self) -> &mut Vec> { + todo!() + } + fn recording(&self) -> bool { + todo!() + } + fn recording_mut(&mut self) -> &mut bool { + todo!() + } + fn monitoring(&self) -> bool { + todo!() + } + fn monitoring_mut(&mut self) -> &mut bool { + todo!() + } + fn overdub(&self) -> bool { + todo!() + } + fn overdub_mut(&mut self) -> &mut bool { + todo!() + } + fn notes_in(&self) -> &Arc> { + todo!() + } +} + +impl MidiOutputApi for SequencerTui { + fn midi_outs (&self) -> &Vec> { + todo!() + } + fn midi_outs_mut (&mut self) -> &mut Vec> { + todo!() + } + fn midi_note (&mut self) -> &mut Vec { + todo!() + } + fn notes_out (&self) -> &Arc> { + todo!() + } +} + +impl ClockApi for SequencerTui { + fn timebase (&self) -> &Arc { + todo!() + } + fn quant (&self) -> &Quantize { + todo!() + } + fn sync (&self) -> &LaunchSync { + todo!() + } +} + +impl PlayheadApi for SequencerTui { + fn current(&self) -> &Instant { + todo!() + } + fn transport(&self) -> &Transport { + todo!() + } + fn playing(&self) -> &RwLock> { + todo!() + } + fn started(&self) -> &RwLock> { + todo!() + } +} + +impl PlayerApi for SequencerTui {} diff --git a/crates/tek_tui/src/tui_sequencer_status.rs b/crates/tek_tui/src/tui_sequencer_status.rs new file mode 100644 index 00000000..c1d57f18 --- /dev/null +++ b/crates/tek_tui/src/tui_sequencer_status.rs @@ -0,0 +1,27 @@ +use crate::*; + +/// Status bar for sequencer app +#[derive(Copy, Clone)] +pub enum SequencerStatusBar { + Transport, + PhrasePool, + PhraseEditor, +} + +impl StatusBar for SequencerStatusBar { + type State = (); + fn hotkey_fg () -> Color { + TuiTheme::hotkey_fg() + } + fn update (&mut self, state: &()) { + todo!() + } +} + +impl Content for SequencerStatusBar { + type Engine = Tui; + fn content (&self) -> impl Widget { + todo!(); + "" + } +} diff --git a/crates/tek_tui/src/tui_sequencer_view.rs b/crates/tek_tui/src/tui_sequencer_view.rs new file mode 100644 index 00000000..b41879cd --- /dev/null +++ b/crates/tek_tui/src/tui_sequencer_view.rs @@ -0,0 +1,44 @@ +use crate::*; + +impl Content for SequencerTui { + type Engine = Tui; + fn content (&self) -> impl Widget { + col!( + widget(&TransportRefView(self)), + Split::right(20, + widget(&PhrasesView(self)), + widget(&PhraseView(self)), + ).min_y(20) + ) + } +} + +impl TransportViewState for SequencerTui { + fn focus (&self) -> TransportFocus { + self.focus + } + fn focused (&self) -> bool { + self.focused + } + fn transport_state (&self) -> Option { + *self.playing().read().unwrap() + } + fn bpm_value (&self) -> f64 { + self.bpm().get() + } + fn sync_value (&self) -> f64 { + self.sync().get() + } + fn format_beat (&self) -> String { + self.current().format_beat() + } + fn format_msu (&self) -> String { + self.current().usec.format_msu() + } +} + +impl PhrasesViewState for ArrangerTui { +} + +impl PhraseViewState for ArrangerTui { +}