constrain tracks from right side

This commit is contained in:
🪞👃🪞 2025-01-27 00:16:26 +01:00
parent 3502070613
commit e4620b9a92
3 changed files with 40 additions and 51 deletions

View file

@ -189,6 +189,9 @@ impl Tek {
fn w_tracks (&self, editing: bool, bigger: usize) -> u16 {
self.tracks_sizes(editing, bigger).last().map(|(_, _, _, x)|x as u16).unwrap_or(0)
}
fn w_tracks_area (&self) -> u16 {
self.w().saturating_sub(2 * self.w_sidebar())
}
fn h_inputs (&self) -> u16 {
1 + self.inputs_sizes().last().map(|(_, _, _, _, y)|y as u16).unwrap_or(0)
}
@ -267,8 +270,8 @@ impl Tek {
fn per_track_top <'a, T: Content<TuiOut> + 'a> (
&'a self, f: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
) -> impl Content<TuiOut> + 'a {
let width = self.size.w();
let filter = move|(t, track, x1, x2)|if x2 >= width {None} else {Some((t, track, x1, x2))};
let width = self.w_tracks_area();
let filter = move|(t, track, x1, x2)|if x2 as u16 >= width {None} else {Some((t, track, x1, x2))};
let tracks = move||self.tracks_sizes(self.is_editing(), self.editor_w()).map_while(filter);
Align::x(Tui::bg(Green, Map::new(tracks, move|(index, track, x1, x2), _|{
let width = (x2 - x1) as u16;

View file

@ -1,10 +1,11 @@
use crate::*;
impl Tek {
pub fn view_inputs (&self) -> impl Content<TuiOut> + use<'_> {
let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar());
let fg = Tui::g(224);
Bsp::s(
Bsp::s(
self.row_top(self.w(), 1,
self.row_top(w, 1,
Fill::x(Align::w(Bsp::e(
self.button3(" i", "midi ins", format!("{}", self.midi_ins.len())),
self.button2(" I", "add midi in"),
@ -23,7 +24,7 @@ impl Tek {
Self::wrap(bg, fg, Tui::bold(true, Fill::x(Bsp::e(
Tui::fg_bg(rec, bg, "Rec "),
Tui::fg_bg(mon, bg, "Mon ")))))})),
self.row_top(self.w(), self.h_inputs() - 1,
self.row_top(w, self.h_inputs() - 1,
self.io_ports(fg, Tui::g(32), ||self.inputs_sizes()),
self.per_track_top(move|t, track|self.io_connections(
track.color.dark.rgb,
@ -31,16 +32,11 @@ impl Tek {
||self.inputs_sizes()
))),
),
self.view_clips_into()
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(),
" ------ ")))))
)
}
fn view_clips_into (&self) -> impl Content<TuiOut> + use<'_> {
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(),
" ------ "
)))))
}
}

View file

@ -1,43 +1,33 @@
use crate::*;
impl Tek {
pub fn view_outputs (&self) -> impl Content<TuiOut> + use<'_> {
let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar());
let w = self.w_tracks_area();
let fg = Tui::g(224);
Align::n(Bsp::s(
Bsp::s(
self.view_clips_next(),
self.view_clips_from(),
),
Bsp::s(
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"),
))),
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+1) { track.color.light.rgb } else { track.color.base.rgb };
let bg2 = if t > 0 { self.tracks()[t - 1].color.base.rgb } else { Reset };
Self::wrap(bg, fg, Tui::bold(true, Fill::x(Bsp::e(
Tui::fg_bg(mute, bg, "Play "),
Tui::fg_bg(solo, bg, "Solo ")))))})),
self.row_top(self.w(), self.h_outputs() - 1,
self.io_ports(fg, Tui::g(32), ||self.outputs_sizes()),
self.per_track_top(move|t, track|self.io_connections(
track.color.dark.rgb, track.color.darker.rgb, ||self.outputs_sizes()))),
)
))
}
fn view_clips_from (&self) -> impl Content<TuiOut> + use<'_> {
let w = (self.size.w() as u16).saturating_sub(2 * self.w_sidebar());
self.row_top(w, 2, Align::e("From:"),
let nexts = self.row_top(w, 1, Align::e("Next:"),
self.per_track_top(|_, _|Tui::bg(Reset, " ------ ")));
let froms = 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<TuiOut> + use<'_> {
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, " ------ "))) }
Align::c(Bsp::s(" ------ ", OctaveVertical::default(),)))));
let ports = 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"),
))),
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+1) { track.color.light.rgb } else { track.color.base.rgb };
let bg2 = if t > 0 { self.tracks()[t - 1].color.base.rgb } else { Reset };
Self::wrap(bg, fg, Tui::bold(true, Fill::x(Bsp::e(
Tui::fg_bg(mute, bg, "Play "),
Tui::fg_bg(solo, bg, "Solo ")))))}));
let routes = self.row_top(w, self.h_outputs() - 1,
self.io_ports(fg, Tui::g(32), ||self.outputs_sizes()),
self.per_track_top(move|t, track|self.io_connections(
track.color.dark.rgb, track.color.darker.rgb, ||self.outputs_sizes())));
Align::n(Bsp::s(Bsp::s(nexts, froms), Bsp::s(ports, routes)))
}
}