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

@ -45,7 +45,7 @@ impl<'a> Content<TuiOut> for ArrangerView<'a> {
let ins = |x|Bsp::s(self.inputs(), x);
let tracks = |x|Bsp::s(self.tracks(), 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 scene_scroll = |x|Bsp::e(&self.scene_scroll, x);
ins(tracks(outs(bg(self.scenes()))))
@ -104,7 +104,7 @@ impl<'a> ArrangerView<'a> {
-> impl ScenesColors<'_>
{
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
} else { Some((s, scene, y1, y2, if s == 0 {
None
@ -118,7 +118,7 @@ impl<'a> ArrangerView<'a> {
-> impl ScenesColors<'_>
{
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
} else {
Some((s, scene, y1, y2, if s == 0 {

View file

@ -3,7 +3,8 @@ use crate::*;
impl<'a> ArrangerView<'a> {
/// Render input matrix.
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 {
@ -63,7 +64,7 @@ impl<'a> ArrangerView<'a> {
/// Render output matrix.
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(
self.output_nexts(),
self.output_froms(),

View file

@ -41,13 +41,13 @@ impl Tek {
}
/// Height available to display track headers.
pub(crate) fn h_tracks_area (&self) -> u16 {
//5
self.h().saturating_sub(self.h_inputs() + self.h_outputs())
5
//self.h().saturating_sub(self.h_inputs() + self.h_outputs())
}
/// Height available to display tracks.
pub(crate) fn h_scenes_area (&self) -> u16 {
//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.
pub(crate) fn h_inputs (&self) -> u16 {

View file

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

View file

@ -1,4 +1,5 @@
(bsp/s (fixed/y 1 :transport)
(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))))