devices can be focused again

This commit is contained in:
🪞👃🪞 2024-07-09 14:53:05 +03:00
parent b673e4c68d
commit 07084656b8
5 changed files with 61 additions and 26 deletions

View file

@ -10,25 +10,40 @@ handle!{
return Ok(true)
};
}
let handle_focused = |state: &mut Self|handle_keymap(
state, e, match state.section {
AppSection::Arranger => self::arranger::KEYMAP_ARRANGER,
AppSection::Sequencer => self::sequencer::KEYMAP_SEQUENCER,
AppSection::Chain => self::chain::KEYMAP_CHAIN,
}
);
Ok(if self.entered {
handle_focused(self)?
handle_focused(self, e)?
|| handle_keymap(self, e, KEYMAP)?
|| handle_keymap(self, e, KEYMAP_FOCUS)?
} else {
handle_keymap(self, e, KEYMAP)?
|| handle_keymap(self, e, KEYMAP_FOCUS)?
|| handle_focused(self)?
|| handle_focused(self, e)?
})
}
}
fn handle_focused (state: &mut App, e: &AppEvent) -> Usually<bool> {
match state.section {
AppSection::Arranger =>
handle_keymap(state, e, crate::control::arranger::KEYMAP_ARRANGER),
AppSection::Sequencer =>
handle_keymap(state, e, crate::control::sequencer::KEYMAP_SEQUENCER),
AppSection::Chain => Ok(if state.entered {
handle_device(state, e)? || handle_keymap(state, e, crate::control::chain::KEYMAP_CHAIN)?
} else {
handle_keymap(state, e, crate::control::chain::KEYMAP_CHAIN)? || handle_device(state, e)?
})
}
}
fn handle_device (state: &mut App, e: &AppEvent) -> Usually<bool> {
state.track_mut()
.and_then(|(_, track)|track.device_mut())
.map(|mut device|device.handle(e))
.transpose()
.map(|x|x.unwrap_or(false))
}
const KEYMAP_FOCUS: &'static [KeyBinding<App>] = keymap!(App {
[Tab, NONE, "focus_next", "focus next area", focus_next],
[Tab, SHIFT, "focus_prev", "focus previous area", focus_prev],