implement phrase autoselect for arranger

This commit is contained in:
🪞👃🪞 2024-12-23 20:05:36 +01:00
parent 3a4f069aa6
commit b956fabe70

View file

@ -261,7 +261,6 @@ command!(|self:ArrangerCommand,state:ArrangerTui|{
Scene(cmd) => cmd.execute(state)?.map(Scene),
Track(cmd) => cmd.execute(state)?.map(Track),
Clip(cmd) => cmd.execute(state)?.map(Clip),
Phrases(cmd) => cmd.execute(&mut state.phrases)?.map(Phrases),
Editor(cmd) => cmd.execute(&mut state.editor)?.map(Editor),
Clock(cmd) => cmd.execute(state)?.map(Clock),
Zoom(_) => { todo!(); },
@ -278,6 +277,26 @@ command!(|self:ArrangerCommand,state:ArrangerTui|{
state.show_pool = show;
None
},
Phrases(cmd) => {
let mut default = |cmd: PhrasesCommand|cmd
.execute(&mut state.phrases)
.map(|x|x.map(Phrases));
match cmd {
// autoselect: automatically load selected phrase in editor
PhrasesCommand::Select(_) => {
let undo = default(cmd)?;
state.editor.set_phrase(Some(state.phrases.phrase()));
undo
},
// update color in all places simultaneously
PhrasesCommand::Phrase(PhrasePoolCommand::SetColor(index, _)) => {
let undo = default(cmd)?;
state.editor.set_phrase(Some(state.phrases.phrase()));
undo
},
_ => default(cmd)?
}
},
_ => { todo!() }
}
});