wip: p.55, e=95

This commit is contained in:
🪞👃🪞 2024-11-18 22:05:11 +01:00
parent 54fb5b6ece
commit 37ac7823af
10 changed files with 272 additions and 219 deletions

View file

@ -60,10 +60,10 @@ impl InputToCommand<Tui, SequencerTui> for SequencerCommand {
key!(KeyCode::Down) => Some(Self::Focus(Down)),
key!(KeyCode::Left) => Some(Self::Focus(Left)),
key!(KeyCode::Right) => Some(Self::Focus(Right)),
_ => Some(Self::App(match state.focused() {
_ => Some(match state.focused() {
SequencerFocus::Transport => {
use TransportCommand::{Clock, Playhead};
match TransportCommand::input_to_command(view, input)? {
match TransportCommand::input_to_command(state, input)? {
Clock(command) => {
todo!()
},
@ -72,18 +72,20 @@ impl InputToCommand<Tui, SequencerTui> for SequencerCommand {
},
}
},
SequencerFocus::Phrases =>
PhrasesCommand::input_to_command(&state.phrases, input).map(Phrases),
SequencerFocus::PhraseEditor =>
PhraseCommand::input_to_command(&state.editor, input).map(Editor),
SequencerFocus::Phrases => {
PhrasesCommand::input_to_command(state, input).map(Phrases)
},
SequencerFocus::PhraseEditor => {
PhraseCommand::input_to_command(state, input).map(Editor)
},
_ => return None,
}))
})
}
}
}
impl<T: ArrangerControl> InputToCommand<Tui, T> for ArrangerCommand {
fn input_to_command (view: &T, input: &TuiInput) -> Option<Self> {
fn input_to_command (state: &T, input: &TuiInput) -> Option<Self> {
use FocusCommand::*;
use ArrangerCommand::*;
Some(match input.event() {
@ -97,13 +99,11 @@ impl<T: ArrangerControl> InputToCommand<Tui, T> for ArrangerCommand {
key!(KeyCode::Right) => Self::Focus(Right),
key!(KeyCode::Enter) => Self::Focus(Enter),
key!(KeyCode::Esc) => Self::Focus(Exit),
key!(KeyCode::Char(' ')) => {
Self::App(Playhead(PlayheadCommand::Play(None)))
},
_ => Self::App(match view.focused() {
key!(KeyCode::Char(' ')) => Self::Playhead(PlayheadCommand::Play(None)),
_ => match state.focused() {
ArrangerFocus::Transport => {
use TransportCommand::{Clock, Playhead};
match TransportCommand::input_to_command(view, input)? {
match TransportCommand::input_to_command(state, input)? {
Clock(command) => {
todo!()
},
@ -113,14 +113,14 @@ impl<T: ArrangerControl> InputToCommand<Tui, T> for ArrangerCommand {
}
},
ArrangerFocus::PhraseEditor => Editor(
PhraseCommand::input_to_command(&view.editor, input)?
PhraseCommand::input_to_command(state, input)?
),
ArrangerFocus::PhrasePool => match input.event() {
key!(KeyCode::Char('e')) => EditPhrase(
Some(view.phrase().clone())
Some(state.phrase().clone())
),
_ => Phrases(
PhrasePoolCommand::input_to_command(view, input)?
PhrasePoolCommand::input_to_command(state, input)?
)
},
ArrangerFocus::Arranger => {
@ -129,32 +129,32 @@ impl<T: ArrangerControl> InputToCommand<Tui, T> for ArrangerCommand {
use ArrangerClipCommand as Clip;
use ArrangerSceneCommand as Scene;
match input.event() {
key!(KeyCode::Char('e')) => EditPhrase(view.phrase()),
key!(KeyCode::Char('e')) => EditPhrase(state.phrase()),
_ => match input.event() {
// FIXME: boundary conditions
key!(KeyCode::Up) => match view.selected() {
key!(KeyCode::Up) => match state.selected() {
Select::Mix => return None,
Select::Track(t) => return None,
Select::Scene(s) => Select(Select::Scene(s - 1)),
Select::Clip(t, s) => Select(Select::Clip(t, s - 1)),
},
key!(KeyCode::Down) => match view.selected() {
key!(KeyCode::Down) => match state.selected() {
Select::Mix => Select(Select::Scene(0)),
Select::Track(t) => Select(Select::Clip(t, 0)),
Select::Scene(s) => Select(Select::Scene(s + 1)),
Select::Clip(t, s) => Select(Select::Clip(t, s + 1)),
},
key!(KeyCode::Left) => match view.selected() {
key!(KeyCode::Left) => match state.selected() {
Select::Mix => return None,
Select::Track(t) => Select(Select::Track(t - 1)),
Select::Scene(s) => return None,
Select::Clip(t, s) => Select(Select::Clip(t - 1, s)),
},
key!(KeyCode::Right) => match view.selected() {
key!(KeyCode::Right) => match state.selected() {
Select::Mix => return None,
Select::Track(t) => Select(Select::Track(t + 1)),
Select::Scene(s) => Select(Select::Clip(0, s)),
@ -169,44 +169,44 @@ impl<T: ArrangerControl> InputToCommand<Tui, T> for ArrangerCommand {
key!(KeyCode::Char('-')) => Zoom(0),
key!(KeyCode::Char('`')) => { todo!("toggle view mode") },
key!(KeyCode::Char('`')) => { todo!("toggle state mode") },
key!(KeyCode::Char(',')) => match view.selected() {
key!(KeyCode::Char(',')) => match state.selected() {
Select::Mix => Zoom(0),
Select::Track(t) => Track(Track::Swap(t, t - 1)),
Select::Scene(s) => Scene(Scene::Swap(s, s - 1)),
Select::Clip(t, s) => Clip(Clip::Set(t, s, None)),
},
key!(KeyCode::Char('.')) => match view.selected() {
key!(KeyCode::Char('.')) => match state.selected() {
Select::Mix => Zoom(0),
Select::Track(t) => Track(Track::Swap(t, t + 1)),
Select::Scene(s) => Scene(Scene::Swap(s, s + 1)),
Select::Clip(t, s) => Clip(Clip::Set(t, s, None)),
},
key!(KeyCode::Char('<')) => match view.selected() {
key!(KeyCode::Char('<')) => match state.selected() {
Select::Mix => Zoom(0),
Select::Track(t) => Track(Track::Swap(t, t - 1)),
Select::Scene(s) => Scene(Scene::Swap(s, s - 1)),
Select::Clip(t, s) => Clip(Clip::Set(t, s, None)),
},
key!(KeyCode::Char('>')) => match view.selected() {
key!(KeyCode::Char('>')) => match state.selected() {
Select::Mix => Zoom(0),
Select::Track(t) => Track(Track::Swap(t, t + 1)),
Select::Scene(s) => Scene(Scene::Swap(s, s + 1)),
Select::Clip(t, s) => Clip(Clip::Set(t, s, None)),
},
key!(KeyCode::Enter) => match view.selected() {
key!(KeyCode::Enter) => match state.selected() {
Select::Mix => return None,
Select::Track(t) => return None,
Select::Scene(s) => Scene(Scene::Play(s)),
Select::Clip(t, s) => return None,
},
key!(KeyCode::Delete) => match view.selected() {
key!(KeyCode::Delete) => match state.selected() {
Select::Mix => Clear,
Select::Track(t) => Track(Track::Delete(t)),
Select::Scene(s) => Scene(Scene::Delete(s)),
@ -215,12 +215,12 @@ impl<T: ArrangerControl> InputToCommand<Tui, T> for ArrangerCommand {
key!(KeyCode::Char('c')) => Clip(Clip::RandomColor),
key!(KeyCode::Char('s')) => match view.selected() {
key!(KeyCode::Char('s')) => match state.selected() {
Select::Clip(t, s) => Clip(Clip::Set(t, s, None)),
_ => return None,
},
key!(KeyCode::Char('g')) => match view.selected() {
key!(KeyCode::Char('g')) => match state.selected() {
Select::Clip(t, s) => Clip(Clip::Get(t, s)),
_ => return None,
},
@ -235,13 +235,13 @@ impl<T: ArrangerControl> InputToCommand<Tui, T> for ArrangerCommand {
}
}
}
})
}
})
}
}
impl InputToCommand<Tui, PhrasesTui> for PhrasesCommand {
fn input_to_command (state: &PhrasesTui, input: &TuiInput) -> Option<Self> {
impl<T: PhrasesControl> InputToCommand<Tui, T> for PhrasesCommand {
fn input_to_command (state: &T, input: &TuiInput) -> Option<Self> {
use PhrasesCommand as Cmd;
use PhrasePoolCommand as Edit;
use PhraseRenameCommand as Rename;
@ -258,7 +258,7 @@ impl InputToCommand<Tui, PhrasesTui> for PhrasesCommand {
key!(KeyCode::Char('c')) => Some(Cmd::Edit(Edit::RandomColor(0))),
key!(KeyCode::Char('n')) => Some(Cmd::Rename(Rename::Begin)),
key!(KeyCode::Char('t')) => Some(Cmd::Length(Length::Begin)),
_ => match state.mode {
_ => match state.phrases_mode() {
Some(PhrasesMode::Rename(..)) => {
Rename::input_to_command(state, input).map(Cmd::Rename)
},
@ -271,9 +271,9 @@ impl InputToCommand<Tui, PhrasesTui> for PhrasesCommand {
}
}
impl InputToCommand<Tui, PhrasesTui> for PhraseLengthCommand {
fn input_to_command (view: &PhrasesTui, from: &TuiInput) -> Option<Self> {
if let Some(PhrasesMode::Length(_, length, _)) = view.mode {
impl<T: PhrasesControl> InputToCommand<Tui, T> for PhraseLengthCommand {
fn input_to_command (state: &T, from: &TuiInput) -> Option<Self> {
if let Some(PhrasesMode::Length(_, length, _)) = state.phrases_mode() {
Some(match from.event() {
key!(KeyCode::Up) => Self::Inc,
key!(KeyCode::Down) => Self::Dec,
@ -289,9 +289,9 @@ impl InputToCommand<Tui, PhrasesTui> for PhraseLengthCommand {
}
}
impl InputToCommand<Tui, PhrasesTui> for PhraseRenameCommand {
fn input_to_command (view: &PhrasesTui, from: &TuiInput) -> Option<Self> {
if let Some(PhrasesMode::Rename(_, ref old_name)) = view.mode {
impl<T: PhrasesControl> InputToCommand<Tui, T> for PhraseRenameCommand {
fn input_to_command (state: &T, from: &TuiInput) -> Option<Self> {
if let Some(PhrasesMode::Rename(_, ref old_name)) = state.phrases_mode() {
Some(match from.event() {
key!(KeyCode::Char(c)) => {
let mut new_name = old_name.clone();
@ -313,8 +313,8 @@ impl InputToCommand<Tui, PhrasesTui> for PhraseRenameCommand {
}
}
impl InputToCommand<Tui, PhraseTui> for PhraseCommand {
fn input_to_command (state: &PhraseTui, from: &TuiInput) -> Option<Self> {
impl<T: PhraseControl> InputToCommand<Tui, T> for PhraseCommand {
fn input_to_command (state: &T, from: &TuiInput) -> Option<Self> {
use PhraseCommand::*;
Some(match from.event() {
key!(KeyCode::Char('`')) => ToggleDirection,
@ -330,19 +330,19 @@ impl InputToCommand<Tui, PhraseTui> for PhraseCommand {
key!(KeyCode::Char('+')) => TimeZoomSet(0),
key!(KeyCode::PageUp) => NoteScrollSet(0),
key!(KeyCode::PageDown) => NoteScrollSet(0),
key!(KeyCode::Up) => match state.entered {
key!(KeyCode::Up) => match state.phrase_entered() {
true => NoteCursorSet(0),
false => NoteScrollSet(0),
},
key!(KeyCode::Down) => match state.entered {
key!(KeyCode::Down) => match state.phrase_entered() {
true => NoteCursorSet(0),
false => NoteScrollSet(0),
},
key!(KeyCode::Left) => match state.entered {
key!(KeyCode::Left) => match state.phrase_entered() {
true => TimeCursorSet(0),
false => TimeScrollSet(0),
},
key!(KeyCode::Right) => match state.entered {
key!(KeyCode::Right) => match state.phrase_entered() {
true => TimeCursorSet(0),
false => TimeScrollSet(0),
},