From 2d7ca155e02f7beaf91eac5cf28fc63dc9982391 Mon Sep 17 00:00:00 2001 From: stop screaming Date: Fri, 20 Feb 2026 00:55:20 +0200 Subject: [PATCH] fix(device): last 8 left to full compile? --- device/arranger.rs | 6 +++--- device/browse.rs | 10 +--------- device/editor.rs | 37 +++++++++++++++++++++++++++---------- device/lv2.rs | 2 +- device/meter.rs | 4 ++-- device/scene.rs | 2 +- device/track.rs | 6 +++--- 7 files changed, 38 insertions(+), 29 deletions(-) diff --git a/device/arranger.rs b/device/arranger.rs index af479133..5b64f3b8 100644 --- a/device/arranger.rs +++ b/device/arranger.rs @@ -314,13 +314,13 @@ impl Arrangement { #[cfg(feature = "scene")] impl ScenesView for Arrangement { fn h_scenes (&self) -> u16 { - (self.height() as u16).saturating_sub(20) + (self.measure_height() as u16).saturating_sub(20) } fn w_side (&self) -> u16 { - (self.width() as u16 * 2 / 10).max(20) + (self.measure_width() as u16 * 2 / 10).max(20) } fn w_mid (&self) -> u16 { - (self.width() as u16).saturating_sub(2 * self.w_side()).max(40) + (self.measure_width() as u16).saturating_sub(2 * self.w_side()).max(40) } } diff --git a/device/browse.rs b/device/browse.rs index 02d41448..2e60a468 100644 --- a/device/browse.rs +++ b/device/browse.rs @@ -53,15 +53,7 @@ impl Browse { files.push((name, format!("📄 {decoded}"))); } } - Ok(Self { - cwd, - dirs, - files, - filter: "".to_string(), - index: 0, - scroll: 0, - size: Measure::new(), - }) + Ok(Self { cwd, dirs, files, ..Default::default() }) } pub fn len (&self) -> usize { diff --git a/device/editor.rs b/device/editor.rs index 72098c52..5cdd290d 100644 --- a/device/editor.rs +++ b/device/editor.rs @@ -1,5 +1,23 @@ use crate::*; +impl>> HasEditor for T {} +pub trait HasEditor: Has> { + 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>> HasEditor for T {} -pub trait HasEditor: Has> { - 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: |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:|self:PianoHorizontal|self.size); impl PianoHorizontal { pub fn new (clip: Option<&Arc>>) -> 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(); diff --git a/device/lv2.rs b/device/lv2.rs index 2330ce38..23293dab 100644 --- a/device/lv2.rs +++ b/device/lv2.rs @@ -135,7 +135,7 @@ audio!(|self: Lv2, _client, scope|{ impl Draw for Lv2 { fn draw (&self, to: &mut TuiOut) { let area = to.area(); - let [x, y, _, height] = area; + let XYWH(x, y, _, height) = area; let mut width = 20u16; let start = self.selected.saturating_sub((height as usize / 2).saturating_sub(1)); let end = start + height as usize - 2; diff --git a/device/meter.rs b/device/meter.rs index 8a7d9a50..7fc5b9f6 100644 --- a/device/meter.rs +++ b/device/meter.rs @@ -12,7 +12,7 @@ pub struct Log10Meter(pub f32); impl Layout for Log10Meter {} impl Draw for Log10Meter { fn draw (&self, to: &mut TuiOut) { - let [x, y, w, h] = to.area(); + let XYWH(x, y, w, h) = to.area(); let signal = 100.0 - f32::max(0.0, f32::min(100.0, self.0.abs())); let v = (signal * h as f32 / 100.0).ceil() as u16; let y2 = y + h; @@ -36,7 +36,7 @@ pub struct RmsMeter(pub f32); impl Layout for RmsMeter {} impl Draw for RmsMeter { fn draw (&self, to: &mut TuiOut) { - let [x, y, w, h] = to.area(); + let XYWH(x, y, w, h) = to.area(); let signal = f32::max(0.0, f32::min(100.0, self.0.abs())); let v = (signal * h as f32).ceil() as u16; let y2 = y + h; diff --git a/device/scene.rs b/device/scene.rs index 3de97989..115bc7ed 100644 --- a/device/scene.rs +++ b/device/scene.rs @@ -108,7 +108,7 @@ pub trait ScenesView: } else { Self::H_SCENE }; - if y + height <= self.clips_size().h() as u16 { + if y + height <= self.clips_size().h() as usize { let data = (s, scene, y, y + height); y += height; Some(data) diff --git a/device/track.rs b/device/track.rs index 15b38dcf..3714ec25 100644 --- a/device/track.rs +++ b/device/track.rs @@ -195,16 +195,16 @@ pub trait TracksView: HasClipsSize { fn tracks_width_available (&self) -> u16 { - (self.width() as u16).saturating_sub(40) + (self.measure_width() as u16).saturating_sub(40) } /// Iterate over tracks with their corresponding sizes. fn tracks_with_sizes (&self) -> impl TracksSizes<'_> { - let _editor_width = self.editor().map(|e|e.width()); + let _editor_width = self.editor().map(|e|e.measure_width()); let _active_track = self.selection().track(); let mut x = 0; self.tracks().iter().enumerate().map_while(move |(index, track)|{ let width = track.width.max(8); - if x + width < self.clips_size().w() { + if x + width < self.clips_size().w() as usize { let data = (index, track, x, x + width); x += width + Self::TRACK_SPACING; Some(data)