mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
82 lines
4 KiB
Rust
82 lines
4 KiB
Rust
use crate::*;
|
|
|
|
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(*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(),
|
|
|index, track|wrap(
|
|
if *track_selected == Some(index) {
|
|
track.color.light
|
|
} else {
|
|
track.color.base
|
|
}.rgb,
|
|
track.color.lightest.rgb,
|
|
Tui::bold(true, Fill::x(Align::nw(&track.name)))
|
|
)))
|
|
}
|
|
/// Render scenes with clips
|
|
pub(crate) fn scenes (&'a self) -> impl Content<TuiOut> + 'a {
|
|
|
|
let Self {
|
|
width, width_side, width_mid,
|
|
scenes_height, scene_last, scene_selected,
|
|
track_selected, is_editing, app: Tek { editor, .. }, ..
|
|
} = self;
|
|
|
|
Tryptich::center(*scenes_height)
|
|
.left(*width_side, Map::new(||self.scenes_with_scene_colors(),
|
|
move|(index, scene, y1, y2, previous): SceneWithColor, _|{
|
|
let name = Some(scene.name.clone());
|
|
let color = scene.color;
|
|
let prev_color = previous;
|
|
let is_last = *scene_last == index;
|
|
let selected = *scene_selected;
|
|
let same_track = true;
|
|
let scene = index;
|
|
let height = (1 + y2 - y1) as u16;
|
|
Fill::x(map_south(y1 as u16, (1 + y2 - y1) as u16, Fixed::y(height, Phat {
|
|
width: 0,
|
|
height: 0,
|
|
content: Fill::x(Align::w(Tui::bold(true, Bsp::e(" ⯈ ", name)))),
|
|
colors: Tek::colors(
|
|
&color,
|
|
prev_color,
|
|
same_track && *scene_selected == Some(index),
|
|
same_track && index > 0 && *scene_selected == Some(index - 1),
|
|
*scene_last == index
|
|
)
|
|
})))
|
|
}))
|
|
.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>, _|{
|
|
let (name, _fg, bg) = if let Some(clip) = &scene.clips[track_index] {
|
|
let clip = clip.read().unwrap();
|
|
(Some(clip.name.clone()), clip.color.lightest.rgb, clip.color)
|
|
} else {
|
|
(None, Tui::g(96), ItemPalette::G[32])
|
|
};
|
|
let same_track = *track_selected == Some(track_index);
|
|
let height = (1 + y2 - y1) as u16;
|
|
map_south(y1 as u16, height, Bsp::b(Fixed::y(height, Phat {
|
|
width: 0,
|
|
height: 0,
|
|
content: Fill::x(Align::w(Tui::bold(true, Bsp::e(" ⏹ ", name)))),
|
|
colors: Tek::colors(
|
|
&bg,
|
|
None,
|
|
same_track && *scene_selected == Some(scene_index),
|
|
same_track && scene_index > 0 && *scene_selected == Some(scene_index - 1),
|
|
*scene_last == scene_index
|
|
)
|
|
}), When(
|
|
*is_editing && same_track && *scene_selected == Some(scene_index),
|
|
editor
|
|
)))
|
|
})))
|
|
}
|
|
}
|