mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: refactor arranger to device
This commit is contained in:
parent
fa73821a0b
commit
89288f2920
40 changed files with 2015 additions and 1919 deletions
74
crates/device/src/arranger/arranger_model.rs
Normal file
74
crates/device/src/arranger/arranger_model.rs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
use crate::*;
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
pub struct Arrangement {
|
||||
/// Project name.
|
||||
pub name: Arc<str>,
|
||||
/// Base color.
|
||||
pub color: ItemTheme,
|
||||
/// List of global midi inputs
|
||||
pub midi_ins: Vec<JackMidiIn>,
|
||||
/// List of global midi outputs
|
||||
pub midi_outs: Vec<JackMidiOut>,
|
||||
/// List of global audio inputs
|
||||
pub audio_ins: Vec<JackAudioIn>,
|
||||
/// List of global audio outputs
|
||||
pub audio_outs: Vec<JackAudioOut>,
|
||||
/// Buffer for writing a midi event
|
||||
pub note_buf: Vec<u8>,
|
||||
/// Buffer for writing a chunk of midi events
|
||||
pub midi_buf: Vec<Vec<Vec<u8>>>,
|
||||
/// Last track number (to avoid duplicate port names)
|
||||
pub track_last: usize,
|
||||
/// List of tracks
|
||||
pub tracks: Vec<Track>,
|
||||
/// Scroll offset of tracks
|
||||
pub track_scroll: usize,
|
||||
/// List of scenes
|
||||
pub scenes: Vec<Scene>,
|
||||
/// Scroll offset of scenes
|
||||
pub scene_scroll: usize,
|
||||
/// Selected UI element
|
||||
pub selected: Option<Selection>,
|
||||
/// Contains a render of the project arrangement, redrawn on update.
|
||||
/// TODO rename to "render_cache" or smth
|
||||
pub arranger: Arc<RwLock<Buffer>>,
|
||||
/// Display size
|
||||
pub size: Measure<TuiOut>,
|
||||
}
|
||||
|
||||
has!(Option<Selection>: |self: Arrangement|self.selected);
|
||||
has!(Vec<JackMidiIn>: |self: Arrangement|self.midi_ins);
|
||||
has!(Vec<JackMidiOut>: |self: Arrangement|self.midi_outs);
|
||||
has!(Vec<Scene>: |self: Arrangement|self.scenes);
|
||||
has!(Vec<Track>: |self: Arrangement|self.tracks);
|
||||
|
||||
impl Has<Option<Track>> for Arrangement {
|
||||
fn get (&self) -> &Option<Track> {
|
||||
Has::<Selection>::get(self)
|
||||
.and_then(|selection|selection.track())
|
||||
.and_then(|index|Has::<Vec<Track>>::get(self).get(index))
|
||||
.flatten()
|
||||
}
|
||||
fn get_mut (&mut self) -> &mut Option<Track> {
|
||||
Has::<Selection>::get(self)
|
||||
.and_then(|selection|selection.track())
|
||||
.and_then(|index|Has::<Vec<Track>>::get_mut(self).get_mut(index))
|
||||
.flatten()
|
||||
}
|
||||
}
|
||||
|
||||
impl Has<Option<Scene>> for Arrangement {
|
||||
fn get (&self) -> &Option<Scene> {
|
||||
Has::<Selection>::get(self)
|
||||
.and_then(|selection|selection.track())
|
||||
.and_then(|index|Has::<Vec<Scene>>::get(self).get(index))
|
||||
.flatten()
|
||||
}
|
||||
fn get_mut (&mut self) -> &mut Option<Scene> {
|
||||
Has::<Selection>::get(self)
|
||||
.and_then(|selection|selection.track())
|
||||
.and_then(|index|Has::<Vec<Scene>>::get_mut(self).get_mut(index))
|
||||
.flatten()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue