diff --git a/crates/tek/src/tui/app_sequencer.rs b/crates/tek/src/tui/app_sequencer.rs index e9db5496..e37ab0b2 100644 --- a/crates/tek/src/tui/app_sequencer.rs +++ b/crates/tek/src/tui/app_sequencer.rs @@ -84,63 +84,51 @@ impl Command for SequencerCommand { impl InputToCommand for SequencerCommand { fn input_to_command (state: &SequencerTui, input: &TuiInput) -> Option { - to_sequencer_command(state, input) - } -} - -pub fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option { - Some(match input.event() { - - // Toggle visibility of phrase pool column - key_pat!(Tab) => ShowPool(!state.show_pool), - - // Enqueue currently edited phrase - key_pat!(Char('q')) => Enqueue(Some( - state.phrases.phrases[state.phrases.phrase.load(Ordering::Relaxed)].clone() - )), - - // 0: Enqueue phrase 0 (stop all) - key_pat!(Char('0')) => Enqueue(Some( - state.phrases.phrases[0].clone() - )), - - // E: Toggle between editing currently playing or other phrase - key_pat!(Char('e')) => if let Some((_, Some(playing_phrase))) = state.player.play_phrase() { - let editing_phrase = state.editor.phrase().as_ref().map(|p|p.read().unwrap().clone()); - let selected_phrase = state.phrases.phrase().clone(); - if Some(selected_phrase.read().unwrap().clone()) != editing_phrase { - Editor(Show(Some(selected_phrase))) + Some(match input.event() { + // Toggle visibility of phrase pool column + key_pat!(Tab) => ShowPool(!state.show_pool), + // Enqueue currently edited phrase + key_pat!(Char('q')) => Enqueue(Some( + state.phrases.phrases[state.phrases.phrase.load(Ordering::Relaxed)].clone() + )), + // 0: Enqueue phrase 0 (stop all) + key_pat!(Char('0')) => Enqueue(Some( + state.phrases.phrases[0].clone() + )), + // E: Toggle between editing currently playing or other phrase + key_pat!(Char('e')) => if let Some((_, Some(playing_phrase))) = state.player.play_phrase() { + let editing_phrase = state.editor.phrase().as_ref().map(|p|p.read().unwrap().clone()); + let selected_phrase = state.phrases.phrase().clone(); + if Some(selected_phrase.read().unwrap().clone()) != editing_phrase { + Editor(Show(Some(selected_phrase))) + } else { + Editor(Show(Some(playing_phrase.clone()))) + } } else { - Editor(Show(Some(playing_phrase.clone()))) + return None + }, + // Transport: Play/pause + key_pat!(Char(' ')) => Clock(if state.clock().is_stopped() { + Play(None) + } else { + Pause(None) + }), + // Transport: Play from start or rewind to start + key_pat!(Shift-Char(' ')) => Clock(if state.clock().is_stopped() { + Play(Some(0)) + } else { + Pause(Some(0)) + }), + // Delegate to components: + _ => if let Some(command) = PhraseCommand::input_to_command(&state.editor, input) { + Editor(command) + } else if let Some(command) = PhrasesCommand::input_to_command(&state.phrases, input) { + Phrases(command) + } else { + return None } - } else { - return None - }, - - // Transport: Play/pause - key_pat!(Char(' ')) => Clock(if state.clock().is_stopped() { - Play(None) - } else { - Pause(None) - }), - - // Transport: Play from start or rewind to start - key_pat!(Shift-Char(' ')) => Clock(if state.clock().is_stopped() { - Play(Some(0)) - } else { - Pause(Some(0)) - }), - - // Delegate to components: - _ => if let Some(command) = PhraseCommand::input_to_command(&state.editor, input) { - Editor(command) - } else if let Some(command) = PhrasesCommand::input_to_command(&state.phrases, input) { - Phrases(command) - } else { - return None - } - - }) + }) + } } audio!(|self:SequencerTui, client, scope|{ @@ -321,8 +309,6 @@ render!(|self: SequencerStatusBar|Tui::fixed_y(2, row!([ Tui::fixed_xy(11, 2, PlayPause(self.playing)), lay!([ { - let bg = TuiTheme::g(50); - let fg = TuiTheme::g(255); let single = |binding, command|row!([" ", col!([ Tui::fg(TuiTheme::yellow(), binding), command @@ -331,7 +317,7 @@ render!(|self: SequencerStatusBar|Tui::fixed_y(2, row!([ row!([" ", Tui::fg(TuiTheme::yellow(), b1), " ", c1,]), row!([" ", Tui::fg(TuiTheme::yellow(), b2), " ", c2,]), ]); - Tui::bg(bg, Tui::fg(fg, row!([ + Tui::bg(TuiTheme::g(50), Tui::fg(TuiTheme::g(255), row!([ single("SPACE", "play/pause"), double((" ✣", "cursor"), ("C-✣", "scroll"), ), double((",.", "note"), ("<>", "triplet"),), @@ -340,15 +326,10 @@ render!(|self: SequencerStatusBar|Tui::fixed_y(2, row!([ ]))) }, Tui::fill_xy(Tui::at_se({ - let orange = TuiTheme::orange(); - let dark = TuiTheme::g(25); - //let cpu = &self.cpu; - //let res = &self.res; - let size = &self.size; - Tui::bg(dark, row!([ - //Tui::fg(orange, cpu), - //Tui::fg(orange, res), - Tui::fg(orange, size), + Tui::bg(TuiTheme::g(25), row!([ + Tui::fg(TuiTheme::orange(), &self.cpu), + Tui::fg(TuiTheme::orange(), &self.res), + Tui::fg(TuiTheme::orange(), &self.size), ])) })), ])