PhraseCommand -> MidiEditCommand

This commit is contained in:
🪞👃🪞 2025-01-02 13:35:35 +01:00
parent 7f55c3bfc8
commit 57158d4d6f
4 changed files with 15 additions and 15 deletions

View file

@ -1,6 +1,6 @@
use crate::*;
use KeyCode::{Char, Up, Down, Left, Right, Enter};
use PhraseCommand::*;
use MidiEditCommand::*;
pub trait HasEditor {
fn editor (&self) -> &MidiEditor;
@ -15,7 +15,7 @@ pub trait HasEditor {
}
#[derive(Clone, Debug)]
pub enum PhraseCommand {
pub enum MidiEditCommand {
// TODO: 1-9 seek markers that by default start every 8th of the phrase
AppendNote,
PutNote,
@ -29,12 +29,12 @@ pub enum PhraseCommand {
Show(Option<Arc<RwLock<MidiClip>>>),
}
event_map_input_to_command!(Tui: MidiEditor: PhraseCommand: MidiEditor::KEYS);
event_map_input_to_command!(Tui: MidiEditor: MidiEditCommand: MidiEditor::KEYS);
pub(crate) type KeyMapping<const N: usize, E, T, U> = [(E, &'static dyn Fn(&T)->U);N];
impl MidiEditor {
const KEYS: KeyMapping<31, Event, Self, PhraseCommand> = [
const KEYS: KeyMapping<31, Event, Self, MidiEditCommand> = [
(kexp!(Ctrl-Alt-Up), &|s: &Self|SetNoteScroll(s.note_point() + 3)),
(kexp!(Ctrl-Alt-Down), &|s: &Self|SetNoteScroll(s.note_point().saturating_sub(3))),
(kexp!(Ctrl-Alt-Left), &|s: &Self|SetTimeScroll(s.time_point().saturating_sub(s.time_zoom().get()))),
@ -74,9 +74,9 @@ impl MidiEditor {
}
}
impl Command<MidiEditor> for PhraseCommand {
impl Command<MidiEditor> for MidiEditCommand {
fn execute (self, state: &mut MidiEditor) -> Perhaps<Self> {
use PhraseCommand::*;
use MidiEditCommand::*;
match self {
Show(phrase) => { state.set_phrase(phrase.as_ref()); },
PutNote => { state.put_note(false); },