groovebox: record at selected pitch

This commit is contained in:
🪞👃🪞 2025-05-10 16:10:52 +03:00
parent 7b09d97473
commit 5648c96c6a

View file

@ -287,29 +287,6 @@ handle!(TuiIn: |self: App, input|Ok(if let Some(command) = self.config.keys.comm
app.toggle_editor(Some(value));
Ok(None)
}
fn editor (app: &mut App, command: MidiEditCommand) -> Perhaps<Self> {
Ok(app.editor.as_mut().map(|editor|command.execute(editor))
.transpose()?
.flatten()
.map(|undo|Self::Editor { command: undo }))
}
fn pool (app: &mut App, command: PoolCommand) -> Perhaps<Self> {
Ok(if let Some(pool) = app.pool.as_mut() {
let undo = command.clone().delegate(pool, |command|AppCommand::Pool{command})?;
// update linked editor after pool action
app.editor.as_mut().map(|editor|match command {
// autoselect: automatically load selected clip in editor
PoolCommand::Select { .. } |
// autocolor: update color in all places simultaneously
PoolCommand::Clip { command: PoolClipCommand::SetColor { .. } } =>
editor.set_clip(pool.clip().as_ref()),
_ => {}
});
undo
} else {
None
})
}
fn color (app: &mut App, theme: ItemTheme) -> Perhaps<Self> {
Ok(app.set_color(Some(theme)).map(|theme|Self::Color{theme}))
}
@ -369,6 +346,37 @@ handle!(TuiIn: |self: App, input|Ok(if let Some(command) = self.config.keys.comm
fn message (app: &mut App, command: MessageCommand) -> Perhaps<Self> {
Ok(command.delegate(app, |command|Self::Message{command})?)
}
fn editor (app: &mut App, command: MidiEditCommand) -> Perhaps<Self> {
Ok(if let Some(editor) = app.editor.as_mut() {
let undo = command.clone().delegate(editor, |command|AppCommand::Editor{command})?;
// update linked sampler after editor action
app.sampler_mut().map(|sampler|match command {
// autoselect: automatically select sample in sampler
MidiEditCommand::NotePos { pos } => { sampler.set_note_pos(pos); },
_ => {}
});
undo
} else {
None
})
}
fn pool (app: &mut App, command: PoolCommand) -> Perhaps<Self> {
Ok(if let Some(pool) = app.pool.as_mut() {
let undo = command.clone().delegate(pool, |command|AppCommand::Pool{command})?;
// update linked editor after pool action
app.editor.as_mut().map(|editor|match command {
// autoselect: automatically load selected clip in editor
PoolCommand::Select { .. } |
// autocolor: update color in all places simultaneously
PoolCommand::Clip { command: PoolClipCommand::SetColor { .. } } =>
editor.set_clip(pool.clip().as_ref()),
_ => {}
});
undo
} else {
None
})
}
}
impl<'state> Context<'state, ClockCommand> for App {