separate input handling for sampler

This commit is contained in:
🪞👃🪞 2025-04-25 20:50:32 +03:00
parent b58fbdfd30
commit b376d75396
11 changed files with 114 additions and 36 deletions

View file

@ -543,27 +543,55 @@ impose!([app: Tek] {
});
handle!(TuiIn: |self: Tek, input|Ok({
handle!(TuiIn: |self: Tek, input|if let Some(handler) = self.handler {
handler(self, input)
} else {
Ok(None)
});
pub fn handle_arranger (app: &mut Tek, input: &TuiIn) -> Perhaps<bool> {
// If editing, editor keys take priority
if self.is_editing() {
if self.editor.handle(input)? == Some(true) {
if app.is_editing() {
if app.editor.handle(input)? == Some(true) {
return Ok(Some(true))
}
}
// Handle from root keymap
if let Some(command) = self.keys.command::<_, TekCommand, _>(self, input) {
if let Some(undo) = command.execute(self)? { self.history.push(undo); }
if let Some(command) = SourceIter(include_str!("../edn/arranger_keys.edn"))
.command::<_, TekCommand, _>(app, input)
{
if let Some(undo) = command.execute(app)? { app.history.push(undo); }
return Ok(Some(true))
}
// Handle from selection-dependent keymaps
if let Some(command) = match self.selected() {
Selection::Clip(_, _) => self.keys_clip,
Selection::Track(_) => self.keys_track,
Selection::Scene(_) => self.keys_scene,
Selection::Mix => self.keys_mix,
}.command::<_, TekCommand, _>(self, input) {
if let Some(undo) = command.execute(self)? { self.history.push(undo); }
if let Some(command) = match app.selected() {
Selection::Clip(_, _) => SourceIter(include_str!("../edn/arranger_keys_clip.edn")),
Selection::Track(_) => SourceIter(include_str!("../edn/arranger_keys_track.edn")),
Selection::Scene(_) => SourceIter(include_str!("../edn/arranger_keys_scene.edn")),
Selection::Mix => SourceIter(include_str!("../edn/arranger_keys_mix.edn")),
}.command::<_, TekCommand, _>(app, input) {
if let Some(undo) = command.execute(app)? {
app.history.push(undo);
}
return Ok(Some(true))
}
None
}));
Ok(None)
}
pub fn handle_sampler (app: &mut Tek, input: &TuiIn) -> Perhaps<bool> {
let sampler = app.tracks[0].sampler_mut(0).expect("no sampler");
if let Some(command) = SourceIter(include_str!("../edn/sampler_keys.edn"))
.command::<_, SamplerCommand, _>(sampler, input)
{
if let Some(undo) = command.execute(sampler)? {
//app.history.push(undo); // TODO UNDO
}
return Ok(Some(true))
}
Ok(None)
}