From 5ff6868a172cbaf1a5a3df99419583c997a85dee Mon Sep 17 00:00:00 2001 From: unspeaker Date: Sat, 17 May 2025 13:32:53 +0300 Subject: [PATCH] replug is_editing() --- crates/device/src/arranger/arranger_model.rs | 8 --- crates/device/src/arranger/arranger_view.rs | 51 +++++++++++--------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/crates/device/src/arranger/arranger_model.rs b/crates/device/src/arranger/arranger_model.rs index 4bc39ecd..24eb1449 100644 --- a/crates/device/src/arranger/arranger_model.rs +++ b/crates/device/src/arranger/arranger_model.rs @@ -77,14 +77,6 @@ impl Arrangement { pub fn h (&self) -> u16 { self.size.h() as u16 } - /// Height taken by all inputs. - pub fn h_inputs (&self) -> u16 { - self.midi_ins_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0) - } - /// Height taken by all outputs. - pub fn h_outputs (&self) -> u16 { - self.midi_outs_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0) - } /// Height taken by visible device slots. pub fn h_devices (&self) -> u16 { 2 diff --git a/crates/device/src/arranger/arranger_view.rs b/crates/device/src/arranger/arranger_view.rs index 8a1713ce..93909a30 100644 --- a/crates/device/src/arranger/arranger_view.rs +++ b/crates/device/src/arranger/arranger_view.rs @@ -13,7 +13,20 @@ impl Content for Arrangement { } } -impl Arrangement { +impl TracksView for T +where T: ScenesView + HasMidiIns + HasMidiOuts + HasSize + HasTrackScroll + HasSelection + HasMidiIns + HasEditor {} + +pub trait TracksView: + ScenesView + HasMidiIns + HasMidiOuts + HasSize + HasTrackScroll + HasSelection + HasMidiIns + HasEditor +{ + /// Height taken by all inputs. + fn h_inputs (&self) -> u16 { + self.midi_ins_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0) + } + /// Height taken by all outputs. + fn h_outputs (&self) -> u16 { + self.midi_outs_with_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0) + } /// Render input matrix. fn view_inputs_0 (&self) -> impl Content + '_ { Tui::bg(Reset, Bsp::s( @@ -22,7 +35,7 @@ impl Arrangement { )) } fn view_input_ports (&self) -> impl Content + '_ { - let is_editing = false; //FIXME + let is_editing = self.is_editing(); Tryptich::top(1) .left(20, button_3("i", "midi ins", format!("{}", self.midi_ins().len()), is_editing)) @@ -77,15 +90,12 @@ impl Arrangement { .middle(self.w_mid(), self.view_output_map()) } fn view_output_count (&self) -> impl Content { - button_3( - "o", - "midi outs", - format!("{}", self.midi_outs().len()), - false // self.is_editing() + button_3("o", "midi outs", format!("{}", self.midi_outs().len()), + self.is_editing() ) } fn view_output_add (&self) -> impl Content { - button_2("O", "add midi out", false /* is_editing */) + button_2("O", "add midi out", self.is_editing()) } fn view_output_map (&self) -> impl Content + '_ { per_track_top(||self.tracks_with_sizes_scrolled(), move|i, t|{ @@ -145,7 +155,7 @@ impl Arrangement { fn view_tracks_0 (&self) -> impl Content + '_ { let w_side = self.w_side(); let w_mid = self.w_mid(); - let is_editing = false; // FIXME + let is_editing = self.is_editing(); let track_selected = self.arrangement().selection().track(); Tryptich::center(3) .left(w_side, @@ -166,7 +176,7 @@ impl Arrangement { fn view_devices_0 (&self) -> impl Content + '_ { let w_side = self.w_side(); let w_mid = self.w_mid(); - let is_editing = false; // FIXME + let is_editing = self.is_editing(); let track_selected = self.arrangement().selection().track(); Tryptich::top(1) .left(w_side, button_3("d", "devices", format!("{}", 0), is_editing)) @@ -182,16 +192,6 @@ impl Arrangement { track.devices.get(0).map(|device|wrap(bg.rgb, fg, device.name())) })) } -} - -impl TracksView for T -where T: HasSize + HasTrackScroll + HasSelection + HasMidiIns + HasEditor {} - -impl ClipsView for Arrangement {} - -pub trait TracksView: - HasSize + HasTrackScroll + HasSelection + HasMidiIns + HasEditor -{ fn tracks_width_available (&self) -> u16 { (self.width() as u16).saturating_sub(40) } @@ -316,7 +316,7 @@ pub trait TracksView: } } -pub trait ScenesView: HasSelection + HasSceneScroll + Send + Sync { +pub trait ScenesView: HasEditor + HasSelection + HasSceneScroll + Send + Sync { /// Default scene height. const H_SCENE: usize = 2; /// Default editor height. @@ -394,9 +394,9 @@ pub trait ScenesView: HasSelection + HasSceneScroll + Send + Sync { .then_some((s, scene, y1, y2))) } /// Height required to display all scenes. - fn h_scenes_total (&self, is_editing: bool) -> u16 { + fn h_scenes_total (&self) -> u16 { self.scenes_with_sizes( - is_editing, + self.is_editing(), Self::H_SCENE, Self::H_EDITOR, self.selection().track(), @@ -407,7 +407,10 @@ pub trait ScenesView: HasSelection + HasSceneScroll + Send + Sync { } } +impl ClipsView for T {} + pub trait ClipsView: TracksView + ScenesView + Send + Sync { + fn view_scenes_clips <'a> (&'a self) -> impl Content + 'a { @@ -498,6 +501,7 @@ pub trait ClipsView: TracksView + ScenesView + Send + Sync { Align::w(Fill::x(Map::new(||self.scenes().iter().skip(self.scene_scroll()), move|scene: &'a Scene, index|self.track_scenes(index, scene)))))) } + fn track_scenes <'a> ( &'a self, scene_index: usize, @@ -508,6 +512,7 @@ pub trait ClipsView: TracksView + ScenesView + Send + Sync { move|clip: &'a Option>>, track_index| self.track_scene_clip(scene_index, scene, track_index, clip)))) } + fn track_scene_clip ( &self, scene_index: usize,