mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
92 lines
3 KiB
Rust
92 lines
3 KiB
Rust
use crate::*;
|
|
|
|
#[derive(Clone, PartialEq)]
|
|
pub enum ArrangerCommand {
|
|
FocusNext,
|
|
FocusPrev,
|
|
FocusUp,
|
|
FocusDown,
|
|
FocusLeft,
|
|
FocusRight,
|
|
Transport(TransportCommand),
|
|
Phrases(PhrasePoolCommand),
|
|
Editor(PhraseEditorCommand),
|
|
Arrangement(ArrangementCommand),
|
|
}
|
|
#[derive(Clone, PartialEq)]
|
|
pub enum ArrangementCommand {
|
|
ToggleViewMode,
|
|
Delete,
|
|
Activate,
|
|
Increment,
|
|
Decrement,
|
|
ZoomIn,
|
|
ZoomOut,
|
|
MoveBack,
|
|
MoveForward,
|
|
RandomColor,
|
|
Put,
|
|
Get,
|
|
AddScene,
|
|
AddTrack,
|
|
ToggleLoop,
|
|
GoUp,
|
|
GoDown,
|
|
GoLeft,
|
|
GoRight,
|
|
}
|
|
impl <E: Engine> Command<Arranger<E>> for ArrangerCommand {
|
|
fn run (&self, state: &mut Arranger<E>) -> Perhaps<Self> {
|
|
use ArrangerCommand::*;
|
|
match self {
|
|
FocusNext => { state.focus_next(); },
|
|
FocusPrev => { state.focus_prev(); },
|
|
FocusUp => { state.focus_up(); },
|
|
FocusDown => { state.focus_down(); },
|
|
FocusLeft => { state.focus_left(); },
|
|
FocusRight => { state.focus_right(); },
|
|
Transport(command) => if let Some(ref transport) = state.transport {
|
|
return command.run(&mut*transport.write().unwrap()).map(|x|x.map(Transport))
|
|
},
|
|
Phrases(command) => {
|
|
return command.run(&mut*state.phrases.write().unwrap()).map(|x|x.map(Phrases))
|
|
},
|
|
Editor(command) => {
|
|
return command.run(&mut state.editor).map(|x|x.map(Editor))
|
|
},
|
|
Arrangement(command) => {
|
|
return command.run(&mut state.arrangement).map(|x|x.map(Arrangement))
|
|
},
|
|
}
|
|
state.show_phrase();
|
|
state.update_status();
|
|
Ok(None)
|
|
}
|
|
}
|
|
impl <E: Engine> Command<Arrangement<E>> for ArrangementCommand {
|
|
fn run (&self, state: &mut Arrangement<E>) -> Perhaps<Self> {
|
|
use ArrangementCommand::*;
|
|
match self {
|
|
ToggleViewMode => { state.mode.to_next(); },
|
|
Delete => { state.delete(); },
|
|
Activate => { state.activate(); },
|
|
Increment => { state.increment(); },
|
|
Decrement => { state.decrement(); },
|
|
ZoomIn => { state.zoom_in(); },
|
|
ZoomOut => { state.zoom_out(); },
|
|
MoveBack => { state.move_back(); },
|
|
MoveForward => { state.move_forward(); },
|
|
RandomColor => { state.randomize_color(); },
|
|
Put => { state.phrase_put(); },
|
|
Get => { state.phrase_get(); },
|
|
AddScene => { state.scene_add(None, None)?; },
|
|
AddTrack => { state.track_add(None, None)?; },
|
|
ToggleLoop => { state.toggle_loop() },
|
|
GoUp => { state.go_up() },
|
|
GoDown => { state.go_down() },
|
|
GoLeft => { state.go_left() },
|
|
GoRight => { state.go_right() },
|
|
};
|
|
Ok(None)
|
|
}
|
|
}
|