mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
PhraseCommand -> MidiEditCommand
This commit is contained in:
parent
7f55c3bfc8
commit
57158d4d6f
4 changed files with 15 additions and 15 deletions
|
|
@ -11,7 +11,7 @@ use ClockCommand::{Play, Pause};
|
||||||
Select(ArrangerSelection),
|
Select(ArrangerSelection),
|
||||||
Zoom(usize),
|
Zoom(usize),
|
||||||
Phrases(PoolCommand),
|
Phrases(PoolCommand),
|
||||||
Editor(PhraseCommand),
|
Editor(MidiEditCommand),
|
||||||
StopAll,
|
StopAll,
|
||||||
Clear,
|
Clear,
|
||||||
}
|
}
|
||||||
|
|
@ -57,7 +57,7 @@ input_to_command!(ArrangerCommand: <Tui>|state: ArrangerTui, input|match input.e
|
||||||
key_pat!(Shift-Char(' ')) =>
|
key_pat!(Shift-Char(' ')) =>
|
||||||
Self::Clock(if state.clock().is_stopped() { Play(Some(0)) } else { Pause(Some(0)) }),
|
Self::Clock(if state.clock().is_stopped() { Play(Some(0)) } else { Pause(Some(0)) }),
|
||||||
key_pat!(Char('e')) =>
|
key_pat!(Char('e')) =>
|
||||||
Self::Editor(PhraseCommand::Show(Some(state.phrases.phrase().clone()))),
|
Self::Editor(MidiEditCommand::Show(Some(state.phrases.phrase().clone()))),
|
||||||
key_pat!(Ctrl-Left) =>
|
key_pat!(Ctrl-Left) =>
|
||||||
Self::Scene(ArrangerSceneCommand::Add),
|
Self::Scene(ArrangerSceneCommand::Add),
|
||||||
key_pat!(Ctrl-Char('t')) =>
|
key_pat!(Ctrl-Char('t')) =>
|
||||||
|
|
@ -152,7 +152,7 @@ input_to_command!(ArrangerCommand: <Tui>|state: ArrangerTui, input|match input.e
|
||||||
_ => None
|
_ => None
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}.or_else(||if let Some(command) = PhraseCommand::input_to_command(&state.editor, input) {
|
}.or_else(||if let Some(command) = MidiEditCommand::input_to_command(&state.editor, input) {
|
||||||
Some(Self::Editor(command))
|
Some(Self::Editor(command))
|
||||||
} else if let Some(command) = PoolCommand::input_to_command(&state.phrases, input) {
|
} else if let Some(command) = PoolCommand::input_to_command(&state.phrases, input) {
|
||||||
Some(Self::Phrases(command))
|
Some(Self::Phrases(command))
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use super::*;
|
||||||
use KeyCode::{Char, Delete, Tab, Up, Down, Left, Right};
|
use KeyCode::{Char, Delete, Tab, Up, Down, Left, Right};
|
||||||
use ClockCommand::{Play, Pause};
|
use ClockCommand::{Play, Pause};
|
||||||
use GrooveboxCommand as Cmd;
|
use GrooveboxCommand as Cmd;
|
||||||
use PhraseCommand::*;
|
use MidiEditCommand::*;
|
||||||
use PhrasePoolCommand::*;
|
use PhrasePoolCommand::*;
|
||||||
|
|
||||||
pub struct Groovebox {
|
pub struct Groovebox {
|
||||||
|
|
@ -183,7 +183,7 @@ pub enum GrooveboxCommand {
|
||||||
History(isize),
|
History(isize),
|
||||||
Clock(ClockCommand),
|
Clock(ClockCommand),
|
||||||
Pool(PoolCommand),
|
Pool(PoolCommand),
|
||||||
Editor(PhraseCommand),
|
Editor(MidiEditCommand),
|
||||||
Enqueue(Option<Arc<RwLock<MidiClip>>>),
|
Enqueue(Option<Arc<RwLock<MidiClip>>>),
|
||||||
Sampler(SamplerCommand),
|
Sampler(SamplerCommand),
|
||||||
}
|
}
|
||||||
|
|
@ -230,7 +230,7 @@ input_to_command!(GrooveboxCommand: <Tui>|state: Groovebox, input|match input.ev
|
||||||
|
|
||||||
// For the rest, use the default keybindings of the components.
|
// For the rest, use the default keybindings of the components.
|
||||||
// The ones defined above supersede them.
|
// The ones defined above supersede them.
|
||||||
_ => if let Some(command) = PhraseCommand::input_to_command(&state.editor, input) {
|
_ => if let Some(command) = MidiEditCommand::input_to_command(&state.editor, input) {
|
||||||
Cmd::Editor(command)
|
Cmd::Editor(command)
|
||||||
} else if let Some(command) = PoolCommand::input_to_command(&state.pool, input) {
|
} else if let Some(command) = PoolCommand::input_to_command(&state.pool, input) {
|
||||||
Cmd::Pool(command)
|
Cmd::Pool(command)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use KeyCode::{Char, Up, Down, Left, Right, Enter};
|
use KeyCode::{Char, Up, Down, Left, Right, Enter};
|
||||||
use PhraseCommand::*;
|
use MidiEditCommand::*;
|
||||||
|
|
||||||
pub trait HasEditor {
|
pub trait HasEditor {
|
||||||
fn editor (&self) -> &MidiEditor;
|
fn editor (&self) -> &MidiEditor;
|
||||||
|
|
@ -15,7 +15,7 @@ pub trait HasEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum PhraseCommand {
|
pub enum MidiEditCommand {
|
||||||
// TODO: 1-9 seek markers that by default start every 8th of the phrase
|
// TODO: 1-9 seek markers that by default start every 8th of the phrase
|
||||||
AppendNote,
|
AppendNote,
|
||||||
PutNote,
|
PutNote,
|
||||||
|
|
@ -29,12 +29,12 @@ pub enum PhraseCommand {
|
||||||
Show(Option<Arc<RwLock<MidiClip>>>),
|
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];
|
pub(crate) type KeyMapping<const N: usize, E, T, U> = [(E, &'static dyn Fn(&T)->U);N];
|
||||||
|
|
||||||
impl MidiEditor {
|
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-Up), &|s: &Self|SetNoteScroll(s.note_point() + 3)),
|
||||||
(kexp!(Ctrl-Alt-Down), &|s: &Self|SetNoteScroll(s.note_point().saturating_sub(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()))),
|
(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> {
|
fn execute (self, state: &mut MidiEditor) -> Perhaps<Self> {
|
||||||
use PhraseCommand::*;
|
use MidiEditCommand::*;
|
||||||
match self {
|
match self {
|
||||||
Show(phrase) => { state.set_phrase(phrase.as_ref()); },
|
Show(phrase) => { state.set_phrase(phrase.as_ref()); },
|
||||||
PutNote => { state.put_note(false); },
|
PutNote => { state.put_note(false); },
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use crate::*;
|
||||||
use ClockCommand::{Play, Pause};
|
use ClockCommand::{Play, Pause};
|
||||||
use KeyCode::{Tab, Char};
|
use KeyCode::{Tab, Char};
|
||||||
use SequencerCommand as Cmd;
|
use SequencerCommand as Cmd;
|
||||||
use PhraseCommand::*;
|
use MidiEditCommand::*;
|
||||||
use PhrasePoolCommand::*;
|
use PhrasePoolCommand::*;
|
||||||
/// Root view for standalone `tek_sequencer`.
|
/// Root view for standalone `tek_sequencer`.
|
||||||
pub struct SequencerTui {
|
pub struct SequencerTui {
|
||||||
|
|
@ -95,7 +95,7 @@ handle!(<Tui>|self:SequencerTui,input|SequencerCommand::execute_with_state(self,
|
||||||
History(isize),
|
History(isize),
|
||||||
Clock(ClockCommand),
|
Clock(ClockCommand),
|
||||||
Pool(PoolCommand),
|
Pool(PoolCommand),
|
||||||
Editor(PhraseCommand),
|
Editor(MidiEditCommand),
|
||||||
Enqueue(Option<Arc<RwLock<MidiClip>>>),
|
Enqueue(Option<Arc<RwLock<MidiClip>>>),
|
||||||
}
|
}
|
||||||
input_to_command!(SequencerCommand: <Tui>|state: SequencerTui, input|match input.event() {
|
input_to_command!(SequencerCommand: <Tui>|state: SequencerTui, input|match input.event() {
|
||||||
|
|
@ -133,7 +133,7 @@ input_to_command!(SequencerCommand: <Tui>|state: SequencerTui, input|match input
|
||||||
},
|
},
|
||||||
// For the rest, use the default keybindings of the components.
|
// For the rest, use the default keybindings of the components.
|
||||||
// The ones defined above supersede them.
|
// The ones defined above supersede them.
|
||||||
_ => if let Some(command) = PhraseCommand::input_to_command(&state.editor, input) {
|
_ => if let Some(command) = MidiEditCommand::input_to_command(&state.editor, input) {
|
||||||
Cmd::Editor(command)
|
Cmd::Editor(command)
|
||||||
} else if let Some(command) = PoolCommand::input_to_command(&state.phrases, input) {
|
} else if let Some(command) = PoolCommand::input_to_command(&state.phrases, input) {
|
||||||
Cmd::Pool(command)
|
Cmd::Pool(command)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue