mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
fix some errors and warnings
This commit is contained in:
parent
64d520e75c
commit
438a2d86a6
3 changed files with 97 additions and 53 deletions
|
|
@ -160,45 +160,19 @@ impl Tek {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view_outputs (&self) -> impl Content<TuiOut> + use<'_> {
|
pub fn view_outputs (&self) -> impl Content<TuiOut> + 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 fg = Tui::g(224);
|
||||||
let nexts = self.per_track_top(|t, track|Either(
|
let bg = Tui::g(32);
|
||||||
track.player.next_clip.is_some(),
|
let len = self.midi_outs.len();
|
||||||
Thunk::new(||Tui::bg(Reset, format!("{:?}",
|
let ed = self.is_editing();
|
||||||
track.player.next_clip.as_ref()
|
let ws = self.w_tracks_area();
|
||||||
.map(|(moment, clip)|clip.as_ref()
|
let s = self.w_sidebar() as u16;
|
||||||
.map(|clip|clip.read().unwrap().name.clone()))
|
let ts = move||self.tracks_sizes_scrolled();
|
||||||
.flatten().as_ref()))),
|
let sel = self.selected().track();
|
||||||
Thunk::new(||Tui::bg(Reset, " ------ "))));
|
let ho = self.h_outputs() - 1;
|
||||||
let nexts = row_top(w, 2, s, Align::ne("Next:"), nexts, ());
|
let os = ||self.outputs_sizes();
|
||||||
let froms = self.per_track_top(
|
let pts = io_ports(fg, bg, os);
|
||||||
|_, _|Tui::bg(Reset, Align::c(Bsp::s(" ------ ", OctaveVertical::default(),)))
|
let tr = self.tracks.as_ref();
|
||||||
);
|
view_outputs(ws, s, ho, len, ed, sel, tr, ts, os, pts)
|
||||||
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)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view_inputs (&self) -> impl Content<TuiOut> + use<'_> {
|
pub fn view_inputs (&self) -> impl Content<TuiOut> + use<'_> {
|
||||||
|
|
@ -209,7 +183,7 @@ impl Tek {
|
||||||
let wt = self.w_tracks_area();
|
let wt = self.w_tracks_area();
|
||||||
let ts = move||self.tracks_sizes_scrolled();
|
let ts = move||self.tracks_sizes_scrolled();
|
||||||
let is = ||self.inputs_sizes();
|
let is = ||self.inputs_sizes();
|
||||||
let ins = self.midi_ins.len();
|
let len = self.midi_ins.len();
|
||||||
let sel = self.selected().track();
|
let sel = self.selected().track();
|
||||||
let tr = self.tracks().as_ref();
|
let tr = self.tracks().as_ref();
|
||||||
let ed = self.is_editing();
|
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);
|
let to_conns = move|_, &Track { color, .. }|io_conns(color.dark.rgb, color.darker.rgb, is);
|
||||||
view_inputs(w, ws, wt, ts,
|
view_inputs(w, ws, wt, ts,
|
||||||
row_top(w, hi, ws, pts, per_track_top(wt, ts, to_conns), ()),
|
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.
|
/// Render something centered for each track.
|
||||||
|
|
@ -267,10 +241,10 @@ fn view_scene_name (
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view_inputs <'a, T, U, V, W> (
|
fn view_inputs <'a, T, U, V, W> (
|
||||||
w: u16,
|
ws: u16,
|
||||||
s: u16,
|
s: u16,
|
||||||
w_tracks_area: u16,
|
wt: u16,
|
||||||
tracks_sizes: U,
|
ts: U,
|
||||||
routes: V,
|
routes: V,
|
||||||
ports: W,
|
ports: W,
|
||||||
) -> impl Content<TuiOut> + use<'a, T, U, V, W> where
|
) -> impl Content<TuiOut> + use<'a, T, U, V, W> where
|
||||||
|
|
@ -281,8 +255,76 @@ fn view_inputs <'a, T, U, V, W> (
|
||||||
{
|
{
|
||||||
let headers = Bsp::s(Align::e("Input:"), Align::e("Into:"));
|
let headers = Bsp::s(Align::e("Input:"), Align::e("Into:"));
|
||||||
let sep = |_, _|Tui::bg(Reset, Align::c(Bsp::s(OctaveVertical::default(), " ------ ")));
|
let sep = |_, _|Tui::bg(Reset, Align::c(Bsp::s(OctaveVertical::default(), " ------ ")));
|
||||||
let separators = per_track_top(w_tracks_area, tracks_sizes, sep);
|
let separators = per_track_top(wt, ts, sep);
|
||||||
Bsp::s(Bsp::s(routes, ports), row_top(w, 2, s, headers, separators, ()))
|
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<usize>,
|
||||||
|
tr: &'a [Track],
|
||||||
|
ts: U,
|
||||||
|
os: W,
|
||||||
|
pts: X,
|
||||||
|
) -> impl Content<TuiOut> + 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<TuiOut> + '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> (
|
fn input_ports <'a, T: TracksSizes<'a>, U: Fn()->T + Send + Sync + 'a> (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![allow(unused)]
|
||||||
|
#![allow(dead_code)]
|
||||||
mod sampler; pub use self::sampler::*;
|
mod sampler; pub use self::sampler::*;
|
||||||
pub(crate) use ::tek_jack::{*, jack::*};
|
pub(crate) use ::tek_jack::{*, jack::*};
|
||||||
pub(crate) use ::tek_midi::{*, midly::{*, live::*, num::*}};
|
pub(crate) use ::tek_midi::{*, midly::{*, live::*, num::*}};
|
||||||
|
|
|
||||||
|
|
@ -547,10 +547,10 @@ impl AddSampleModal {
|
||||||
return Ok(false)
|
return Ok(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn read_sample_data (_: &str) -> Usually<(usize, Vec<Vec<f32>>)> {
|
pub fn read_sample_data (_: &str) -> Usually<(usize, Vec<Vec<f32>>)> {
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
fn scan (dir: &PathBuf) -> Usually<(Vec<OsString>, Vec<OsString>)> {
|
pub fn scan (dir: &PathBuf) -> Usually<(Vec<OsString>, Vec<OsString>)> {
|
||||||
let (mut subdirs, mut files) = std::fs::read_dir(dir)?
|
let (mut subdirs, mut files) = std::fs::read_dir(dir)?
|
||||||
.fold((vec!["..".into()], vec![]), |(mut subdirs, mut files), entry|{
|
.fold((vec!["..".into()], vec![]), |(mut subdirs, mut files), entry|{
|
||||||
let entry = entry.expect("failed to read drectory entry");
|
let entry = entry.expect("failed to read drectory entry");
|
||||||
|
|
@ -566,7 +566,7 @@ fn scan (dir: &PathBuf) -> Usually<(Vec<OsString>, Vec<OsString>)> {
|
||||||
files.sort();
|
files.sort();
|
||||||
Ok((subdirs, files))
|
Ok((subdirs, files))
|
||||||
}
|
}
|
||||||
fn draw_sample (
|
pub fn draw_sample (
|
||||||
to: &mut TuiOut, x: u16, y: u16, note: Option<&u7>, sample: &Sample, focus: bool
|
to: &mut TuiOut, x: u16, y: u16, note: Option<&u7>, sample: &Sample, focus: bool
|
||||||
) -> Usually<usize> {
|
) -> Usually<usize> {
|
||||||
let style = if focus { Style::default().green() } else { Style::default() };
|
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); }
|
fn set_note_pos (&self, x: usize) { self.note_pt.store(x, Relaxed); }
|
||||||
}
|
}
|
||||||
impl Sampler {
|
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<TuiOut> + 'a {
|
pub fn list <'a> (&'a self, compact: bool, editor: &MidiEditor) -> impl Content<TuiOut> + 'a {
|
||||||
let note_lo = editor.note_lo().load(Relaxed);
|
let note_lo = editor.note_lo().load(Relaxed);
|
||||||
let note_pt = editor.note_pos();
|
let note_pt = editor.note_pos();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue