autoselect

This commit is contained in:
🪞👃🪞 2024-12-15 02:09:49 +01:00
parent ddba9e0382
commit b799f6dbd0
2 changed files with 33 additions and 21 deletions

View file

@ -74,7 +74,17 @@ impl Command<SequencerTui> for SequencerCommand {
fn execute (self, state: &mut SequencerTui) -> Perhaps<Self> {
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"),

View file

@ -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!(![" Loop ", Tui::bold(true, format!("on"))])])))?;
add(&Tui::fixed_xy(25, 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!(!["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(())
}))))
}));