diff --git a/crates/tek_tui/src/tui_app_arranger.rs b/crates/tek_tui/src/tui_app_arranger.rs index a8704680..a175a2cc 100644 --- a/crates/tek_tui/src/tui_app_arranger.rs +++ b/crates/tek_tui/src/tui_app_arranger.rs @@ -4,7 +4,7 @@ use crate::*; pub struct ArrangerTui { pub jack: Arc>, pub clock: ClockModel, - pub phrases: PhrasesModel, + pub phrases: PhraseListModel, pub tracks: Vec, pub scenes: Vec, pub name: Arc>, @@ -31,7 +31,7 @@ impl TryFrom<&Arc>> for ArrangerTui { Ok(Self { jack: jack.clone(), clock: ClockModel::from(&Arc::new(jack.read().unwrap().transport())), - phrases: PhrasesModel::default(), + phrases: PhraseListModel::default(), editor: PhraseEditorModel::default(), selected: ArrangerSelection::Clip(0, 0), scenes: vec![], diff --git a/crates/tek_tui/src/tui_app_sequencer.rs b/crates/tek_tui/src/tui_app_sequencer.rs index 2c8908fe..b2f8e1bb 100644 --- a/crates/tek_tui/src/tui_app_sequencer.rs +++ b/crates/tek_tui/src/tui_app_sequencer.rs @@ -4,7 +4,7 @@ use crate::*; pub struct SequencerTui { pub jack: Arc>, pub clock: ClockModel, - pub phrases: PhrasesModel, + pub phrases: PhraseListModel, pub player: PhrasePlayerModel, pub editor: PhraseEditorModel, pub size: Measure, @@ -23,7 +23,7 @@ impl TryFrom<&Arc>> for SequencerTui { let clock = ClockModel::from(&Arc::new(jack.read().unwrap().transport())); Ok(Self { jack: jack.clone(), - phrases: PhrasesModel::default(), + phrases: PhraseListModel::default(), player: PhrasePlayerModel::from(&clock), editor: PhraseEditorModel::default(), size: Measure::new(), @@ -98,6 +98,7 @@ pub struct SequencerStatusBar { pub(crate) size: String, pub(crate) sr: String, pub(crate) mode: &'static str, + pub(crate) help: &'static [(&'static str, &'static str, &'static str)] } impl StatusBar for SequencerStatusBar { @@ -130,7 +131,8 @@ impl From<&SequencerTui> for SequencerStatusBar { PhraseEditor => " EDIT MIDI ", PhrasePlay => " TO PLAY ", PhraseNext => " UP NEXT ", - } + }, + help: &[] } } } diff --git a/crates/tek_tui/src/tui_control_phrase_list.rs b/crates/tek_tui/src/tui_control_phrase_list.rs index 5ede5e02..4c9b8e15 100644 --- a/crates/tek_tui/src/tui_control_phrase_list.rs +++ b/crates/tek_tui/src/tui_control_phrase_list.rs @@ -107,7 +107,7 @@ macro_rules! impl_has_phrases { } } } -impl_has_phrases!(PhrasesModel); +impl_has_phrases!(PhraseListModel); impl_has_phrases!(SequencerTui::phrases); impl_has_phrases!(ArrangerTui::phrases); diff --git a/crates/tek_tui/src/tui_control_sequencer.rs b/crates/tek_tui/src/tui_control_sequencer.rs index b2403116..66847cbd 100644 --- a/crates/tek_tui/src/tui_control_sequencer.rs +++ b/crates/tek_tui/src/tui_control_sequencer.rs @@ -45,38 +45,45 @@ impl InputToCommand for SequencerCommand { pub fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option { use SequencerCommand::*; + use PhraseCommand::Show; + use ClockCommand::{Play, Pause}; use KeyCode::Char; if !state.entered() { return None } Some(match input.event() { - key!(Char('e')) => Editor( - PhraseCommand::Show(state.phrase_to_edit().clone()) - ), - key!(Char(' ')) => Clock(if state.is_stopped() { - ClockCommand::Play(None) - } else { - ClockCommand::Pause(None) - }), - key!(Shift-Char(' ')) => Clock(if state.is_stopped() { - ClockCommand::Play(Some(0)) - } else { - ClockCommand::Pause(Some(0)) - }), + // Edit phrase + //key!(Char('e')) => Editor(Show(state.phrase_to_edit().clone())), + key!(Char(' ')) => Clock(if state.is_stopped() { Play(None) } else { Pause(None) }), + key!(Shift-Char(' ')) => Clock(if state.is_stopped() { Play(Some(0)) } else { Pause(Some(0)) }), _ => match state.focused() { - SequencerFocus::Transport(_) => { - match TransportCommand::input_to_command(state, input)? { - TransportCommand::Clock(command) => Clock(command), - _ => return None, - } + SequencerFocus::Transport(_) => match TransportCommand::input_to_command(state, input)? { + TransportCommand::Clock(command) => Clock(command), + _ => return None, + }, + SequencerFocus::PhrasePlay => match input.event() { + key!(Char('e')) => Editor(Show( + state.player.play_phrase().as_ref().map(|x|x.1.as_ref()).flatten().map(|x|x.clone()) + )), + _ => return None, + }, + SequencerFocus::PhraseNext => match input.event() { + key!(Char('e')) => Editor(Show( + state.player.next_phrase().as_ref().map(|x|x.1.as_ref()).flatten().map(|x|x.clone()) + )), + _ => return None, + }, + SequencerFocus::PhraseList => match input.event() { + key!(Char('e')) => Editor(Show( + Some(state.phrases.phrases[state.phrases.phrase.load(Ordering::Relaxed)].clone()) + )), + _ => Phrases( + PhrasesCommand::input_to_command(state, input)? + ) }, - SequencerFocus::PhraseList => Phrases( - PhrasesCommand::input_to_command(state, input)? - ), SequencerFocus::PhraseEditor => Editor( PhraseCommand::input_to_command(state, input)? ), - _ => todo!() } }) } diff --git a/crates/tek_tui/src/tui_model_phrase_list.rs b/crates/tek_tui/src/tui_model_phrase_list.rs index a1fe0d7e..0fc2fbdf 100644 --- a/crates/tek_tui/src/tui_model_phrase_list.rs +++ b/crates/tek_tui/src/tui_model_phrase_list.rs @@ -1,7 +1,7 @@ use crate::*; #[derive(Debug)] -pub struct PhrasesModel { +pub struct PhraseListModel { /// Collection of phrases pub(crate) phrases: Vec>>, /// Selected phrase @@ -12,7 +12,7 @@ pub struct PhrasesModel { pub(crate) mode: Option, } -impl Default for PhrasesModel { +impl Default for PhraseListModel { fn default () -> Self { Self { phrases: vec![RwLock::new(Phrase::default()).into()],