mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
fold-in view_track
This commit is contained in:
parent
aa8eaf2e2b
commit
37be2f4add
2 changed files with 80 additions and 78 deletions
|
|
@ -3,7 +3,6 @@ mod view_clock; pub use self::view_clock::*;
|
|||
mod view_color; pub use self::view_color::*;
|
||||
mod view_memo; pub use self::view_memo::*;
|
||||
mod view_meter; pub use self::view_meter::*;
|
||||
mod view_track; pub use self::view_track::*;
|
||||
mod view_ports; pub use self::view_ports::*;
|
||||
mod view_layout; pub use self::view_layout::*;
|
||||
pub(crate) use std::fmt::Write;
|
||||
|
|
@ -90,6 +89,85 @@ 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;
|
||||
|
||||
let scene_headers = Map::new(||self.scenes_with_scene_colors(),
|
||||
move|(index, scene, y1, y2, previous): SceneWithColor, _|{
|
||||
let same_track = true;
|
||||
let height = (1 + y2 - y1) as u16;
|
||||
let name = Some(scene.name.clone());
|
||||
Fill::x(map_south(y1 as u16, height, Fixed::y(height, Phat {
|
||||
width: 0,
|
||||
height: 0,
|
||||
content: Fill::x(Align::w(Tui::bold(true, Bsp::e(" ⯈ ", name)))),
|
||||
colors: Tek::colors(
|
||||
&scene.color,
|
||||
previous,
|
||||
same_track && *scene_selected == Some(index),
|
||||
same_track && index > 0 && *scene_selected == Some(index - 1),
|
||||
*scene_last == index
|
||||
)
|
||||
})))
|
||||
});
|
||||
|
||||
let scene_track_clips = 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
|
||||
)))
|
||||
}));
|
||||
|
||||
Tryptich::center(*scenes_height)
|
||||
.left(*width_side, scene_headers)
|
||||
.middle(*width_mid, scene_track_clips)
|
||||
}
|
||||
|
||||
pub(crate) fn tracks_with_sizes_scrolled (&'a self)
|
||||
-> impl TracksSizes<'a>
|
||||
{
|
||||
|
|
@ -130,6 +208,7 @@ impl<'a> ArrangerView<'a> {
|
|||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl Tek {
|
||||
|
|
|
|||
|
|
@ -1,77 +0,0 @@
|
|||
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 same_track = true;
|
||||
let height = (1 + y2 - y1) as u16;
|
||||
let name = Some(scene.name.clone());
|
||||
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(
|
||||
&scene.color,
|
||||
previous,
|
||||
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,
|
||||
Some(bg),
|
||||
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
|
||||
)))
|
||||
})))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue