mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
groovebox: record at selected pitch
This commit is contained in:
parent
7b09d97473
commit
5648c96c6a
1 changed files with 31 additions and 23 deletions
|
|
@ -287,29 +287,6 @@ handle!(TuiIn: |self: App, input|Ok(if let Some(command) = self.config.keys.comm
|
||||||
app.toggle_editor(Some(value));
|
app.toggle_editor(Some(value));
|
||||||
Ok(None)
|
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> {
|
fn color (app: &mut App, theme: ItemTheme) -> Perhaps<Self> {
|
||||||
Ok(app.set_color(Some(theme)).map(|theme|Self::Color{theme}))
|
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> {
|
fn message (app: &mut App, command: MessageCommand) -> Perhaps<Self> {
|
||||||
Ok(command.delegate(app, |command|Self::Message{command})?)
|
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 {
|
impl<'state> Context<'state, ClockCommand> for App {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue