unify edn_view entrypoint

This commit is contained in:
🪞👃🪞 2025-01-14 15:39:28 +01:00
parent df50bb9f47
commit 9cd6e9f195
16 changed files with 603 additions and 541 deletions

View file

@ -7,11 +7,25 @@ pub trait HasEditor {
fn editor_h (&self) -> usize { 0 }
}
#[macro_export] macro_rules! has_editor {
(|$self:ident: $Struct:ident|{
editor = $e0:expr;
editor_w = $e1:expr;
editor_h = $e2:expr;
is_editing = $e3:expr;
}) => {
impl HasEditor for $Struct {
fn editor (&$self) -> &Option<MidiEditor> { &$e0 }
fn editor_mut (&mut $self) -> &Option<MidiEditor> { &mut $e0 }
fn editor_w (&$self) -> usize { $e1 }
fn editor_h (&$self) -> usize { $e2 }
fn is_editing (&$self) -> bool { $e3 }
}
};
(|$self:ident:$Struct:ident$(<$($L:lifetime),*$($T:ident$(:$U:path)?),*>)?|$cb:expr) => {
impl $(<$($L),*$($T $(: $U)?),*>)? HasEditor for $Struct $(<$($L),*$($T),*>)? {
fn editor (&$self) -> &MidiEditor { &$cb }
}
}
};
}
/// Contains state for viewing and editing a clip
pub struct MidiEditor {
@ -32,7 +46,7 @@ impl Default for MidiEditor {
mode: PianoHorizontal::new(None),
size: Measure::new(),
keymap: EdnKeymap(
EdnItem::<String>::read_all(include_str!("../edn/midi-keys.edn"))
EdnItem::<String>::read_all(include_str!("midi_editor_keys.edn"))
.expect("failed to load keymap for MidiEditor")
)
}