diff --git a/app/src/view/view_arranger.rs b/app/src/view/view_arranger.rs index 2c3bd602..ee6ea5eb 100644 --- a/app/src/view/view_arranger.rs +++ b/app/src/view/view_arranger.rs @@ -160,45 +160,19 @@ impl Tek { } pub fn view_outputs (&self) -> impl Content + use<'_> { - let editing = self.is_editing(); - let w = self.w_tracks_area(); - let s = self.w_sidebar() as u16; - let fg = Tui::g(224); - let nexts = self.per_track_top(|t, track|Either( - track.player.next_clip.is_some(), - Thunk::new(||Tui::bg(Reset, format!("{:?}", - track.player.next_clip.as_ref() - .map(|(moment, clip)|clip.as_ref() - .map(|clip|clip.read().unwrap().name.clone())) - .flatten().as_ref()))), - Thunk::new(||Tui::bg(Reset, " ------ ")))); - let nexts = row_top(w, 2, s, Align::ne("Next:"), nexts, ()); - let froms = self.per_track_top( - |_, _|Tui::bg(Reset, Align::c(Bsp::s(" ------ ", OctaveVertical::default(),))) - ); - let froms = row_top(w, 2, s, Align::ne("From:"), froms, ()); - let ports = row_top(w, 1, s, - button_3("o", "midi outs", format!("{}", self.midi_outs.len()), editing), - self.per_track_top(move|t, track|{ - let mute = false; - let solo = false; - let mute = if mute { White } else { track.color.darkest.rgb }; - let solo = if solo { White } else { track.color.darkest.rgb }; - let bg = if self.selected().track() == Some(t) { - track.color.light.rgb - } else { - track.color.base.rgb - }; - let bg2 = if t > 0 { self.tracks()[t].color.base.rgb } else { Reset }; - wrap(bg, fg, Tui::bold(true, Fill::x(Bsp::e( - Tui::fg_bg(mute, bg, "Play "), - Tui::fg_bg(solo, bg, "Solo ")))))}), - button_2("O", "add midi out", editing)); - let routes = row_top(w, self.h_outputs() - 1, s, - io_ports(fg, Tui::g(32), ||self.outputs_sizes()), - self.per_track_top(move|t, track|io_conns( - track.color.dark.rgb, track.color.darker.rgb, ||self.outputs_sizes())), ()); - Align::n(Bsp::s(Bsp::s(nexts, froms), Bsp::s(ports, routes))) + let fg = Tui::g(224); + let bg = Tui::g(32); + let len = self.midi_outs.len(); + let ed = self.is_editing(); + let ws = self.w_tracks_area(); + let s = self.w_sidebar() as u16; + let ts = move||self.tracks_sizes_scrolled(); + let sel = self.selected().track(); + let ho = self.h_outputs() - 1; + let os = ||self.outputs_sizes(); + let pts = io_ports(fg, bg, os); + let tr = self.tracks.as_ref(); + view_outputs(ws, s, ho, len, ed, sel, tr, ts, os, pts) } pub fn view_inputs (&self) -> impl Content + use<'_> { @@ -209,7 +183,7 @@ impl Tek { let wt = self.w_tracks_area(); let ts = move||self.tracks_sizes_scrolled(); let is = ||self.inputs_sizes(); - let ins = self.midi_ins.len(); + let len = self.midi_ins.len(); let sel = self.selected().track(); let tr = self.tracks().as_ref(); let ed = self.is_editing(); @@ -218,7 +192,7 @@ impl Tek { let to_conns = move|_, &Track { color, .. }|io_conns(color.dark.rgb, color.darker.rgb, is); view_inputs(w, ws, wt, ts, row_top(w, hi, ws, pts, per_track_top(wt, ts, to_conns), ()), - input_ports(w, ws, ins, wt, ts, sel, tr, ed)) + input_ports(w, ws, len, wt, ts, sel, tr, ed)) } /// Render something centered for each track. @@ -267,12 +241,12 @@ fn view_scene_name ( } fn view_inputs <'a, T, U, V, W> ( - w: u16, - s: u16, - w_tracks_area: u16, - tracks_sizes: U, - routes: V, - ports: W, + ws: u16, + s: u16, + wt: u16, + ts: U, + routes: V, + ports: W, ) -> impl Content + use<'a, T, U, V, W> where T: TracksSizes<'a>, U: Fn()->T + Send + Sync + 'a, @@ -281,8 +255,76 @@ fn view_inputs <'a, T, U, V, W> ( { let headers = Bsp::s(Align::e("Input:"), Align::e("Into:")); let sep = |_, _|Tui::bg(Reset, Align::c(Bsp::s(OctaveVertical::default(), " ------ "))); - let separators = per_track_top(w_tracks_area, tracks_sizes, sep); - Bsp::s(Bsp::s(routes, ports), row_top(w, 2, s, headers, separators, ())) + let separators = per_track_top(wt, ts, sep); + Bsp::s(Bsp::s(routes, ports), row_top(ws, 2, s, headers, separators, ())) +} + +fn view_outputs <'a, T, U, V, W, X> ( + ws: u16, + s: u16, + ho: u16, + len: usize, + ed: bool, + sel: Option, + tr: &'a [Track], + ts: U, + os: W, + pts: X, +) -> impl Content + use<'a, T, U, V, W, X> where + T: TracksSizes<'a>, + U: Fn()->T + Send + Sync + 'a, + V: PortsSizes<'a>, + W: Fn()->V + Send + Sync + 'a, + X: Content + 'a +{ + let fg = Tui::g(224); + let conns = row_top(ws, ho, s, pts, per_track_top( + ws, ts, |t, track|io_conns(track.color.dark.rgb, track.color.darker.rgb, os) + ), ()); + let nexts = row_top(ws, 2, s, Align::ne("Next:"), per_track_top(ws, ts, |t, track|Either( + track.player.next_clip.is_some(), + Thunk::new(||Tui::bg(Reset, format!("{:?}", + track.player.next_clip.as_ref() + .map(|(moment, clip)|clip.as_ref() + .map(|clip|clip.read().unwrap().name.clone())) + .flatten().as_ref()))), + Thunk::new(||Tui::bg(Reset, " ------ ")) + )), ()); + let bar = row_top( + ws, + 2, + s, + Align::ne("From:"), + per_track_top( + ws, + ts, + |_, _|Tui::bg(Reset, Align::c(Bsp::s(" ------ ", OctaveVertical::default(),))) + ), + () + ); + let baz = row_top( + ws, + 1, + s, + button_3("o", "midi outs", format!("{}", len), ed), + per_track_top( + ws, + ts, + move|t, track|{ + let mute = false; + let solo = false; + let mute = if mute { White } else { track.color.darkest.rgb }; + let solo = if solo { White } else { track.color.darkest.rgb }; + let bg1 = if sel == Some(t) { track.color.light.rgb } else { track.color.base.rgb }; + let bg2 = if t > 0 { tr[t].color.base.rgb } else { Reset }; + wrap(bg1, fg, Tui::bold(true, Fill::x(Bsp::e( + Tui::fg_bg(mute, bg1, "Play "), + Tui::fg_bg(solo, bg1, "Solo "))))) + } + ), + button_2("O", "add midi out", ed) + ); + Align::n(Bsp::s(Bsp::s(nexts, bar), Bsp::s(baz, conns))) } fn input_ports <'a, T: TracksSizes<'a>, U: Fn()->T + Send + Sync + 'a> ( diff --git a/sampler/src/lib.rs b/sampler/src/lib.rs index b3dfeed8..2d69a917 100644 --- a/sampler/src/lib.rs +++ b/sampler/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(unused)] +#![allow(dead_code)] mod sampler; pub use self::sampler::*; pub(crate) use ::tek_jack::{*, jack::*}; pub(crate) use ::tek_midi::{*, midly::{*, live::*, num::*}}; diff --git a/sampler/src/sampler.rs b/sampler/src/sampler.rs index b37853a7..cba709e0 100644 --- a/sampler/src/sampler.rs +++ b/sampler/src/sampler.rs @@ -547,10 +547,10 @@ impl AddSampleModal { return Ok(false) } } -fn read_sample_data (_: &str) -> Usually<(usize, Vec>)> { +pub fn read_sample_data (_: &str) -> Usually<(usize, Vec>)> { todo!(); } -fn scan (dir: &PathBuf) -> Usually<(Vec, Vec)> { +pub fn scan (dir: &PathBuf) -> Usually<(Vec, Vec)> { let (mut subdirs, mut files) = std::fs::read_dir(dir)? .fold((vec!["..".into()], vec![]), |(mut subdirs, mut files), entry|{ let entry = entry.expect("failed to read drectory entry"); @@ -566,7 +566,7 @@ fn scan (dir: &PathBuf) -> Usually<(Vec, Vec)> { files.sort(); Ok((subdirs, files)) } -fn draw_sample ( +pub fn draw_sample ( to: &mut TuiOut, x: u16, y: u16, note: Option<&u7>, sample: &Sample, focus: bool ) -> Usually { let style = if focus { Style::default().green() } else { Style::default() }; @@ -828,7 +828,7 @@ impl NotePoint for SamplerTui { fn set_note_pos (&self, x: usize) { self.note_pt.store(x, Relaxed); } } impl Sampler { - const EMPTY: &[(f64, f64)] = &[(0., 0.), (1., 1.), (2., 2.), (0., 2.), (2., 0.)]; + const _EMPTY: &[(f64, f64)] = &[(0., 0.), (1., 1.), (2., 2.), (0., 2.), (2., 0.)]; pub fn list <'a> (&'a self, compact: bool, editor: &MidiEditor) -> impl Content + 'a { let note_lo = editor.note_lo().load(Relaxed); let note_pt = editor.note_pos();