mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
fix arrow keys fallthrough in arranger
This commit is contained in:
parent
6319c0db2d
commit
7186ec3979
2 changed files with 95 additions and 7 deletions
|
|
@ -3,6 +3,9 @@ name = "tek"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
lto = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
#no_deadlocks = "1.3.2"
|
#no_deadlocks = "1.3.2"
|
||||||
#vst3 = "0.1.0"
|
#vst3 = "0.1.0"
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,99 @@ input_to_command!(ArrangerCommand: <Tui>|state: ArrangerTui, input|match input.e
|
||||||
// Tab: Toggle visibility of phrase pool column
|
// Tab: Toggle visibility of phrase pool column
|
||||||
key_pat!(Tab) =>
|
key_pat!(Tab) =>
|
||||||
Self::Phrases(PhrasesCommand::Show(!state.phrases.visible)),
|
Self::Phrases(PhrasesCommand::Show(!state.phrases.visible)),
|
||||||
_ => to_arrangement_command(state, input).or_else(||{
|
_ => {
|
||||||
if let Some(command) = PhraseCommand::input_to_command(&state.editor, input) {
|
use ArrangerCommand as Cmd;
|
||||||
Some(Self::Editor(command))
|
use ArrangerSelection as Selected;
|
||||||
} else if let Some(command) = PhrasesCommand::input_to_command(&state.phrases, input) {
|
use ArrangerSceneCommand as Scene;
|
||||||
Some(Self::Phrases(command))
|
use ArrangerTrackCommand as Track;
|
||||||
} else {
|
use ArrangerClipCommand as Clip;
|
||||||
None
|
let t_len = state.tracks.len();
|
||||||
|
let s_len = state.scenes.len();
|
||||||
|
match state.selected() {
|
||||||
|
Selected::Clip(t, s) => match input.event() {
|
||||||
|
key_pat!(Char('g')) => Some(Cmd::Phrases(PhrasesCommand::Select(0))),
|
||||||
|
key_pat!(Char('q')) => Some(Cmd::Clip(Clip::Enqueue(t, s))),
|
||||||
|
key_pat!(Char(',')) => Some(Cmd::Clip(Clip::Put(t, s, None))),
|
||||||
|
key_pat!(Char('.')) => Some(Cmd::Clip(Clip::Put(t, s, None))),
|
||||||
|
key_pat!(Char('<')) => Some(Cmd::Clip(Clip::Put(t, s, None))),
|
||||||
|
key_pat!(Char('>')) => Some(Cmd::Clip(Clip::Put(t, s, None))),
|
||||||
|
key_pat!(Char('p')) => Some(Cmd::Clip(Clip::Put(t, s, Some(state.phrases.phrase().clone())))),
|
||||||
|
key_pat!(Char('l')) => Some(Cmd::Clip(ArrangerClipCommand::SetLoop(t, s, false))),
|
||||||
|
key_pat!(Delete) => Some(Cmd::Clip(Clip::Put(t, s, None))),
|
||||||
|
|
||||||
|
key_pat!(Up) => Some(Cmd::Select(
|
||||||
|
if s > 0 { Selected::Clip(t, s - 1) } else { Selected::Track(t) })),
|
||||||
|
key_pat!(Down) => Some(Cmd::Select(
|
||||||
|
Selected::Clip(t, (s + 1).min(s_len.saturating_sub(1))))),
|
||||||
|
key_pat!(Left) => Some(Cmd::Select(
|
||||||
|
if t > 0 { Selected::Clip(t - 1, s) } else { Selected::Scene(s) })),
|
||||||
|
key_pat!(Right) => Some(Cmd::Select(
|
||||||
|
Selected::Clip((t + 1).min(t_len.saturating_sub(1)), s))),
|
||||||
|
|
||||||
|
_ => None
|
||||||
|
},
|
||||||
|
Selected::Scene(s) => match input.event() {
|
||||||
|
key_pat!(Char(',')) => Some(Cmd::Scene(Scene::Swap(s, s - 1))),
|
||||||
|
key_pat!(Char('.')) => Some(Cmd::Scene(Scene::Swap(s, s + 1))),
|
||||||
|
key_pat!(Char('<')) => Some(Cmd::Scene(Scene::Swap(s, s - 1))),
|
||||||
|
key_pat!(Char('>')) => Some(Cmd::Scene(Scene::Swap(s, s + 1))),
|
||||||
|
key_pat!(Char('q')) => Some(Cmd::Scene(Scene::Enqueue(s))),
|
||||||
|
key_pat!(Delete) => Some(Cmd::Scene(Scene::Delete(s))),
|
||||||
|
key_pat!(Char('c')) => Some(Cmd::Scene(Scene::SetColor(s, ItemPalette::random()))),
|
||||||
|
|
||||||
|
key_pat!(Up) => Some(
|
||||||
|
Cmd::Select(if s > 0 { Selected::Scene(s - 1) } else { Selected::Mix })),
|
||||||
|
key_pat!(Down) => Some(
|
||||||
|
Cmd::Select(Selected::Scene((s + 1).min(s_len.saturating_sub(1))))),
|
||||||
|
key_pat!(Left) =>
|
||||||
|
return None,
|
||||||
|
key_pat!(Right) => Some(
|
||||||
|
Cmd::Select(Selected::Clip(0, s))),
|
||||||
|
|
||||||
|
_ => None
|
||||||
|
},
|
||||||
|
Selected::Track(t) => match input.event() {
|
||||||
|
key_pat!(Char(',')) => Some(Cmd::Track(Track::Swap(t, t - 1))),
|
||||||
|
key_pat!(Char('.')) => Some(Cmd::Track(Track::Swap(t, t + 1))),
|
||||||
|
key_pat!(Char('<')) => Some(Cmd::Track(Track::Swap(t, t - 1))),
|
||||||
|
key_pat!(Char('>')) => Some(Cmd::Track(Track::Swap(t, t + 1))),
|
||||||
|
key_pat!(Delete) => Some(Cmd::Track(Track::Delete(t))),
|
||||||
|
key_pat!(Char('c')) => Some(Cmd::Track(Track::SetColor(t, ItemPalette::random()))),
|
||||||
|
|
||||||
|
key_pat!(Up) =>
|
||||||
|
return None,
|
||||||
|
key_pat!(Down) => Some(
|
||||||
|
Cmd::Select(Selected::Clip(t, 0))),
|
||||||
|
key_pat!(Left) => Some(
|
||||||
|
Cmd::Select(if t > 0 { Selected::Track(t - 1) } else { Selected::Mix })),
|
||||||
|
key_pat!(Right) => Some(
|
||||||
|
Cmd::Select(Selected::Track((t + 1).min(t_len.saturating_sub(1))))),
|
||||||
|
|
||||||
|
_ => None
|
||||||
|
},
|
||||||
|
Selected::Mix => match input.event() {
|
||||||
|
key_pat!(Delete) => Some(Cmd::Clear),
|
||||||
|
key_pat!(Char('0')) => Some(Cmd::StopAll),
|
||||||
|
key_pat!(Char('c')) => Some(Cmd::Color(ItemPalette::random())),
|
||||||
|
|
||||||
|
key_pat!(Up) =>
|
||||||
|
return None,
|
||||||
|
key_pat!(Down) => Some(
|
||||||
|
Cmd::Select(Selected::Scene(0))),
|
||||||
|
key_pat!(Left) =>
|
||||||
|
return None,
|
||||||
|
key_pat!(Right) => Some(
|
||||||
|
Cmd::Select(Selected::Track(0))),
|
||||||
|
|
||||||
|
_ => None
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
}.or_else(||if let Some(command) = PhraseCommand::input_to_command(&state.editor, input) {
|
||||||
|
Some(Self::Editor(command))
|
||||||
|
} else if let Some(command) = PhrasesCommand::input_to_command(&state.phrases, input) {
|
||||||
|
Some(Self::Phrases(command))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
})?
|
})?
|
||||||
});
|
});
|
||||||
fn to_arrangement_command (state: &ArrangerTui, input: &TuiInput) -> Option<ArrangerCommand> {
|
fn to_arrangement_command (state: &ArrangerTui, input: &TuiInput) -> Option<ArrangerCommand> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue