fix(device): last 8 left to full compile?
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
stop screaming 2026-02-20 00:55:20 +02:00
parent 82ff49b386
commit 2d7ca155e0
7 changed files with 38 additions and 29 deletions

View file

@ -1,5 +1,23 @@
use crate::*;
impl<T: Has<Option<MidiEditor>>> HasEditor for T {}
pub trait HasEditor: Has<Option<MidiEditor>> {
fn editor (&self) -> Option<&MidiEditor> {
self.get().as_ref()
}
fn editor_mut (&mut self) -> Option<&mut MidiEditor> {
self.get_mut().as_mut()
}
fn is_editing (&self) -> bool {
self.editor().is_some()
}
fn editor_w (&self) -> usize {
self.editor().map(|e|e.size.w()).unwrap_or(0) as usize
}
fn editor_h (&self) -> usize {
self.editor().map(|e|e.size.h()).unwrap_or(0) as usize
}
}
#[macro_export] macro_rules! has_editor {
(|$self:ident: $Struct:ident|{
editor = $e0:expr;
@ -16,14 +34,6 @@ use crate::*;
}
};
}
impl<T: Has<Option<MidiEditor>>> HasEditor for T {}
pub trait HasEditor: Has<Option<MidiEditor>> {
fn editor (&self) -> Option<&MidiEditor> { self.get().as_ref() }
fn editor_mut (&mut self) -> Option<&mut MidiEditor> { self.get_mut().as_mut() }
fn is_editing (&self) -> bool { self.editor().is_some() }
fn editor_w (&self) -> usize { self.editor().map(|e|e.size.w()).unwrap_or(0) }
fn editor_h (&self) -> usize { self.editor().map(|e|e.size.h()).unwrap_or(0) }
}
/// Contains state for viewing and editing a clip
pub struct MidiEditor {
@ -34,7 +44,14 @@ pub struct MidiEditor {
}
has!(Measure<TuiOut>: |self: MidiEditor|self.size);
impl Default for MidiEditor { fn default () -> Self { Self { size: Measure::new(), mode: PianoHorizontal::new(None), } } }
impl Default for MidiEditor {
fn default () -> Self {
Self {
size: Measure::new(0, 0),
mode: PianoHorizontal::new(None),
}
}
}
impl std::fmt::Debug for MidiEditor {
fn fmt (&self, f: &mut Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
f.debug_struct("MidiEditor").field("mode", &self.mode).finish()
@ -247,7 +264,7 @@ has!(Measure<TuiOut>:|self:PianoHorizontal|self.size);
impl PianoHorizontal {
pub fn new (clip: Option<&Arc<RwLock<MidiClip>>>) -> Self {
let size = Measure::new();
let size = Measure::new(0, 0);
let mut range = MidiRangeModel::from((12, true));
range.time_axis = size.x.clone();
range.note_axis = size.y.clone();