down to 1 weirdest error

This commit is contained in:
🪞👃🪞 2025-05-14 15:13:25 +03:00
parent 254e19db0d
commit f3c67f95b5

View file

@ -86,7 +86,7 @@ impl<'a> Content<TuiOut> for ArrangerView<'a> {
let bg = |x|Tui::bg(Reset, x);
//let track_scroll = |x|Bsp::s(&self.track_scroll, x);
//let scene_scroll = |x|Bsp::e(&self.scene_scroll, x);
outs(tracks(devices(ins(bg(self.scenes(None))))))
outs(tracks(devices(ins(bg(self.scenes(&None))))))
}
}
@ -150,7 +150,7 @@ impl<'a> ArrangerView<'a> {
pub(crate) const H_EDITOR: usize = 15;
/// Render scenes with clips
pub(crate) fn scenes (&'a self, editor: Option<MidiEditor>) -> impl Content<TuiOut> + 'a {
pub(crate) fn scenes (&'a self, editor: &'a Option<MidiEditor>) -> impl Content<TuiOut> + 'a {
/// A scene with size and color.
type SceneWithColor<'a> = (usize, &'a Scene, usize, usize, Option<ItemTheme>);
let Self {
@ -163,8 +163,10 @@ impl<'a> ArrangerView<'a> {
let selection = Has::<Option<Selection>>::get(self.arrangement);
let selected_track = selection.map(|s|s.track()).flatten();
let selected_scene = selection.map(|s|s.scene()).flatten();
Tryptich::center(*scenes_height)
let scenes_with_scene_colors = ||HasScenes::scenes_with_sizes(self.arrangement,
.left(*width_side, Map::new(
move||arrangement.scenes_with_sizes(
*is_editing,
Self::H_SCENE,
Self::H_EDITOR,
@ -178,9 +180,8 @@ impl<'a> ArrangerView<'a> {
} else {
Some(arrangement.scenes()[s-1].color)
}))
});
let scene_header = |(s, scene, y1, y2, previous): SceneWithColor, _|{
}),
move |(s, scene, y1, y2, previous): SceneWithColor, _|{
let height = (1 + y2 - y1) as u16;
let name = Some(scene.name.clone());
let content = Fill::x(Align::w(Tui::bold(true, Bsp::e("", name))));
@ -210,38 +211,30 @@ impl<'a> ArrangerView<'a> {
Fill::x(map_south(y1 as u16, height, Fixed::y(height, Phat {
width: 0, height: 0, content, colors: [fg, bg, hi, lo]
})))
};
}))
let scenes_with_track_colors = |track: usize| arrangement.scenes_with_sizes(
.middle(*width_mid, per_track(
*width_mid,
||self.tracks_with_sizes_scrolled(),
move|track_index, track|Map::new(
move||arrangement.scenes_with_sizes(
self.is_editing,
Self::H_SCENE,
Self::H_EDITOR,
selected_track,
selected_scene,
).map_while(|(s, scene, y1, y2)|if y2 as u16 > self.scenes_height {
).map_while(move|(s, scene, y1, y2)|if y2 as u16 > self.scenes_height {
None
} else {
Some((s, scene, y1, y2, if s == 0 {
None
} else {
Some(self.arrangement.scenes[s-1].clips[track].as_ref()
Some(self.arrangement.scenes[s-1].clips[track_index].as_ref()
.map(|c|c.read().unwrap().color)
.unwrap_or(ItemTheme::G[32]))
}))
});
Tryptich::center(*scenes_height)
.left(*width_side, Map::new(
||scenes_with_scene_colors(),
scene_header))
.middle(*width_mid, per_track(
*width_mid,
||self.tracks_with_sizes_scrolled(),
|track_index, track|Map::new(
||scenes_with_track_colors(track_index),
|(s, scene, y1, y2, previous): SceneWithColor<'a>, _|{
}),
move|(s, scene, y1, y2, previous): SceneWithColor<'a>, _|{
let (name, theme) = if let Some(clip) = &scene.clips[track_index] {
let clip = clip.read().unwrap();
(Some(clip.name.clone()), clip.color)