mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-04-29 22:10:14 +02:00
scene_cell to top level
This commit is contained in:
parent
1924d51323
commit
ec85224f3a
|
@ -59,12 +59,14 @@ impl Tek {
|
|||
Fill::x(Fixed::y(1, ScrollbarH { offset, length, total }))
|
||||
}
|
||||
|
||||
/// Render something centered for each track.
|
||||
fn per_track <'a, T: Content<TuiOut> + 'a> (
|
||||
&'a self, f: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
self.per_track_top(move|index, track|Fill::y(Align::y(f(index, track))))
|
||||
}
|
||||
|
||||
/// Render something top-aligned for each track.
|
||||
fn per_track_top <'a, T: Content<TuiOut> + 'a> (
|
||||
&'a self, f: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
|
@ -123,15 +125,21 @@ impl Tek {
|
|||
width: u16,
|
||||
height: u16,
|
||||
offset: u16,
|
||||
s: usize,
|
||||
index: usize,
|
||||
scene: &Scene,
|
||||
prev: Option<ItemPalette>,
|
||||
) -> impl Content<TuiOut> + use<'_> {
|
||||
let bg = scene.color;
|
||||
let fg = scene.color.lightest.rgb;
|
||||
let name = Some(scene.name.clone());
|
||||
let cell = self.view_scene_cell(true, s, &bg, prev, name, " ⯈ ", fg);
|
||||
Fill::x(map_south(offset, height, Fixed::y(height, cell)))
|
||||
Fill::x(map_south(offset, height, Fixed::y(height, scene_cell(
|
||||
index == self.scenes.len().saturating_sub(1),
|
||||
self.selected().scene(),
|
||||
true,
|
||||
index,
|
||||
&scene.color,
|
||||
prev,
|
||||
Some(scene.name.clone()),
|
||||
" ⯈ ",
|
||||
scene.color.lightest.rgb
|
||||
))))
|
||||
}
|
||||
|
||||
fn view_scene_clip (
|
||||
|
@ -141,44 +149,31 @@ impl Tek {
|
|||
offset: u16,
|
||||
scene: &Scene,
|
||||
prev: Option<ItemPalette>,
|
||||
s: usize,
|
||||
t: usize,
|
||||
scene_index: usize,
|
||||
track_index: usize,
|
||||
editing: bool,
|
||||
same_track: bool,
|
||||
selected_scene: Option<usize>
|
||||
) -> impl Content<TuiOut> + use<'_> {
|
||||
let (name, fg, bg) = if let Some(clip) = &scene.clips[t] {
|
||||
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 active = editing && same_track && selected_scene == Some(s);
|
||||
let active = editing && same_track && selected_scene == Some(scene_index);
|
||||
let edit = |x|Bsp::b(x, When(active, &self.editor));
|
||||
let cell = self.view_scene_cell(same_track, s, &bg, prev, name, " ⏹ ", fg);
|
||||
map_south(offset, height, edit(Fixed::y(height, cell)))
|
||||
}
|
||||
|
||||
fn view_scene_cell <'a> (
|
||||
&self,
|
||||
same_track: bool,
|
||||
scene: usize,
|
||||
color: &ItemPalette,
|
||||
prev: Option<ItemPalette>,
|
||||
name: Option<Arc<str>>,
|
||||
icon: &'a str,
|
||||
fg: Color,
|
||||
) -> impl Content<TuiOut> + use<'a> {
|
||||
let selected_scene = self.selected().scene();
|
||||
let selected = same_track && selected_scene == Some(scene);
|
||||
let neighbor = same_track && scene > 0 && selected_scene == Some(scene - 1);
|
||||
let is_last = scene == self.scenes.len().saturating_sub(1);
|
||||
Phat {
|
||||
width: 0,
|
||||
height: 0,
|
||||
colors: Self::colors(color, prev, selected, neighbor, is_last),
|
||||
content: Fill::x(Align::w(Tui::bold(true, Bsp::e(icon, name))))
|
||||
}
|
||||
map_south(offset, height, edit(Fixed::y(height, scene_cell(
|
||||
scene_index == self.scenes.len().saturating_sub(1),
|
||||
self.selected().scene(),
|
||||
same_track,
|
||||
scene_index,
|
||||
&bg,
|
||||
prev,
|
||||
name,
|
||||
" ⏹ ",
|
||||
fg
|
||||
))))
|
||||
}
|
||||
|
||||
pub fn view_scene_add (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
|
@ -270,6 +265,31 @@ impl Tek {
|
|||
|
||||
}
|
||||
|
||||
fn scene_cell <'a> (
|
||||
is_last: bool,
|
||||
selected_scene: Option<usize>,
|
||||
same_track: bool,
|
||||
scene: usize,
|
||||
color: &ItemPalette,
|
||||
prev: Option<ItemPalette>,
|
||||
name: Option<Arc<str>>,
|
||||
icon: &'a str,
|
||||
fg: Color,
|
||||
) -> impl Content<TuiOut> + use<'a> {
|
||||
Phat {
|
||||
width: 0,
|
||||
height: 0,
|
||||
content: Fill::x(Align::w(Tui::bold(true, Bsp::e(icon, name)))),
|
||||
colors: Tek::colors(
|
||||
color,
|
||||
prev,
|
||||
same_track && selected_scene == Some(scene),
|
||||
same_track && scene > 0 && selected_scene == Some(scene - 1),
|
||||
is_last
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn track_header <'a> (t: usize, track: &'a Track, active: bool) -> impl Content<TuiOut> + use<'a> {
|
||||
let name = &track.name;
|
||||
let fg = track.color.lightest.rgb;
|
||||
|
|
Loading…
Reference in a new issue