mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
scene_cell to top level
This commit is contained in:
parent
1924d51323
commit
ec85224f3a
1 changed files with 54 additions and 34 deletions
|
|
@ -59,12 +59,14 @@ impl Tek {
|
||||||
Fill::x(Fixed::y(1, ScrollbarH { offset, length, total }))
|
Fill::x(Fixed::y(1, ScrollbarH { offset, length, total }))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Render something centered for each track.
|
||||||
fn per_track <'a, T: Content<TuiOut> + 'a> (
|
fn per_track <'a, T: Content<TuiOut> + 'a> (
|
||||||
&'a self, f: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
|
&'a self, f: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
|
||||||
) -> impl Content<TuiOut> + 'a {
|
) -> impl Content<TuiOut> + 'a {
|
||||||
self.per_track_top(move|index, track|Fill::y(Align::y(f(index, track))))
|
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> (
|
fn per_track_top <'a, T: Content<TuiOut> + 'a> (
|
||||||
&'a self, f: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
|
&'a self, f: impl Fn(usize, &'a Track)->T + Send + Sync + 'a
|
||||||
) -> impl Content<TuiOut> + 'a {
|
) -> impl Content<TuiOut> + 'a {
|
||||||
|
|
@ -123,15 +125,21 @@ impl Tek {
|
||||||
width: u16,
|
width: u16,
|
||||||
height: u16,
|
height: u16,
|
||||||
offset: u16,
|
offset: u16,
|
||||||
s: usize,
|
index: usize,
|
||||||
scene: &Scene,
|
scene: &Scene,
|
||||||
prev: Option<ItemPalette>,
|
prev: Option<ItemPalette>,
|
||||||
) -> impl Content<TuiOut> + use<'_> {
|
) -> impl Content<TuiOut> + use<'_> {
|
||||||
let bg = scene.color;
|
Fill::x(map_south(offset, height, Fixed::y(height, scene_cell(
|
||||||
let fg = scene.color.lightest.rgb;
|
index == self.scenes.len().saturating_sub(1),
|
||||||
let name = Some(scene.name.clone());
|
self.selected().scene(),
|
||||||
let cell = self.view_scene_cell(true, s, &bg, prev, name, " ⯈ ", fg);
|
true,
|
||||||
Fill::x(map_south(offset, height, Fixed::y(height, cell)))
|
index,
|
||||||
|
&scene.color,
|
||||||
|
prev,
|
||||||
|
Some(scene.name.clone()),
|
||||||
|
" ⯈ ",
|
||||||
|
scene.color.lightest.rgb
|
||||||
|
))))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view_scene_clip (
|
fn view_scene_clip (
|
||||||
|
|
@ -141,44 +149,31 @@ impl Tek {
|
||||||
offset: u16,
|
offset: u16,
|
||||||
scene: &Scene,
|
scene: &Scene,
|
||||||
prev: Option<ItemPalette>,
|
prev: Option<ItemPalette>,
|
||||||
s: usize,
|
scene_index: usize,
|
||||||
t: usize,
|
track_index: usize,
|
||||||
editing: bool,
|
editing: bool,
|
||||||
same_track: bool,
|
same_track: bool,
|
||||||
selected_scene: Option<usize>
|
selected_scene: Option<usize>
|
||||||
) -> impl Content<TuiOut> + use<'_> {
|
) -> 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();
|
let clip = clip.read().unwrap();
|
||||||
(Some(clip.name.clone()), clip.color.lightest.rgb, clip.color)
|
(Some(clip.name.clone()), clip.color.lightest.rgb, clip.color)
|
||||||
} else {
|
} else {
|
||||||
(None, Tui::g(96), ItemPalette::G[32])
|
(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 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, scene_cell(
|
||||||
map_south(offset, height, edit(Fixed::y(height, cell)))
|
scene_index == self.scenes.len().saturating_sub(1),
|
||||||
}
|
self.selected().scene(),
|
||||||
|
same_track,
|
||||||
fn view_scene_cell <'a> (
|
scene_index,
|
||||||
&self,
|
&bg,
|
||||||
same_track: bool,
|
prev,
|
||||||
scene: usize,
|
name,
|
||||||
color: &ItemPalette,
|
" ⏹ ",
|
||||||
prev: Option<ItemPalette>,
|
fg
|
||||||
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))))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view_scene_add (&self) -> impl Content<TuiOut> + use<'_> {
|
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> {
|
fn track_header <'a> (t: usize, track: &'a Track, active: bool) -> impl Content<TuiOut> + use<'a> {
|
||||||
let name = &track.name;
|
let name = &track.name;
|
||||||
let fg = track.color.lightest.rgb;
|
let fg = track.color.lightest.rgb;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue