grid -> arranger

This commit is contained in:
🪞👃🪞 2024-07-08 19:50:18 +03:00
parent d99a08bcf7
commit f1f812d0fb
5 changed files with 131 additions and 191 deletions

View file

@ -15,8 +15,8 @@ handle!(App |self, e| {
};
}
let handle_focused = |state: &mut Self|match state.section {
AppSection::Grid =>
handle_keymap(state, e, KEYMAP_GRID),
AppSection::Arranger =>
handle_keymap(state, e, KEYMAP_ARRANGER),
AppSection::Sequencer =>
handle_keymap(state, e, KEYMAP_SEQUENCER),
AppSection::Chain =>
@ -47,7 +47,6 @@ const KEYMAP_FOCUS: &'static [KeyBinding<App>] = keymap!(App {
});
const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
[F(1), NONE, "help_toggle", "toggle help", |_: &mut App| {Ok(true)}],
[Up, NONE, "focus_prev", "focus previous area", focus_prev],
@ -140,24 +139,32 @@ const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
// [Char('s'), NONE, "stop_and_rewind", "Stop and rewind", stop_and_rewind],
});
const KEYMAP_GRID: &'static [KeyBinding<App>] = keymap!(App {
[Up, NONE, "grid_cursor_up", "move cursor up", |app: &mut App| Ok(match app.grid_mode {
false => {app.scene_cursor = app.scene_cursor.saturating_sub(1); true},
true => {app.track_cursor = app.track_cursor.saturating_sub(1); true},
})],
[Down, NONE, "grid_cursor_down", "move cursor down", |app: &mut App| Ok(match app.grid_mode {
false => {app.scene_cursor = app.scenes.len().min(app.scene_cursor + 1); true},
true => {app.track_cursor = app.tracks.len().min(app.track_cursor + 1); true},
})],
[Left, NONE, "grid_cursor_left", "move cursor left", |app: &mut App| Ok(match app.grid_mode {
false => {app.track_cursor = app.track_cursor.saturating_sub(1); true},
true => {app.scene_cursor = app.scene_cursor.saturating_sub(1); true},
})],
[Right, NONE, "grid_cursor_right", "move cursor right", |app: &mut App| Ok(match app.grid_mode {
false => {app.track_cursor = app.tracks.len().min(app.track_cursor + 1); true},
true => {app.scene_cursor = app.scenes.len().min(app.scene_cursor + 1); true},
})],
[Enter, NONE, "grid_activate", "activate item at cursor", |app: &mut App| Ok(
const KEYMAP_ARRANGER: &'static [KeyBinding<App>] = keymap!(App {
[Up, NONE, "arranger_cursor_up", "move cursor up", |app: &mut App| Ok(
match app.arranger_mode {
false => {app.scene_cursor = app.scene_cursor.saturating_sub(1); true},
true => {app.track_cursor = app.track_cursor.saturating_sub(1); true},
}
)],
[Down, NONE, "arranger_cursor_down", "move cursor down", |app: &mut App| Ok(
match app.arranger_mode {
false => {app.scene_cursor = app.scenes.len().min(app.scene_cursor + 1); true},
true => {app.track_cursor = app.tracks.len().min(app.track_cursor + 1); true},
}
)],
[Left, NONE, "arranger_cursor_left", "move cursor left", |app: &mut App| Ok(
match app.arranger_mode {
false => {app.track_cursor = app.track_cursor.saturating_sub(1); true},
true => {app.scene_cursor = app.scene_cursor.saturating_sub(1); true},
}
)],
[Right, NONE, "arranger_cursor_right", "move cursor right", |app: &mut App| Ok(
match app.arranger_mode {
false => {app.track_cursor = app.tracks.len().min(app.track_cursor + 1); true},
true => {app.scene_cursor = app.scenes.len().min(app.scene_cursor + 1); true},
}
)],
[Enter, NONE, "arranger_activate", "activate item at cursor", |app: &mut App| Ok(
if app.scene_cursor == 0 {
false
} else {
@ -175,52 +182,43 @@ const KEYMAP_GRID: &'static [KeyBinding<App>] = keymap!(App {
true
}
)],
[Char('.'), NONE, "grid_increment", "set next clip at cursor", |app: &mut App| {
[Char('.'), NONE, "arranger_increment", "set next clip at cursor", |app: &mut App| {
//if state.cursor.0 >= 1 && state.cursor.1 >= 1 {
//let scene_id = state.cursor.1 - 1;
//let clip_id = state.cursor.0 - 1;
//let scene = &mut state.scenes[scene_id];
//scene.clips[clip_id] = match scene.clips[clip_id] {
//None => Some(0),
//Some(i) => if i >= state.tracks[clip_id].sequencer.phrases.len().saturating_sub(1) {
//None
//} else {
//Some(i + 1)
//}
//};
//}
Ok(true)
}],
[Char(','), NONE, "grid_decrement", "set previous clip at cursor", |app: &mut App| {
[Char(','), NONE, "arranger_decrement", "set previous clip at cursor", |app: &mut App| {
//if state.cursor.0 >= 1 && state.cursor.1 >= 1 {
//let scene_id = state.cursor.1 - 1;
//let clip_id = state.cursor.0 - 1;
//let scene = &mut state.scenes[scene_id];
//scene.clips[clip_id] = match scene.clips[clip_id] {
//None => Some(state.tracks[clip_id].sequencer.phrases.len().saturating_sub(1)),
//Some(i) => if i == 0 {
//None
//} else {
//Some(i - 1)
//}
//};
//}
Ok(true)
}],
[Char('`'), NONE, "grid_mode_switch", "switch the display mode", |app: &mut App| {
app.grid_mode = !app.seq_mode;
[Char('`'), NONE, "arranger_mode_switch", "switch the display mode", |app: &mut App| {
app.arranger_mode = !app.seq_mode;
Ok(true)
}],
});
fn clip_next (_: &mut App) -> Usually<bool> { Ok(true) }
//fn clip_next (state: &mut Launcher) -> Usually<bool> {
//if state.cursor.0 >= 1 && state.cursor.1 >= 1 {
//let scene_id = state.cursor.1 - 1;
//let clip_id = state.cursor.0 - 1;
//let scene = &mut state.scenes[scene_id];
//scene.clips[clip_id] = match scene.clips[clip_id] {
//None => Some(0),
//Some(i) => if i >= state.tracks[clip_id].sequencer.phrases.len().saturating_sub(1) {
//None
//} else {
//Some(i + 1)
//}
//};
//}
//Ok(true)
//}
fn clip_prev (_: &mut App) -> Usually<bool> { Ok(true) }
//fn clip_prev (state: &mut Launcher) -> Usually<bool> {
//if state.cursor.0 >= 1 && state.cursor.1 >= 1 {
//let scene_id = state.cursor.1 - 1;
//let clip_id = state.cursor.0 - 1;
//let scene = &mut state.scenes[scene_id];
//scene.clips[clip_id] = match scene.clips[clip_id] {
//None => Some(state.tracks[clip_id].sequencer.phrases.len().saturating_sub(1)),
//Some(i) => if i == 0 {
//None
//} else {
//Some(i - 1)
//}
//};
//}
//Ok(true)
//}
const KEYMAP_SEQUENCER: &'static [KeyBinding<App>] = keymap!(App {
[Up, NONE, "seq_cursor_up", "move cursor up", |app: &mut App| {
@ -258,8 +256,12 @@ const KEYMAP_SEQUENCER: &'static [KeyBinding<App>] = keymap!(App {
});
const KEYMAP_CHAIN: &'static [KeyBinding<App>] = keymap!(App {
[Up, NONE, "chain_cursor_up", "move cursor up", |_: &mut App| Ok(true)],
[Down, NONE, "chain_cursor_down", "move cursor down", |_: &mut App| Ok(true)],
[Up, NONE, "chain_cursor_up", "move cursor up", |_: &mut App| {
Ok(true)
}],
[Down, NONE, "chain_cursor_down", "move cursor down", |_: &mut App| {
Ok(true)
}],
[Left, NONE, "chain_cursor_left", "move cursor left", |app: &mut App| {
if let Some((_, track)) = app.track_mut() {
track.device = track.device.saturating_sub(1);
@ -303,7 +305,7 @@ fn decrement (app: &mut App) -> Usually<bool> {
fn delete (app: &mut App) -> Usually<bool> {
match app.section {
AppSection::Grid => delete_track(app),
AppSection::Arranger => delete_track(app),
_ => Ok(false)
}
}