down to 48 ugly ones

This commit is contained in:
🪞👃🪞 2025-05-14 16:06:10 +03:00
parent 57eff50973
commit 4fe51b5267
9 changed files with 104 additions and 101 deletions

View file

@ -102,8 +102,8 @@ impl MidiViewer for MidiEditor {
}
pub trait HasEditor {
fn editor (&self) -> &Option<MidiEditor>;
fn editor_mut (&mut self) -> &Option<MidiEditor>;
fn editor (&self) -> Option<&MidiEditor>;
fn editor_mut (&mut self) -> Option<&mut MidiEditor>;
fn is_editing (&self) -> bool { true }
fn editor_w (&self) -> usize { 0 }
fn editor_h (&self) -> usize { 0 }
@ -117,17 +117,12 @@ pub trait HasEditor {
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 (&$self) -> Option<&MidiEditor> { $e0.as_ref() }
fn editor_mut (&mut $self) -> Option<&mut MidiEditor> { $e0.as_mut() }
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 }
}
};
}