mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 20:26:42 +01:00
refactor control and sequencer rendering
This commit is contained in:
parent
20b7267225
commit
14d9116c7c
10 changed files with 370 additions and 405 deletions
496
src/control.rs
496
src/control.rs
|
|
@ -5,7 +5,7 @@ pub mod sampler;
|
|||
|
||||
pub use self::focus::*;
|
||||
|
||||
use crate::{core::*, handle, App};
|
||||
use crate::{core::*, handle, App, AppSection};
|
||||
|
||||
handle!(App |self, e| {
|
||||
if let Some(ref mut modal) = self.modal {
|
||||
|
|
@ -14,27 +14,81 @@ handle!(App |self, e| {
|
|||
return Ok(true)
|
||||
};
|
||||
}
|
||||
handle_keymap(self, e, KEYMAP)
|
||||
let handle_focused = |state: &mut Self|match state.section {
|
||||
AppSection::Grid =>
|
||||
handle_keymap(state, e, KEYMAP_GRID),
|
||||
AppSection::Sequencer =>
|
||||
handle_keymap(state, e, KEYMAP_SEQUENCER),
|
||||
AppSection::Chain =>
|
||||
handle_keymap(state, e, KEYMAP_CHAIN),
|
||||
};
|
||||
Ok(if self.entered {
|
||||
handle_focused(self)?
|
||||
|| handle_keymap(self, e, KEYMAP)?
|
||||
|| handle_keymap(self, e, KEYMAP_FOCUS)?
|
||||
} else {
|
||||
handle_keymap(self, e, KEYMAP)?
|
||||
|| handle_keymap(self, e, KEYMAP_FOCUS)?
|
||||
|| handle_focused(self)?
|
||||
})
|
||||
});
|
||||
|
||||
const KEYMAP_FOCUS: &'static [KeyBinding<App>] = keymap!(App {
|
||||
[Tab, NONE, "focus_next", "focus next area", focus_next],
|
||||
[Tab, SHIFT, "focus_prev", "focus previous area", focus_prev],
|
||||
[Esc, NONE, "focus_exit", "unfocus", |app: &mut App|{
|
||||
app.entered = false;
|
||||
Ok(true)
|
||||
}],
|
||||
[Enter, NONE, "focus_enter", "activate item at cursor", |app: &mut App|{
|
||||
app.entered = true;
|
||||
Ok(true)
|
||||
}],
|
||||
});
|
||||
|
||||
const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
|
||||
[Char('+'), NONE, "quant_inc", "Zoom in", |app: &mut App| {
|
||||
|
||||
[F(1), NONE, "help_toggle", "toggle help", |_: &mut App| {Ok(true)}],
|
||||
|
||||
[Up, NONE, "focus_prev", "focus previous area", focus_prev],
|
||||
[Down, NONE, "focus_next", "focus next area", focus_next],
|
||||
|
||||
[Char(' '), NONE, "play_toggle", "play or pause", |app: &mut App| {
|
||||
app.toggle_play()?;
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('r'), NONE, "record_toggle", "toggle recording", |app: &mut App| {
|
||||
app.track_mut().map(|t|t.1.toggle_record());
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('o'), NONE, "overdub_toggle", "toggle overdub", |app: &mut App| {
|
||||
app.track_mut().map(|t|t.1.toggle_overdub());
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('m'), NONE, "monitor_toggle", "toggle monitor", |app: &mut App| {
|
||||
app.track_mut().map(|t|t.1.toggle_monitor());
|
||||
Ok(true)
|
||||
}],
|
||||
|
||||
[Char('+'), NONE, "quant_inc", "Quantize coarser", |app: &mut App| {
|
||||
app.quant = next_note_length(app.quant);
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('_'), NONE, "quant_dec", "Zoom out", |app: &mut App| {
|
||||
[Char('_'), NONE, "quant_dec", "Quantize finer", |app: &mut App| {
|
||||
app.quant = prev_note_length(app.quant);
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('='), NONE, "zoom_in", "Zoom in", |app: &mut App| {
|
||||
|
||||
[Char('='), NONE, "zoom_in", "Zoom in", |app: &mut App| {
|
||||
app.time_zoom = prev_note_length(app.time_zoom);
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('-'), NONE, "zoom_out", "Zoom out", |app: &mut App| {
|
||||
[Char('-'), NONE, "zoom_out", "Zoom out", |app: &mut App| {
|
||||
app.time_zoom = next_note_length(app.time_zoom);
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('x'), NONE, "extend", "double the current clip", |app: &mut App| {
|
||||
|
||||
[Char('x'), NONE, "extend", "double the current clip", |app: &mut App| {
|
||||
if let Some(phrase) = app.phrase_mut() {
|
||||
let mut notes = BTreeMap::new();
|
||||
for (time, events) in phrase.notes.iter() {
|
||||
|
|
@ -45,6 +99,7 @@ const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
|
|||
}
|
||||
Ok(true)
|
||||
}],
|
||||
|
||||
[Char('l'), NONE, "loop_toggle", "toggle looping", |_app: &mut App| {
|
||||
// TODO: This toggles the loop flag for the clip under the cursor.
|
||||
Ok(true)
|
||||
|
|
@ -65,10 +120,8 @@ const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
|
|||
// TODO: This moves the loop end to the next quant.
|
||||
Ok(true)
|
||||
}],
|
||||
[Char(' '), NONE, "play_toggle", "play or pause", |app: &mut App| {
|
||||
app.toggle_play()?;
|
||||
Ok(true)
|
||||
}],
|
||||
|
||||
|
||||
[Char('a'), CONTROL, "scene_add", "add a new scene", |app: &mut App| {
|
||||
app.add_scene(None)?;
|
||||
Ok(true)
|
||||
|
|
@ -77,160 +130,131 @@ const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
|
|||
app.add_track(None)?;
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('`'), NONE, "mode_switch", "switch the display mode", |app: &mut App| {
|
||||
match app.section {
|
||||
0 => {app.grid_mode = !app.grid_mode; Ok(true)},
|
||||
1 => {app.chain_mode = !app.chain_mode; Ok(true)},
|
||||
2 => {app.seq_mode = !app.seq_mode; Ok(true)},
|
||||
_ => Ok(false)
|
||||
}
|
||||
}],
|
||||
[F(1), NONE, "help_toggle", "toggle help", |_: &mut App| {Ok(true)}],
|
||||
[Char('r'), NONE, "record_toggle", "toggle recording", |app: &mut App| {
|
||||
app.track_mut().map(|t|t.1.toggle_record());
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('d'), NONE, "overdub_toggle", "toggle overdub", |app: &mut App| {
|
||||
app.track_mut().map(|t|t.1.toggle_overdub());
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('m'), NONE, "monitor_toggle", "toggle input monitoring", |app: &mut App| {
|
||||
app.track_mut().map(|t|t.1.toggle_monitor());
|
||||
Ok(true)
|
||||
}],
|
||||
//fn toggle_record (s: &mut Launcher) -> Usually<bool> {
|
||||
//s.sequencer_mut().map(|s|s.recording = !s.recording);
|
||||
//Ok(true)
|
||||
//}
|
||||
|
||||
//fn toggle_overdub (s: &mut Launcher) -> Usually<bool> {
|
||||
//s.sequencer_mut().map(|s|s.overdub = !s.overdub);
|
||||
//Ok(true)
|
||||
//}
|
||||
[Char('.'), NONE, "cursor_inc", "increment value", increment],
|
||||
[Char(','), NONE, "cursor_dec", "decrement value", decrement],
|
||||
[Delete, CONTROL, "cursor_delete", "delete item at cursor", delete],
|
||||
[Char('d'), CONTROL, "cursor_duplicate", "duplicate scene or track", duplicate],
|
||||
|
||||
//fn toggle_monitor (s: &mut Launcher) -> Usually<bool> {
|
||||
//s.sequencer_mut().map(|s|s.monitoring = !s.monitoring);
|
||||
//Ok(true)
|
||||
//}
|
||||
[Tab, NONE, "focus_next", "focus next area", focus_next],
|
||||
[Tab, SHIFT, "focus_prev", "focus previous area", focus_prev],
|
||||
[Esc, NONE, "focus_out", "unfocus", escape],
|
||||
[Up, NONE, "cursor_up", "move cursor up", |app: &mut App| {
|
||||
if app.entered {
|
||||
match app.section {
|
||||
0 => match app.grid_mode {
|
||||
false => {app.scene_cursor = app.scene_cursor.saturating_sub(1); Ok(true)},
|
||||
true => {app.track_cursor = app.track_cursor.saturating_sub(1); Ok(true)},
|
||||
},
|
||||
2 => { app.note_cursor = app.note_cursor.saturating_sub(1); Ok(true) }
|
||||
_ => Ok(false)
|
||||
}
|
||||
} else {
|
||||
focus_next(app)
|
||||
}
|
||||
}],
|
||||
[Down, NONE, "cursor_down", "move cursor down", |app: &mut App| {
|
||||
if app.entered {
|
||||
match app.section {
|
||||
0 => match app.grid_mode {
|
||||
false => {app.scene_cursor = app.scenes.len().min(app.scene_cursor + 1); Ok(true)},
|
||||
true => {app.track_cursor = app.tracks.len().min(app.track_cursor + 1); Ok(true)},
|
||||
},
|
||||
2 => { app.note_cursor = app.note_cursor + 1; Ok(true) }
|
||||
_ => Ok(false)
|
||||
}
|
||||
} else {
|
||||
focus_prev(app)
|
||||
}
|
||||
}],
|
||||
[Left, NONE, "cursor_left", "move cursor left", |app: &mut App| {
|
||||
match app.section {
|
||||
0 => match app.grid_mode {
|
||||
false => {app.track_cursor = app.track_cursor.saturating_sub(1); Ok(true)},
|
||||
true => {app.scene_cursor = app.scene_cursor.saturating_sub(1); Ok(true)},
|
||||
},
|
||||
1 => {
|
||||
if let Some((_, track)) = app.track_mut() {
|
||||
track.device = track.device.saturating_sub(1);
|
||||
Ok(true)
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
},
|
||||
2 => {
|
||||
if app.entered {
|
||||
app.time_cursor = app.time_cursor.saturating_sub(1);
|
||||
} else {
|
||||
app.time_start = app.time_start.saturating_sub(1);
|
||||
}
|
||||
Ok(true)
|
||||
},
|
||||
_ => Ok(false)
|
||||
}
|
||||
}],
|
||||
[Right, NONE, "cursor_right", "move cursor right", |app: &mut App| {
|
||||
match app.section {
|
||||
0 => match app.grid_mode {
|
||||
false => {app.track_cursor = app.tracks.len().min(app.track_cursor + 1); Ok(true)},
|
||||
true => {app.scene_cursor = app.scenes.len().min(app.scene_cursor + 1); Ok(true)},
|
||||
},
|
||||
1 => {
|
||||
if let Some((_, track)) = app.track_mut() {
|
||||
track.device = (track.device + 1).min(track.devices.len().saturating_sub(1));
|
||||
Ok(true)
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
},
|
||||
2 => {
|
||||
if app.entered {
|
||||
app.time_cursor = app.time_cursor + 1;
|
||||
} else {
|
||||
app.time_start = app.time_start + 1;
|
||||
}
|
||||
Ok(true)
|
||||
},
|
||||
_ => Ok(false)
|
||||
}
|
||||
}],
|
||||
[Char('.'), NONE, "cursor_inc", "increment value", increment],
|
||||
[Char(','), NONE, "cursor_dec", "decrement value", decrement],
|
||||
[Delete, CONTROL, "cursor_delete", "delete track", delete],
|
||||
[Char('d'), CONTROL, "cursor_duplicate", "duplicate scene or track", duplicate],
|
||||
[Enter, NONE, "cursor_activate", "activate item at cursor", enter],
|
||||
//[Char('r'), CONTROL, "rename", "rename current element", rename],
|
||||
// [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(
|
||||
if app.scene_cursor == 0 {
|
||||
false
|
||||
} else {
|
||||
let scene = &app.scenes[app.scene_cursor - 1];
|
||||
if app.track_cursor == 0 {
|
||||
for (i, track) in app.tracks.iter_mut().enumerate() {
|
||||
track.sequence = scene.clips[i];
|
||||
track.reset = true;
|
||||
}
|
||||
} else {
|
||||
let track = &mut app.tracks[app.track_cursor - 1];
|
||||
track.sequence = scene.clips[app.track_cursor - 1];
|
||||
track.reset = true;
|
||||
};
|
||||
true
|
||||
}
|
||||
)],
|
||||
[Char('.'), NONE, "grid_increment", "increment item at cursor", clip_next],
|
||||
[Char(','), NONE, "grid_decrement", "decrement item at cursor", clip_prev],
|
||||
[Char('`'), NONE, "grid_mode_switch", "switch the display mode", |app: &mut App| {
|
||||
app.grid_mode = !app.seq_mode;
|
||||
Ok(true)
|
||||
}],
|
||||
});
|
||||
|
||||
const KEYMAP_SEQUENCER: &'static [KeyBinding<App>] = keymap!(App {
|
||||
[Up, NONE, "seq_cursor_up", "move cursor up", |app: &mut App| {
|
||||
app.note_cursor = app.note_cursor.saturating_sub(1);
|
||||
Ok(true)
|
||||
}],
|
||||
[Down, NONE, "seq_cursor_down", "move cursor up", |app: &mut App| {
|
||||
app.note_cursor = app.note_cursor + 1;
|
||||
Ok(true)
|
||||
}],
|
||||
[Left, NONE, "seq_cursor_left", "move cursor up", |app: &mut App| {
|
||||
if app.entered {
|
||||
app.time_cursor = app.time_cursor.saturating_sub(1);
|
||||
} else {
|
||||
app.time_start = app.time_start.saturating_sub(1);
|
||||
}
|
||||
Ok(true)
|
||||
}],
|
||||
[Right, NONE, "seq_cursor_right", "move cursor up", |app: &mut App| {
|
||||
if app.entered {
|
||||
app.time_cursor = app.time_cursor + 1;
|
||||
} else {
|
||||
app.time_start = app.time_start + 1;
|
||||
}
|
||||
Ok(true)
|
||||
}],
|
||||
[Char('`'), NONE, "seq_mode_switch", "switch the display mode", |app: &mut App| {
|
||||
app.seq_mode = !app.seq_mode;
|
||||
Ok(true)
|
||||
}],
|
||||
// [Char('a'), NONE, "note_add", "Add note", note_add],
|
||||
// [Char('z'), NONE, "note_del", "Delete note", note_del],
|
||||
// [CapsLock, NONE, "advance", "Toggle auto advance", nop],
|
||||
// [Char('w'), NONE, "rest", "Advance by note duration", nop],
|
||||
// [Char('s'), NONE, "stop_and_rewind", "Stop and rewind", stop_and_rewind],
|
||||
// [Char('q'), NONE, "quantize_next", "Next quantize value", quantize_next],
|
||||
// [Char('Q'), SHIFT, "quantize_prev", "Previous quantize value", quantize_prev],
|
||||
});
|
||||
|
||||
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)],
|
||||
[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);
|
||||
Ok(true)
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
}],
|
||||
[Right, NONE, "chain_cursor_right", "move cursor right", |app: &mut App| {
|
||||
if let Some((_, track)) = app.track_mut() {
|
||||
track.device = (track.device + 1).min(track.devices.len().saturating_sub(1));
|
||||
Ok(true)
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
}],
|
||||
[Char('`'), NONE, "chain_mode_switch", "switch the display mode", |app: &mut App| {
|
||||
app.chain_mode = !app.seq_mode;
|
||||
Ok(true)
|
||||
}],
|
||||
});
|
||||
|
||||
fn focus_next (app: &mut App) -> Usually<bool> {
|
||||
if app.section >= 2 {
|
||||
app.section = 0;
|
||||
} else {
|
||||
app.section = app.section + 1;
|
||||
}
|
||||
app.section.next();
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn focus_prev (app: &mut App) -> Usually<bool> {
|
||||
if app.section == 0 {
|
||||
app.section = 2;
|
||||
} else {
|
||||
app.section = app.section - 1;
|
||||
}
|
||||
app.section.prev();
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn increment (app: &mut App) -> Usually<bool> {
|
||||
match app.section {
|
||||
0 => clip_next(app),
|
||||
_ => Ok(false)
|
||||
}
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
fn clip_next (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||
|
|
@ -252,10 +276,7 @@ fn clip_next (_: &mut App) -> Usually<bool> { Ok(true) }
|
|||
//}
|
||||
|
||||
fn decrement (app: &mut App) -> Usually<bool> {
|
||||
match app.section {
|
||||
0 => clip_prev(app),
|
||||
_ => Ok(false)
|
||||
}
|
||||
Ok(false)
|
||||
}
|
||||
|
||||
fn clip_prev (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||
|
|
@ -278,107 +299,11 @@ fn clip_prev (_: &mut App) -> Usually<bool> { Ok(true) }
|
|||
|
||||
fn delete (app: &mut App) -> Usually<bool> {
|
||||
match app.section {
|
||||
0 => delete_track(app),
|
||||
AppSection::Grid => delete_track(app),
|
||||
_ => Ok(false)
|
||||
}
|
||||
}
|
||||
|
||||
fn enter (app: &mut App) -> Usually<bool> {
|
||||
if app.entered {
|
||||
activate(app)
|
||||
} else {
|
||||
app.entered = true;
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
|
||||
fn activate (app: &mut App) -> Usually<bool> {
|
||||
Ok(match app.section {
|
||||
0 => {
|
||||
if app.scene_cursor == 0 {
|
||||
false
|
||||
} else {
|
||||
let scene = &app.scenes[app.scene_cursor - 1];
|
||||
if app.track_cursor == 0 {
|
||||
for (i, track) in app.tracks.iter_mut().enumerate() {
|
||||
track.sequence = scene.clips[i];
|
||||
track.reset = true;
|
||||
}
|
||||
} else {
|
||||
let track = &mut app.tracks[app.track_cursor - 1];
|
||||
track.sequence = scene.clips[app.track_cursor - 1];
|
||||
track.reset = true;
|
||||
};
|
||||
true
|
||||
}
|
||||
},
|
||||
_ => false
|
||||
})
|
||||
}
|
||||
//fn activate (_: &mut Launcher) -> Usually<bool> {
|
||||
//unimplemented!();
|
||||
////if let (
|
||||
////Some((_scene_id, scene)),
|
||||
////Some((track_id, track)),
|
||||
////) = (state.scene_mut(), state.track_mut()) {
|
||||
////// Launch clip
|
||||
////if let Some(phrase_id) = scene.clips.get(track_id) {
|
||||
////track.sequencer.sequence = *phrase_id;
|
||||
////}
|
||||
////if state.playing == TransportState::Stopped {
|
||||
////state.transport.start()?;
|
||||
////state.playing = TransportState::Starting;
|
||||
////}
|
||||
////} else if let Some((_scene_id, scene)) = state.scene() {
|
||||
////// Launch scene
|
||||
////for (track_id, track) in state.tracks.iter().enumerate() {
|
||||
////if let Some(phrase_id) = scene.clips.get(track_id) {
|
||||
////track.sequencer.sequence = *phrase_id;
|
||||
////}
|
||||
////}
|
||||
////if state.playing == TransportState::Stopped {
|
||||
////state.transport.start()?;
|
||||
////state.playing = TransportState::Starting;
|
||||
////}
|
||||
////} else if let Some((_track_id, _track)) = state.track() {
|
||||
////// Rename track?
|
||||
////}
|
||||
|
||||
////let track = state.active_track().unwrap();
|
||||
////let scene = state.active_scene();
|
||||
////if state.cursor.1 >= 2 {
|
||||
////if let Some(Some(index)) = scene.clips.get(state.cursor.1 - 2) {
|
||||
////track.enqueue(index)
|
||||
////} else {
|
||||
////}
|
||||
////}
|
||||
////if state.cursor.0 >= 1 {
|
||||
////let sequencer = state.tracks.get_mut(state.cursor.0 - 1);
|
||||
////if state.cursor.1 >= 2 {
|
||||
////let scene = state.scenes.get_mut(state.cursor.1 - 2);
|
||||
////if let Some(index) = scene.get(state.cursor.0 - 1) {
|
||||
////let phrase = sequencer.phrases.get(index);
|
||||
////} else {
|
||||
////let index = sequencer.phrases.len();
|
||||
////let phrase = Phrase::new(&format!("Phrase#{index}"));
|
||||
////sequencer.phrases.push(phrase);
|
||||
////scene[state.cursor.0 - 1] = Some(index);
|
||||
////}
|
||||
////}
|
||||
////}
|
||||
//Ok(true)
|
||||
//}
|
||||
|
||||
|
||||
fn escape (app: &mut App) -> Usually<bool> {
|
||||
if app.entered {
|
||||
app.entered = false;
|
||||
Ok(true)
|
||||
} else {
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
|
||||
fn delete_track (app: &mut App) -> Usually<bool> {
|
||||
if app.tracks.len() > 0 {
|
||||
let track = app.tracks.remove(app.track_cursor);
|
||||
|
|
@ -390,78 +315,3 @@ fn delete_track (app: &mut App) -> Usually<bool> {
|
|||
}
|
||||
|
||||
fn duplicate (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||
|
||||
fn rename (_: &mut App) -> Usually<bool> { Ok(true) }
|
||||
|
||||
//use crate::{core::*, model::*};
|
||||
//use super::focus::*;
|
||||
|
||||
//pub fn handle (state: &mut Chain, event: &AppEvent) -> Usually<bool> {
|
||||
//Ok(handle_focus(state, event, keymap!(Chain {
|
||||
//[Up, NONE, "focus_up", "focus row above",
|
||||
//|s: &mut Chain|s.handle_focus(&FocusEvent::Backward)],
|
||||
//[Down, NONE, "focus_down", "focus row below",
|
||||
//|s: &mut Chain|s.handle_focus(&FocusEvent::Forward)],
|
||||
//[Enter, NONE, "focus_down", "focus row below",
|
||||
//|s: &mut Chain|s.handle_focus(&FocusEvent::Inward)],
|
||||
//[Esc, NONE, "focus_down", "focus row below",
|
||||
//|s: &mut Chain|s.handle_focus(&FocusEvent::Outward)],
|
||||
//}))? || handle_keymap(state, event, keymap!(Chain {
|
||||
//[Char('a'), NONE, "add_device", "add a device", add_device]
|
||||
//}))?)
|
||||
//}
|
||||
|
||||
//fn add_device (state: &mut Chain) -> Usually<bool> {
|
||||
//state.adding = true;
|
||||
//Ok(true)
|
||||
//}
|
||||
|
||||
//impl Focus for Chain {
|
||||
//fn unfocus (&mut self) {
|
||||
//self.focused = false
|
||||
//}
|
||||
//fn focused (&self) -> Option<&Box<dyn Device>> {
|
||||
//match self.focused {
|
||||
//true => self.items.get(self.focus),
|
||||
//false => None
|
||||
//}
|
||||
//}
|
||||
//fn focused_mut (&mut self) -> Option<&mut Box<dyn Device>> {
|
||||
//match self.focused {
|
||||
//true => self.items.get_mut(self.focus),
|
||||
//false => None
|
||||
//}
|
||||
//}
|
||||
//fn handle_focus (&mut self, event: &FocusEvent) -> Usually<bool> {
|
||||
//Ok(match event {
|
||||
//FocusEvent::Backward => {
|
||||
//if self.focus == 0 {
|
||||
//self.focus = self.items.len();
|
||||
//}
|
||||
//self.focus = self.focus - 1;
|
||||
//true
|
||||
//},
|
||||
//FocusEvent::Forward => {
|
||||
//self.focus = self.focus + 1;
|
||||
//if self.focus >= self.items.len() {
|
||||
//self.focus = 0;
|
||||
//}
|
||||
//true
|
||||
//},
|
||||
//FocusEvent::Inward => {
|
||||
//self.focused = true;
|
||||
//self.items[self.focus].handle(&AppEvent::Focus)?;
|
||||
//true
|
||||
//},
|
||||
//FocusEvent::Outward => {
|
||||
//if self.focused {
|
||||
//self.focused = false;
|
||||
//self.items[self.focus].handle(&AppEvent::Blur)?;
|
||||
//true
|
||||
//} else {
|
||||
//false
|
||||
//}
|
||||
//},
|
||||
//})
|
||||
//}
|
||||
//}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue