From 3502070613f6da02b9a23e93ea1a22dc482d399f Mon Sep 17 00:00:00 2001 From: unspeaker Date: Mon, 27 Jan 2025 00:07:56 +0100 Subject: [PATCH] constrain tracks from left side --- midi/src/piano_h.rs | 9 +++++---- tek/src/view/clip.rs | 9 +++++---- tek/src/view/input.rs | 3 ++- tek/src/view/output.rs | 21 +++++++++------------ tek/src/view_arranger.edn | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/midi/src/piano_h.rs b/midi/src/piano_h.rs index 9b1e0698..f7fa91fd 100644 --- a/midi/src/piano_h.rs +++ b/midi/src/piano_h.rs @@ -1,4 +1,5 @@ use crate::*; +use Color::*; /// A clip, rendered as a horizontal piano roll. pub struct PianoHorizontal { pub clip: Option>>, @@ -82,7 +83,7 @@ impl PianoHorizontal { } /// Draw the piano roll background using full blocks on note on and half blocks on legato: █▄ █▄ █▄ fn draw_fg (buf: &mut BigBuffer, clip: &MidiClip, zoom: usize) { - let style = Style::default().fg(clip.color.base.rgb);//.bg(Color::Rgb(0, 0, 0)); + let style = Style::default().fg(clip.color.base.rgb);//.bg(Rgb(0, 0, 0)); let mut notes_on = [false;128]; for (x, time_start) in (0..clip.length).step_by(zoom).enumerate() { for (_y, note) in (0..=127).rev().enumerate() { @@ -182,9 +183,9 @@ impl PianoHorizontal { let note_lo = state.note_lo().get(); let note_hi = state.note_hi(); let note_pos = state.note_pos(); - let key_style = Some(Style::default().fg(Color::Rgb(192, 192, 192)).bg(Color::Rgb(0, 0, 0))); - let off_style = Some(Style::default().fg(Tui::g(160))); - let on_style = Some(Style::default().fg(Tui::g(255)).bg(color.base.rgb).bold()); + let key_style = Some(Style::default().fg(Rgb(192, 192, 192)).bg(Rgb(0, 0, 0))); + let off_style = Some(Style::default().fg(Tui::g(255))); + let on_style = Some(Style::default().fg(Rgb(255,0,0)).bg(color.base.rgb).bold()); Fill::y(Fixed::x(self.keys_width, ThunkRender::new(move|to: &mut TuiOut|{ let [x, y0, _w, _h] = to.area().xywh(); for (_area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) { diff --git a/tek/src/view/clip.rs b/tek/src/view/clip.rs index 64b6475c..b3765f2b 100644 --- a/tek/src/view/clip.rs +++ b/tek/src/view/clip.rs @@ -1,9 +1,10 @@ use crate::*; impl Tek { pub fn view_tracks (&self) -> impl Content + use<'_> { + let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar()); let data = (self.selected.track().unwrap_or(0), self.tracks().len()); - self.fmtd.write().unwrap().trks.update(Some(data), rewrite!(buf, "({}/{})", data.0, data.1)); - self.row(self.w(), 1, Align::w(Bsp::e( + self.fmtd.write().unwrap().trks.update(Some(data), rewrite!(buf, "{}/{}", data.0, data.1)); + self.row(w, 1, Align::w(Bsp::e( self.button3(" t", "track", self.fmtd.read().unwrap().trks.view.clone()), self.button2(" T", "add track"), )), self.per_track(|t, track|{ @@ -17,8 +18,8 @@ impl Tek { })) } pub fn view_scenes (&self) -> impl Content + use<'_> { - let w = self.size.w() as u16; - let h = self.size.h() as u16; + let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar()); + let h = (self.size.h() as u16).saturating_sub(self.h_inputs() + self.h_outputs() + 1); let editing = self.is_editing(); let selected_track = self.selected().track(); let selected_scene = self.selected().scene(); diff --git a/tek/src/view/input.rs b/tek/src/view/input.rs index c2952082..12767d02 100644 --- a/tek/src/view/input.rs +++ b/tek/src/view/input.rs @@ -35,7 +35,8 @@ impl Tek { ) } fn view_clips_into (&self) -> impl Content + use<'_> { - self.row_top(self.w(), 2, + let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar()); + self.row_top(w, 2, Bsp::s(Align::e("Input:"), Align::e("Into:")), self.per_track_top(|_, _|Tui::bg(Reset, Align::c(Bsp::s( OctaveVertical::default(), diff --git a/tek/src/view/output.rs b/tek/src/view/output.rs index 1989f340..83fcb1df 100644 --- a/tek/src/view/output.rs +++ b/tek/src/view/output.rs @@ -1,6 +1,7 @@ use crate::*; impl Tek { pub fn view_outputs (&self) -> impl Content + use<'_> { + let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar()); let fg = Tui::g(224); Align::n(Bsp::s( Bsp::s( @@ -8,7 +9,7 @@ impl Tek { self.view_clips_from(), ), Bsp::s( - self.row_top(self.w(), 1, + self.row_top(w, 1, Fill::x(Align::w(Bsp::e( self.button3(" o", "midi outs", format!("{}", self.midi_outs.len())), self.button2(" O", "add midi out"), @@ -31,16 +32,12 @@ impl Tek { )) } fn view_clips_from (&self) -> impl Content + use<'_> { - let heading = Align::e("From:"); - let content = self.per_track_top(|_, _|Tui::bg(Reset, Align::c(Bsp::s( - OctaveVertical::default(), - " ------ " - )))); - self.row_top(self.w(), 2, heading, content) - } + let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar()); + self.row_top(w, 2, Align::e("From:"), + self.per_track_top(|_, _|Tui::bg(Reset, + Align::c(Bsp::s(" ------ ", OctaveVertical::default(),))))) } fn view_clips_next (&self) -> impl Content + use<'_> { - let heading = Align::e("Next:"); - let content = self.per_track_top(|_, _|Tui::bg(Reset, " ----- ")); - self.row_top(self.w(), 1, heading, content) - } + let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar()); + self.row_top(w, 1, Align::e("Next:"), + self.per_track_top(|_, _|Tui::bg(Reset, " ------ "))) } } diff --git a/tek/src/view_arranger.edn b/tek/src/view_arranger.edn index 11913cf3..fc8d815f 100644 --- a/tek/src/view_arranger.edn +++ b/tek/src/view_arranger.edn @@ -1,5 +1,5 @@ (bsp/n - (fixed/y 1 :toolbar) + (fixed/y 2 :toolbar) (fill/xy (align/c (bsp/a (fill/xy (align/e :pool)) (bsp/a (fill/xy (align/n (bsp/s :tracks :inputs)))