mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
This commit is contained in:
parent
5696cbbebb
commit
2fd7d7b39f
18 changed files with 355 additions and 360 deletions
|
|
@ -3,9 +3,12 @@ use crate::*;
|
|||
|
||||
/// Contains state for viewing and editing a clip
|
||||
pub struct MidiEditor {
|
||||
pub mode: PianoHorizontal,
|
||||
/// Size of editor on screen
|
||||
pub size: Measure<TuiOut>,
|
||||
pub keys: InputMap<'static, Self, MidiEditCommand, TuiIn>
|
||||
/// View mode and state of editor
|
||||
pub mode: PianoHorizontal,
|
||||
/// Input keymap
|
||||
pub keys: InputMap<'static, Self, MidiEditCommand, TuiIn, SourceIter<'static>>
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for MidiEditor {
|
||||
|
|
@ -19,10 +22,9 @@ impl std::fmt::Debug for MidiEditor {
|
|||
impl Default for MidiEditor {
|
||||
fn default () -> Self {
|
||||
Self {
|
||||
mode: PianoHorizontal::new(None),
|
||||
size: Measure::new(),
|
||||
keys: InputMap::new()
|
||||
.layer(SourceIter(include_str!("../../../../config/keys_edit.edn"))),
|
||||
mode: PianoHorizontal::new(None),
|
||||
keys: InputMap::new(SourceIter(include_str!("../../../../config/keys_editor.edn"))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -206,14 +208,12 @@ atom_command!(MidiEditCommand: |state: MidiEditor| {
|
|||
Show(Option<Arc<RwLock<MidiClip>>>),
|
||||
}
|
||||
|
||||
handle!(TuiIn: |self: MidiEditor, input|{
|
||||
Ok(if let Some(command) = self.keys.command(self, input) {
|
||||
let _undo = command.execute(self)?;
|
||||
Some(true)
|
||||
} else {
|
||||
None
|
||||
})
|
||||
});
|
||||
handle!(TuiIn: |self: MidiEditor, input|Ok(if let Some(command) = self.keys.command(self, input) {
|
||||
command.execute(self)?;
|
||||
Some(true)
|
||||
} else {
|
||||
None
|
||||
}));
|
||||
|
||||
impl Command<MidiEditor> for MidiEditCommand {
|
||||
fn execute (self, state: &mut MidiEditor) -> Perhaps<Self> {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use crate::*;
|
|||
use Color::*;
|
||||
|
||||
/// A clip, rendered as a horizontal piano roll.
|
||||
#[derive(Clone)]
|
||||
pub struct PianoHorizontal {
|
||||
pub clip: Option<Arc<RwLock<MidiClip>>>,
|
||||
/// Buffer where the whole clip is rerendered on change
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::*;
|
||||
|
||||
//#[derive(Debug)]
|
||||
#[derive(Debug)]
|
||||
pub struct MidiPool {
|
||||
pub visible: bool,
|
||||
/// Collection of clips
|
||||
|
|
@ -10,7 +10,7 @@ pub struct MidiPool {
|
|||
/// Mode switch
|
||||
pub mode: Option<PoolMode>,
|
||||
|
||||
pub keys: InputMap<'static, Self, PoolCommand, TuiIn>,
|
||||
pub keys: InputMap<'static, Self, PoolCommand, TuiIn, SourceIter<'static>>,
|
||||
//pub keys: SourceIter<'static>,
|
||||
//pub keys_rename: SourceIter<'static>,
|
||||
//pub keys_length: SourceIter<'static>,
|
||||
|
|
@ -25,9 +25,7 @@ impl Default for MidiPool {
|
|||
clips: Arc::from(RwLock::from(vec![])),
|
||||
clip: 0.into(),
|
||||
mode: None,
|
||||
keys: InputMap::new()
|
||||
.layer(
|
||||
SourceIter(include_str!("../../../../config/keys_edit.edn")))
|
||||
keys: InputMap::new(SourceIter(include_str!("../../../../config/keys_pool.edn")))
|
||||
.layer_if(|pool: &Self|matches!(pool.mode, Some(Import(..))|Some(Export(..))),
|
||||
SourceIter(include_str!("../../../../config/keys_pool_file.edn")))
|
||||
.layer_if(|pool: &Self|matches!(pool.mode, Some(Rename(..))),
|
||||
|
|
|
|||
|
|
@ -3,10 +3,13 @@ use crate::*;
|
|||
/// Trait for thing that may output MIDI.
|
||||
pub trait HasMidiOuts {
|
||||
fn midi_outs (&self) -> &Vec<JackMidiOut>;
|
||||
|
||||
fn midi_outs_mut (&mut self) -> &mut Vec<JackMidiOut>;
|
||||
|
||||
fn has_midi_outs (&self) -> bool {
|
||||
!self.midi_outs().is_empty()
|
||||
}
|
||||
|
||||
/// Buffer for serializing a MIDI event. FIXME rename
|
||||
fn midi_note (&mut self) -> &mut Vec<u8>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue