did i just fix arranger layout?

This commit is contained in:
🪞👃🪞 2025-04-17 03:31:32 +03:00
parent 3beb24d594
commit 997c8e2d6e
5 changed files with 69 additions and 65 deletions

View file

@ -42,10 +42,10 @@ 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> {
let ins = |x|Bsp::s(self.inputs(), x); let ins = |x|Bsp::s(self.inputs(), x);
let tracks = |x|Bsp::s(self.tracks(), x); let tracks = |x|Bsp::s(self.tracks(), x);
let outs = |x|Bsp::n(self.outputs(), x); let outs = |x|Bsp::n(self.outputs(), x);
let bg = |x|Tui::bg(Green, x); let bg = |x|Tui::bg(Color::Reset, x);
//let track_scroll = |x|Bsp::s(&self.track_scroll, x); //let track_scroll = |x|Bsp::s(&self.track_scroll, x);
//let scene_scroll = |x|Bsp::e(&self.scene_scroll, x); //let scene_scroll = |x|Bsp::e(&self.scene_scroll, x);
ins(tracks(outs(bg(self.scenes())))) ins(tracks(outs(bg(self.scenes()))))
@ -104,7 +104,7 @@ impl<'a> ArrangerView<'a> {
-> impl ScenesColors<'_> -> impl ScenesColors<'_>
{ {
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.scenes_height {
None None
} else { Some((s, scene, y1, y2, if s == 0 { } else { Some((s, scene, y1, y2, if s == 0 {
None None
@ -118,7 +118,7 @@ impl<'a> ArrangerView<'a> {
-> impl ScenesColors<'_> -> impl ScenesColors<'_>
{ {
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.scenes_height {
None None
} else { } else {
Some((s, scene, y1, y2, if s == 0 { Some((s, scene, y1, y2, if s == 0 {

View file

@ -3,7 +3,8 @@ use crate::*;
impl<'a> ArrangerView<'a> { impl<'a> ArrangerView<'a> {
/// Render input matrix. /// Render input matrix.
pub(crate) fn inputs (&'a self) -> impl Content<TuiOut> + 'a { pub(crate) fn inputs (&'a self) -> impl Content<TuiOut> + 'a {
Bsp::s(Bsp::s(self.input_routes(), self.input_ports()), self.input_intos()) Tui::bg(Color::Reset,
Bsp::s(Bsp::s(self.input_routes(), self.input_ports()), self.input_intos()))
} }
fn input_routes (&'a self) -> impl Content<TuiOut> + 'a { fn input_routes (&'a self) -> impl Content<TuiOut> + 'a {
@ -63,7 +64,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 {
Fixed::y(3, Align::n(Bsp::s( Tui::bg(Color::Reset, Align::n(Bsp::s(
Bsp::s( Bsp::s(
self.output_nexts(), self.output_nexts(),
self.output_froms(), self.output_froms(),

View file

@ -41,13 +41,13 @@ impl Tek {
} }
/// Height available to display track headers. /// Height available to display track headers.
pub(crate) fn h_tracks_area (&self) -> u16 { pub(crate) fn h_tracks_area (&self) -> u16 {
//5 5
self.h().saturating_sub(self.h_inputs() + self.h_outputs()) //self.h().saturating_sub(self.h_inputs() + self.h_outputs())
} }
/// Height available to display tracks. /// Height available to display tracks.
pub(crate) fn h_scenes_area (&self) -> u16 { pub(crate) fn h_scenes_area (&self) -> u16 {
//15 //15
self.h().saturating_sub(self.h_tracks_area()) self.h().saturating_sub(self.h_inputs() + self.h_outputs() + 11)
} }
/// Height taken by all inputs. /// Height taken by all inputs.
pub(crate) fn h_inputs (&self) -> u16 { pub(crate) fn h_inputs (&self) -> u16 {

View file

@ -4,78 +4,80 @@ 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 {
let Self { width_side, width_mid, track_count, track_selected, is_editing, .. } = self;
Tryptich::center(3) Tryptich::center(3)
.left(self.width_side, .left(*width_side, button_3("t", "track", format!("{}", *track_count), *is_editing))
button_3("t", "track", format!("{}", self.track_count), self.is_editing)) .right(*width_side, button_2("T", "add track", *is_editing))
.right(self.width_side, .middle(*width_mid, per_track(*width_mid,
button_2("T", "add track", self.is_editing)) ||self.tracks_with_sizes_scrolled(),
.middle(self.width_mid, |t, track|view_track_header(t, track, *track_selected == Some(t))))
per_track(
self.width_mid,
||self.tracks_with_sizes_scrolled(),
|t, track|view_track_header(t, track, self.track_selected == Some(t))))
} }
/// Render scenes with clips /// Render scenes with clips
pub(crate) fn scenes (&'a self) -> impl Content<TuiOut> + 'a { pub(crate) fn scenes (&'a self) -> impl Content<TuiOut> + 'a {
Tryptich::center(self.scenes_height) let Self {
.left(self.width_side, Map::new( width, width_side, width_mid,
||self.scenes_with_scene_colors(), scenes_height, scene_last, scene_selected,
move|(index, scene, y1, y2, previous): SceneWithColor, _|{ track_selected, is_editing, ..
let offset = y1 as u16; } = self;
let height = (1 + y2 - y1) as u16; Tryptich::center(*scenes_height)
let is_last = self.scene_last == index; .left(*width_side, Map::new(||self.scenes_with_scene_colors(),
view_scene_name( move|(index, scene, y1, y2, previous): SceneWithColor, _|view_scene_name(
self.width, height, offset, *width,
index, scene, previous, is_last, self.scene_selected (1 + y2 - y1) as u16,
) y1 as u16,
})) index,
.middle(self.width_mid, per_track( scene,
self.width_mid, previous,
||self.tracks_with_sizes_scrolled(), *scene_last == index,
move|track_index, track|Map::new( *scene_selected
||self.scenes_with_track_colors(), )))
.middle(*width_mid, per_track(*width_mid, ||self.tracks_with_sizes_scrolled(),
move|track_index, track|Map::new(||self.scenes_with_track_colors(),
move|(scene_index, scene, y1, y2, prev_scene): SceneWithColor<'a>, _| move|(scene_index, scene, y1, y2, prev_scene): SceneWithColor<'a>, _|
view_scene_clip( view_scene_clip(
self.width_mid, *width_mid,
(1 + y2 - y1) as u16, (1 + y2 - y1) as u16,
y1 as u16, y1 as u16,
scene, scene,
prev_scene, prev_scene,
scene_index, scene_index,
track_index, track_index,
self.is_editing, *is_editing,
self.track_selected == Some(track_index), *track_selected == Some(track_index),
self.scene_selected, *scene_selected,
self.scene_last == scene_index, *scene_last == scene_index,
&self.app.editor &self.app.editor
)))) ))))
} }
fn scene_add (&'a self) -> impl Content<TuiOut> + 'a { fn scene_add (&'a self) -> impl Content<TuiOut> + 'a {
let data = (self.scene_selected.unwrap_or(0), self.scene_count); let Self {
self.app.view_cache.write().unwrap().scns.update(Some(data), rewrite!(buf, "({}/{})", data.0, data.1)); scene_selected, scene_count, is_editing, app: Tek { view_cache, .. }, ..
button_3("S", "add scene", self.app.view_cache.read().unwrap().scns.view.clone(), self.is_editing) } = self;
let data = (scene_selected.unwrap_or(0), *scene_count);
view_cache.write().unwrap()
.scns.update(Some(data), rewrite!(buf, "({}/{})", data.0, data.1));
button_3("S", "add scene", view_cache.read().unwrap().scns.view.clone(), *is_editing)
} }
fn track_counter (&'a self) -> Arc<RwLock<String>> { fn track_counter (&'a self) -> Arc<RwLock<String>> {
let track_counter_data = (self.track_selected.unwrap_or(0), self.track_count); let Self {
self.app.view_cache.write().unwrap().trks.update( track_selected, track_count, app: Tek { view_cache, .. }, ..
Some(track_counter_data), } = self;
rewrite!(buf, "{}/{}", track_counter_data.0, track_counter_data.1) let data = (track_selected.unwrap_or(0), *track_count);
); view_cache.write().unwrap()
self.app.view_cache.read().unwrap().trks.view.clone() .trks.update(Some(data), rewrite!(buf, "{}/{}", data.0, data.1));
view_cache.read().unwrap().trks.view.clone()
} }
} }
fn view_track_header <'a> ( fn view_track_header <'a> (
index: usize, index: usize, track: &'a Track, active: bool
track: &'a Track,
active: bool
) -> impl Content<TuiOut> + use<'a> { ) -> impl Content<TuiOut> + use<'a> {
let fg = track.color.lightest.rgb; let fg = track.color.lightest.rgb;
let bg = if active { track.color.light.rgb } else { track.color.base.rgb }; let bg = if active { track.color.light.rgb } else { track.color.base.rgb };
let bg2 = Reset;//if index > 0 { self.tracks()[index - 1].color.base.rgb } else { Reset }; let bg2 = Reset;//if index > 0 { self.tracks()[index - 1].color.base.rgb } else { Reset };
wrap(bg, fg, Tui::bold(true, Fill::x(Align::nw(&track.name)))) wrap(bg, fg, Tui::bold(true, Fill::x(Align::nw(&track.name))))
} }
@ -91,14 +93,14 @@ pub(crate) fn view_scene_name (
select: Option<usize>, select: Option<usize>,
) -> impl Content<TuiOut> { ) -> impl Content<TuiOut> {
Fill::x(map_south(offset, height, Fixed::y(height, view_scene_cell( Fill::x(map_south(offset, height, Fixed::y(height, view_scene_cell(
"",
Some(scene.name.clone()),
last, last,
select, select,
true, true,
index, index,
&scene.color, &scene.color,
prev, prev,
Some(scene.name.clone()),
"",
scene.color.lightest.rgb scene.color.lightest.rgb
)))) ))))
} }
@ -126,27 +128,27 @@ pub(crate) fn view_scene_clip <'a> (
let active = editing && same_track && scene_selected == Some(scene_index); let active = editing && same_track && scene_selected == Some(scene_index);
let edit = |x|Bsp::b(x, When(active, editor)); let edit = |x|Bsp::b(x, When(active, editor));
map_south(offset, height, edit(Fixed::y(height, view_scene_cell( map_south(offset, height, edit(Fixed::y(height, view_scene_cell(
"",
name,
scene_is_last, scene_is_last,
scene_selected, scene_selected,
same_track, same_track,
scene_index, scene_index,
&bg, &bg,
prev, prev,
name,
"",
fg fg
)))) ))))
} }
pub(crate) fn view_scene_cell <'a> ( pub(crate) fn view_scene_cell <'a> (
icon: &'a str,
name: Option<Arc<str>>,
is_last: bool, is_last: bool,
selected: Option<usize>, selected: Option<usize>,
same_track: bool, same_track: bool,
scene: usize, scene: usize,
color: &ItemPalette, color: &ItemPalette,
prev: Option<ItemPalette>, prev_color: Option<ItemPalette>,
name: Option<Arc<str>>,
icon: &'a str,
fg: Color, fg: Color,
) -> impl Content<TuiOut> + use<'a> { ) -> impl Content<TuiOut> + use<'a> {
Phat { Phat {
@ -155,7 +157,7 @@ pub(crate) fn view_scene_cell <'a> (
content: Fill::x(Align::w(Tui::bold(true, Bsp::e(icon, name)))), content: Fill::x(Align::w(Tui::bold(true, Bsp::e(icon, name)))),
colors: Tek::colors( colors: Tek::colors(
color, color,
prev, prev_color,
same_track && selected == Some(scene), same_track && selected == Some(scene),
same_track && scene > 0 && selected == Some(scene - 1), same_track && scene > 0 && selected == Some(scene - 1),
is_last is_last

View file

@ -1,4 +1,5 @@
(bsp/s (fixed/y 1 :transport) (bsp/s (fixed/y 1 :transport)
(bsp/n (fixed/y 1 :status) (bsp/n (fixed/y 1 :status)
(fill/xy (bsp/a (fill/xy (align/e :pool)) (fill/xy (bsp/a
(fill/xy (align/e :pool))
:arranger)))) :arranger))))