From b799f6dbd02818059714c2e6fab82310da7fbe48 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Sun, 15 Dec 2024 02:09:49 +0100 Subject: [PATCH] autoselect --- crates/tek/src/tui/app_sequencer.rs | 16 +++++++++--- crates/tek/src/tui/phrase_editor.rs | 38 +++++++++++++++-------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/crates/tek/src/tui/app_sequencer.rs b/crates/tek/src/tui/app_sequencer.rs index 16b75cd8..e4862f3a 100644 --- a/crates/tek/src/tui/app_sequencer.rs +++ b/crates/tek/src/tui/app_sequencer.rs @@ -74,7 +74,17 @@ impl Command for SequencerCommand { fn execute (self, state: &mut SequencerTui) -> Perhaps { Ok(match self { Self::Focus(cmd) => cmd.execute(state)?.map(Focus), - Self::Phrases(cmd) => cmd.execute(&mut state.phrases)?.map(Phrases), + Self::Phrases(cmd) => { + match cmd { + // autoselect: automatically load selected phrase in editor + PhrasesCommand::Select(_) => { + let undo = cmd.execute(&mut state.phrases)?.map(Phrases); + Editor(Show(Some(state.phrases.phrase().clone()))).execute(state)?; + undo + }, + _ => cmd.execute(&mut state.phrases)?.map(Phrases) + } + }, Self::Editor(cmd) => cmd.execute(&mut state.editor)?.map(Editor), Self::Clock(cmd) => cmd.execute(state)?.map(Clock), Self::Enqueue(phrase) => { @@ -370,8 +380,8 @@ render!(|self: SequencerStatusBar|Tui::fixed_y(2, row!([ command ])]); let double = |(b1, c1), (b2, c2)|col!([ - row!([" ", Tui::fg(TuiTheme::yellow(), b1), " ", c1, " "]), - row!([" ", Tui::fg(TuiTheme::yellow(), b2), " ", c2, " "]), + row!([" ", Tui::fg(TuiTheme::yellow(), b1), " ", c1,]), + row!([" ", Tui::fg(TuiTheme::yellow(), b2), " ", c2,]), ]); Tui::bg(bg, Tui::fg(fg, row!([ single("SPACE", "play/pause"), diff --git a/crates/tek/src/tui/phrase_editor.rs b/crates/tek/src/tui/phrase_editor.rs index 2263c001..bdc6c307 100644 --- a/crates/tek/src/tui/phrase_editor.rs +++ b/crates/tek/src/tui/phrase_editor.rs @@ -236,26 +236,28 @@ render!(|self:PhraseEditStatus<'a>|row!(|add|{ let bg = color.darker.rgb; let fg = color.lightest.rgb; add(&Tui::fill_x(Tui::bg(bg, row!(|add|{ - add(&Tui::fixed_xy(16, 3, col!(![ + add(&Tui::fixed_xy(26, 3, col!(![ row!(![" Edit ", Tui::bold(true, format!("{name}"))]), row!(![" Length ", Tui::bold(true, format!("{length}"))]), - row!(![" Loop ", Tui::bold(true, format!("on"))]), - ])))?; - add(&Tui::fixed_xy(12, 3, col!(![ - row!(!["Time ", Tui::bold(true, format!("{}", self.0.time_point()))]), - row!(!["Note ", Tui::bold(true, format!("{}", self.0.note_point()))]), - row!(!["Len ", Tui::bold(true, format!("{}", self.0.note_len()))]), - ])))?; - add(&Tui::fixed_xy(20, 3, col!(![ - row!(!["TimeRange ", Tui::bold(true, format!("{}-{}", self.0.time_start(), self.0.time_end()))]), - row!(!["TimeAxis ", Tui::bold(true, format!("{}", self.0.time_axis()))]), - row!(!["TimeZoom ", Tui::bold(true, format!("{} {}", self.0.time_zoom(), self.0.time_lock()))]), - ])))?; - add(&Tui::fixed_xy(20, 3, col!(![ - row!(!["NoteRange", Tui::bold(true, format!("{}-{}", self.0.note_lo(), self.0.note_hi()))]), - row!(!["NoteAxis ", Tui::bold(true, format!("{}", self.0.note_axis()))]), - "" - ])))?; + row!(![" Loop ", Tui::bold(true, format!("on"))])])))?; + add(&Tui::fixed_xy(25, 3, col!(![ + row!(!["Time ", Tui::bold(true, format!("{}", self.0.time_point()))]), + row!(!["View ", Tui::bold(true, format!("{}-{} ({}*{})", + self.0.time_start(), + self.0.time_end(), + self.0.time_axis(), + self.0.time_zoom()))])])))?; + add(&Tui::fixed_xy(25, 3, col!(![ + row!(!["Note ", Tui::bold(true, format!("{:4} ({:3}) {:4}", + to_note_name(self.0.note_point()), + self.0.note_point(), + self.0.note_len()))]), + row!(!["View ", Tui::bold(true, format!("{}-{} ({})", + to_note_name(self.0.note_lo()), + to_note_name(self.0.note_hi()), + self.0.note_axis()))])])))?; + add(&Tui::fixed_xy(16, 3, col!(![ + row!(!["TimeLock ", Tui::bold(true, format!("{}", self.0.time_lock()))])])))?; Ok(()) })))) }));