mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 20:26:42 +01:00
wip: rebinding commands...
This commit is contained in:
parent
4fb703d05d
commit
744ce21e24
3 changed files with 171 additions and 122 deletions
|
|
@ -151,7 +151,54 @@ impl TrackCommand {
|
|||
StopAll,
|
||||
Clear,
|
||||
}
|
||||
command!(|self: AppCommand, state: App|match self {
|
||||
Self::Clear => { todo!() },
|
||||
Self::Clock(cmd) => cmd.delegate(state, Self::Clock)?,
|
||||
Self::History(delta) => { todo!("undo/redo") },
|
||||
Self::Select(s) => { state.selected = s; None },
|
||||
Self::Scene(cmd) => cmd.delegate(state, Self::Scene)?,
|
||||
Self::Track(cmd) => cmd.delegate(state, Self::Track)?,
|
||||
Self::Zoom(_) => { todo!(); },
|
||||
|
||||
Self::Editor(cmd) =>
|
||||
state.editor.as_mut().map(|editor|cmd.delegate(editor, Self::Editor)).transpose()?.flatten(),
|
||||
Self::Sampler(cmd) =>
|
||||
state.sampler.as_mut().map(|sampler|cmd.delegate(sampler, Self::Sampler)).transpose()?.flatten(),
|
||||
Self::Enqueue(clip) =>
|
||||
state.player.as_mut().map(|player|{player.enqueue_next(clip.as_ref());None}).flatten(),
|
||||
Self::StopAll => {
|
||||
for track in 0..state.tracks.len() { state.tracks[track].player.enqueue_next(None); }
|
||||
None
|
||||
},
|
||||
Self::Color(palette) => {
|
||||
let old = state.color;
|
||||
state.color = palette;
|
||||
Some(Self::Color(old))
|
||||
},
|
||||
|
||||
Self::Pool(cmd) => match cmd {
|
||||
// autoselect: automatically load selected clip in editor
|
||||
PoolCommand::Select(_) => {
|
||||
let undo = cmd.delegate(&mut state.pool, Self::Pool)?;
|
||||
state.editor.set_clip(state.pool.clip().as_ref());
|
||||
undo
|
||||
},
|
||||
// update color in all places simultaneously
|
||||
PoolCommand::Clip(PoolCmd::SetColor(index, _)) => {
|
||||
let undo = cmd.delegate(&mut state.pool, Self::Pool)?;
|
||||
state.editor.set_clip(state.pool.clip().as_ref());
|
||||
undo
|
||||
},
|
||||
_ => cmd.delegate(&mut state.pool, Self::Pool)?
|
||||
},
|
||||
|
||||
Self::Compact(compact) => if state.compact != compact {
|
||||
state.compact = compact;
|
||||
Some(Self::Compact(!compact))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
});
|
||||
|
||||
command!(|self: SequencerCommand, state: Sequencer|match self {
|
||||
Self::Clock(cmd) => cmd.delegate(state, Self::Clock)?,
|
||||
|
|
|
|||
117
tek/src/model.rs
117
tek/src/model.rs
|
|
@ -86,62 +86,11 @@ impl App {
|
|||
}
|
||||
}
|
||||
}
|
||||
#[derive(Default)] pub struct Sequencer {
|
||||
pub jack: Arc<RwLock<JackConnection>>,
|
||||
pub compact: bool,
|
||||
pub editor: MidiEditor,
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
pub note_buf: Vec<u8>,
|
||||
pub perf: PerfModel,
|
||||
pub player: MidiPlayer,
|
||||
pub pool: PoolModel,
|
||||
pub selectors: bool,
|
||||
pub size: Measure<TuiOut>,
|
||||
pub status: bool,
|
||||
pub transport: bool,
|
||||
}
|
||||
has_size!(<TuiOut>|self:Sequencer|&self.size);
|
||||
has_clock!(|self:Sequencer|&self.player.clock);
|
||||
has_clips!(|self:Sequencer|self.pool.clips);
|
||||
has_editor!(|self:Sequencer|self.editor);
|
||||
has_size!(<TuiOut>|self: App|&self.size);
|
||||
has_clock!(|self: App|&self.clock);
|
||||
has_clips!(|self: App|self.pool.clips);
|
||||
has_editor!(|self: App|self.editor);
|
||||
|
||||
#[derive(Default)] pub struct Groovebox {
|
||||
pub jack: Arc<RwLock<JackConnection>>,
|
||||
pub compact: bool,
|
||||
pub editor: MidiEditor,
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
pub note_buf: Vec<u8>,
|
||||
pub perf: PerfModel,
|
||||
pub player: MidiPlayer,
|
||||
pub pool: PoolModel,
|
||||
pub sampler: Sampler,
|
||||
pub size: Measure<TuiOut>,
|
||||
pub status: bool,
|
||||
}
|
||||
has_clock!(|self: Groovebox|self.player.clock());
|
||||
|
||||
#[derive(Default)] pub struct Arranger {
|
||||
pub clock: Clock,
|
||||
pub color: ItemPalette,
|
||||
pub compact: bool,
|
||||
pub editing: AtomicBool,
|
||||
pub editor: MidiEditor,
|
||||
pub jack: Arc<RwLock<JackConnection>>,
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
pub midi_ins: Vec<JackPort<MidiIn>>,
|
||||
pub midi_outs: Vec<JackPort<MidiOut>>,
|
||||
pub note_buf: Vec<u8>,
|
||||
pub perf: PerfModel,
|
||||
pub pool: PoolModel,
|
||||
pub scenes: Vec<ArrangerScene>,
|
||||
pub selected: ArrangerSelection,
|
||||
pub size: Measure<TuiOut>,
|
||||
pub splits: [u16;2],
|
||||
pub tracks: Vec<ArrangerTrack>,
|
||||
}
|
||||
has_clock!(|self: Arranger|&self.clock);
|
||||
has_clips!(|self: Arranger|self.pool.clips);
|
||||
has_editor!(|self: Arranger|self.editor);
|
||||
#[derive(Debug)] pub struct ArrangerTrack {
|
||||
/// Name of track
|
||||
pub name: Arc<str>,
|
||||
|
|
@ -217,3 +166,61 @@ impl ArrangerSelection {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)] pub struct Sequencer {
|
||||
pub jack: Arc<RwLock<JackConnection>>,
|
||||
pub compact: bool,
|
||||
pub editor: MidiEditor,
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
pub note_buf: Vec<u8>,
|
||||
pub perf: PerfModel,
|
||||
pub player: MidiPlayer,
|
||||
pub pool: PoolModel,
|
||||
pub selectors: bool,
|
||||
pub size: Measure<TuiOut>,
|
||||
pub status: bool,
|
||||
pub transport: bool,
|
||||
}
|
||||
has_size!(<TuiOut>|self:Sequencer|&self.size);
|
||||
has_clock!(|self:Sequencer|&self.player.clock);
|
||||
has_clips!(|self:Sequencer|self.pool.clips);
|
||||
has_editor!(|self:Sequencer|self.editor);
|
||||
has_player!(|self:Sequencer|self.player);
|
||||
|
||||
#[derive(Default)] pub struct Groovebox {
|
||||
pub jack: Arc<RwLock<JackConnection>>,
|
||||
pub compact: bool,
|
||||
pub editor: MidiEditor,
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
pub note_buf: Vec<u8>,
|
||||
pub perf: PerfModel,
|
||||
pub player: MidiPlayer,
|
||||
pub pool: PoolModel,
|
||||
pub sampler: Sampler,
|
||||
pub size: Measure<TuiOut>,
|
||||
pub status: bool,
|
||||
}
|
||||
has_clock!(|self: Groovebox|self.player.clock());
|
||||
|
||||
#[derive(Default)] pub struct Arranger {
|
||||
pub clock: Clock,
|
||||
pub color: ItemPalette,
|
||||
pub compact: bool,
|
||||
pub editing: AtomicBool,
|
||||
pub editor: MidiEditor,
|
||||
pub jack: Arc<RwLock<JackConnection>>,
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
pub midi_ins: Vec<JackPort<MidiIn>>,
|
||||
pub midi_outs: Vec<JackPort<MidiOut>>,
|
||||
pub note_buf: Vec<u8>,
|
||||
pub perf: PerfModel,
|
||||
pub pool: PoolModel,
|
||||
pub scenes: Vec<ArrangerScene>,
|
||||
pub selected: ArrangerSelection,
|
||||
pub size: Measure<TuiOut>,
|
||||
pub splits: [u16;2],
|
||||
pub tracks: Vec<ArrangerTrack>,
|
||||
}
|
||||
has_clock!(|self: Arranger|&self.clock);
|
||||
has_clips!(|self: Arranger|self.pool.clips);
|
||||
has_editor!(|self: Arranger|self.editor);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue