trying to fix the main layout, what happened

This commit is contained in:
🪞👃🪞 2025-03-30 21:20:50 +03:00
parent 0c6484d733
commit 85749a3437
6 changed files with 41 additions and 37 deletions

View file

@ -69,13 +69,14 @@ pub(crate) struct ArrangerView<'a> {
impl<'a> Content<TuiOut> for ArrangerView<'a> { impl<'a> Content<TuiOut> for ArrangerView<'a> {
fn content (&self) -> impl Render<TuiOut> { fn content (&self) -> impl Render<TuiOut> {
Bsp::s(self.inputs(), let with_inputs = |x|Bsp::s(self.inputs(), x);
Bsp::s(self.tracks(), let with_tracks = |x|Bsp::s(self.tracks(), x);
Bsp::n(self.outputs(), Tui::bg(Reset, Bsp::s( let with_outputs = |x|Bsp::n(self.outputs(), x);
&self.track_scroll, let with_track_scroll = |x|Bsp::s(&self.track_scroll, x);
Bsp::e( let with_scene_scroll = |x|Bsp::e(&self.scene_scroll, x);
&self.scene_scroll, let with_background = |x|Tui::bg(Reset, x);
Fixed::y(self.scenes_height, self.scenes()))))))) with_inputs(with_tracks(with_outputs(with_background(with_track_scroll(with_scene_scroll(
self.scenes()))))))
} }
} }
@ -89,7 +90,7 @@ impl<'a> ArrangerView<'a> {
width_mid: app.w_tracks_area(), width_mid: app.w_tracks_area(),
width_side: app.w_sidebar(), width_side: app.w_sidebar(),
inputs_height: app.h_inputs().saturating_sub(1), inputs_height: app.h_inputs(),
inputs_count: app.midi_ins.len(), inputs_count: app.midi_ins.len(),
outputs_height: app.h_outputs().saturating_sub(1), outputs_height: app.h_outputs().saturating_sub(1),
@ -147,14 +148,16 @@ impl<'a> ArrangerView<'a> {
self.app.scenes_with_sizes(self.is_editing, Tek::H_SCENE, Tek::H_EDITOR).map_while( self.app.scenes_with_sizes(self.is_editing, Tek::H_SCENE, Tek::H_EDITOR).map_while(
move|(s, scene, y1, y2)|if y2 as u16 > self.tracks_height { move|(s, scene, y1, y2)|if y2 as u16 > self.tracks_height {
None None
} else { Some((s, scene, y1, y2, if s == 0 {
None
} else { } else {
Some(self.app.scenes[s-1].clips[self.track_selected.unwrap_or(0)].as_ref() Some((s, scene, y1, y2, if s == 0 {
.map(|c|c.read().unwrap().color) None
.unwrap_or(ItemPalette::G[32])) } else {
})) Some(self.app.scenes[s-1].clips[self.track_selected.unwrap_or(0)].as_ref()
}) .map(|c|c.read().unwrap().color)
.unwrap_or(ItemPalette::G[32]))
}))
}
)
} }
} }

View file

@ -33,14 +33,14 @@ impl Tek {
self.update_clock(); self.update_clock();
let theme = ItemPalette::G[96]; let theme = ItemPalette::G[96];
let fmtd = self.fmtd.read().unwrap(); let fmtd = self.fmtd.read().unwrap();
Tui::bg(Black, row!(Bsp::a( Fixed::y(1, Tui::bg(Black, row!(Bsp::a(
Fill::xy(Align::w(button_play_pause(self.clock.is_rolling()))), Fill::xy(Align::w(button_play_pause(self.clock.is_rolling()))),
Fill::xy(Align::e(row!( Fill::xy(Align::e(row!(
FieldH(theme, "BPM", fmtd.bpm.view.clone()), FieldH(theme, "BPM", fmtd.bpm.view.clone()),
FieldH(theme, "Beat", fmtd.beat.view.clone()), FieldH(theme, "Beat", fmtd.beat.view.clone()),
FieldH(theme, "Time", fmtd.time.view.clone()) FieldH(theme, "Time", fmtd.time.view.clone())
))) )))
))) ))))
} }
pub(crate) fn view_transport (&self) -> impl Content<TuiOut> + use<'_> { pub(crate) fn view_transport (&self) -> impl Content<TuiOut> + use<'_> {
self.update_clock(); self.update_clock();

View file

@ -34,23 +34,23 @@ impl<A, B, C> Content<TuiOut> for Tryptich<A, B, C>
where A: Content<TuiOut>, B: Content<TuiOut>, C: Content<TuiOut> { where A: Content<TuiOut>, B: Content<TuiOut>, C: Content<TuiOut> {
fn content (&self) -> impl Render<TuiOut> { fn content (&self) -> impl Render<TuiOut> {
let Self { top, h, left: (w_a, ref a), middle: (w_b, ref b), right: (w_c, ref c) } = *self; let Self { top, h, left: (w_a, ref a), middle: (w_b, ref b), right: (w_c, ref c) } = *self;
if top { Fixed::y(h, if top {
Fixed::y(h, Bsp::a( Bsp::a(
Fill::x(Align::n(Fixed::x(w_b, Align::x(Tui::bg(Reset, b))))), Fill::x(Align::n(Fixed::x(w_b, Align::x(Tui::bg(Reset, b))))),
Bsp::a( Bsp::a(
Fill::x(Align::nw(Fixed::x(w_a, Tui::bg(Reset, a)))), Fill::x(Align::nw(Fixed::x(w_a, Tui::bg(Reset, a)))),
Fill::x(Align::ne(Fixed::x(w_c, Tui::bg(Reset, c)))), Fill::x(Align::ne(Fixed::x(w_c, Tui::bg(Reset, c)))),
), ),
)) )
} else { } else {
Fixed::y(h, Bsp::a( Bsp::a(
Fill::xy(Align::c(Fixed::x(w_b, Align::x(Tui::bg(Reset, b))))), Fill::xy(Align::c(Fixed::x(w_b, Align::x(Tui::bg(Reset, b))))),
Bsp::a( Bsp::a(
Fill::xy(Align::w(Fixed::x(w_a, Tui::bg(Reset, a)))), Fill::xy(Align::w(Fixed::x(w_a, Tui::bg(Reset, a)))),
Fill::xy(Align::e(Fixed::x(w_c, Tui::bg(Reset, c)))), Fill::xy(Align::e(Fixed::x(w_c, Tui::bg(Reset, c)))),
), ),
)) )
} })
} }
} }

View file

@ -21,9 +21,9 @@ impl<'a> ArrangerView<'a> {
} }
fn input_ports (&'a self) -> impl Content<TuiOut> + 'a { fn input_ports (&'a self) -> impl Content<TuiOut> + 'a {
Tryptich::top(1) Tryptich::top(self.inputs_count as u16)
.left(self.width_side, .left(self.width_side,
button_3("i", "midi ins", format!("{}", self.outputs_count), self.is_editing)) button_3("i", "midi ins", format!("{}", self.inputs_count), self.is_editing))
.right(self.width_side, .right(self.width_side,
button_2("I", "add midi in", self.is_editing)) button_2("I", "add midi in", self.is_editing))
.middle(self.width_mid, .middle(self.width_mid,
@ -63,7 +63,7 @@ impl<'a> ArrangerView<'a> {
/// Render output matrix. /// Render output matrix.
pub(crate) fn outputs (&'a self) -> impl Content<TuiOut> + 'a { pub(crate) fn outputs (&'a self) -> impl Content<TuiOut> + 'a {
Align::n(Bsp::s( Fixed::y(3, Align::n(Bsp::s(
Bsp::s( Bsp::s(
self.output_nexts(), self.output_nexts(),
self.output_froms(), self.output_froms(),
@ -72,21 +72,21 @@ impl<'a> ArrangerView<'a> {
self.output_ports(), self.output_ports(),
self.output_conns(), self.output_conns(),
) )
)) )))
} }
fn output_nexts (&'a self) -> impl Content<TuiOut> + 'a { fn output_nexts (&'a self) -> impl Content<TuiOut> + 'a {
Tryptich::top(2) Fixed::y(1, Tryptich::top(2)
.left(self.width_side, Align::ne("From:")) .left(self.width_side, Align::ne("From:"))
.middle(self.width_mid, per_track_top( .middle(self.width_mid, per_track_top(
self.width_mid, self.width_mid,
||self.tracks_with_sizes_scrolled(), ||self.tracks_with_sizes_scrolled(),
|_, _|{ |_, _|{
Tui::bg(Reset, Align::c(Bsp::s(" ------ ", OctaveVertical::default()))) Tui::bg(Reset, Align::c(Bsp::s(" ------ ", OctaveVertical::default())))
})) })))
} }
fn output_froms (&'a self) -> impl Content<TuiOut> + 'a { fn output_froms (&'a self) -> impl Content<TuiOut> + 'a {
Tryptich::top(2) Fixed::y(1, Tryptich::top(2)
.left(self.width_side, Align::ne("Next:")) .left(self.width_side, Align::ne("Next:"))
.middle(self.width_mid, per_track_top( .middle(self.width_mid, per_track_top(
self.width_mid, self.width_mid,
@ -99,10 +99,10 @@ impl<'a> ArrangerView<'a> {
.map(|clip|clip.read().unwrap().name.clone())) .map(|clip|clip.read().unwrap().name.clone()))
.flatten().as_ref()))), .flatten().as_ref()))),
Thunk::new(||Tui::bg(Reset, " ------ ")) Thunk::new(||Tui::bg(Reset, " ------ "))
))) ))))
} }
fn output_ports (&'a self) -> impl Content<TuiOut> + 'a { fn output_ports (&'a self) -> impl Content<TuiOut> + 'a {
Tryptich::top(1) Fixed::y(3, Tryptich::top(1)
.left(self.width_side, .left(self.width_side,
button_3("o", "midi outs", format!("{}", self.outputs_count), self.is_editing)) button_3("o", "midi outs", format!("{}", self.outputs_count), self.is_editing))
.right(self.width_side, .right(self.width_side,
@ -121,10 +121,10 @@ impl<'a> ArrangerView<'a> {
let mute = Tui::fg_bg(mute, bg_1, "Play "); let mute = Tui::fg_bg(mute, bg_1, "Play ");
let solo = Tui::fg_bg(solo, bg_1, "Solo "); let solo = Tui::fg_bg(solo, bg_1, "Solo ");
wrap(bg_1, Tui::g(224), Tui::bold(true, Fill::x(Bsp::e(mute, solo)))) wrap(bg_1, Tui::g(224), Tui::bold(true, Fill::x(Bsp::e(mute, solo))))
})) })))
} }
fn output_conns (&'a self) -> impl Content<TuiOut> + 'a { fn output_conns (&'a self) -> impl Content<TuiOut> + 'a {
Tryptich::top(self.outputs_height) Fixed::y(3, Tryptich::top(self.outputs_height)
.left(self.width_side, .left(self.width_side,
io_ports(Tui::g(224), Tui::g(32), ||self.app.outputs_with_sizes())) io_ports(Tui::g(224), Tui::g(32), ||self.app.outputs_with_sizes()))
.middle(self.width_mid, per_track_top( .middle(self.width_mid, per_track_top(
@ -134,6 +134,6 @@ impl<'a> ArrangerView<'a> {
t.color.dark.rgb, t.color.dark.rgb,
t.color.darker.rgb, t.color.darker.rgb,
||self.app.outputs_with_sizes() ||self.app.outputs_with_sizes()
))) ))))
} }
} }

View file

@ -4,7 +4,7 @@ impl<'a> ArrangerView<'a> {
/// Render track headers /// Render track headers
pub(crate) fn tracks (&'a self) -> impl Content<TuiOut> + 'a { pub(crate) fn tracks (&'a self) -> impl Content<TuiOut> + 'a {
Tryptich::center(1) Tryptich::center(3)
.left(self.width_side, .left(self.width_side,
button_3("t", "track", format!("{}", self.track_count), self.is_editing)) button_3("t", "track", format!("{}", self.track_count), self.is_editing))
.right(self.width_side, .right(self.width_side,

View file

@ -166,7 +166,8 @@ content!(TuiOut: |self: PoolView<'a>| {
let on_bg = |x|x;//Bsp::b(Repeat(" "), Tui::bg(color.darkest.rgb, x)); let on_bg = |x|x;//Bsp::b(Repeat(" "), Tui::bg(color.darkest.rgb, x));
let border = |x|x;//Outer(Style::default().fg(color.dark.rgb).bg(color.darkest.rgb)).enclose(x); let border = |x|x;//Outer(Style::default().fg(color.dark.rgb).bg(color.darkest.rgb)).enclose(x);
let iter = | |model.clips().clone().into_iter(); let iter = | |model.clips().clone().into_iter();
Tui::bg(Color::Reset, Fixed::y(clips.read().unwrap().len() as u16, on_bg(border(Map::new(iter, move|clip, i|{ let height = clips.read().unwrap().len() as u16;
Tui::bg(Color::Reset, Fixed::y(height, on_bg(border(Map::new(iter, move|clip, i|{
let item_height = 1; let item_height = 1;
let item_offset = i as u16 * item_height; let item_offset = i as u16 * item_height;
let selected = i == model.clip_index(); let selected = i == model.clip_index();