mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
reenable adding tracks/scenes
This commit is contained in:
parent
62bfb0120b
commit
f1f5ac63e1
4 changed files with 52 additions and 139 deletions
|
|
@ -3,6 +3,8 @@ use crate::*;
|
|||
impl<T> TracksView for T
|
||||
where T: ScenesView + HasMidiIns + HasMidiOuts + HasSize<TuiOut> + HasTrackScroll + HasSelection + HasMidiIns + HasEditor {}
|
||||
|
||||
impl<T: TracksView + ScenesView + Send + Sync> ClipsView for T {}
|
||||
|
||||
pub trait TracksView:
|
||||
ScenesView + HasMidiIns + HasMidiOuts + HasSize<TuiOut> + HasTrackScroll + HasSelection + HasMidiIns + HasEditor
|
||||
{
|
||||
|
|
@ -39,7 +41,7 @@ pub trait TracksView:
|
|||
Fixed::x(4, button_add),
|
||||
Bsp::e(
|
||||
Fixed::x(20, Align::w(button)),
|
||||
content
|
||||
Fill::xy(Align::c(content))
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -53,10 +55,10 @@ pub trait TracksView:
|
|||
theme,
|
||||
button_2("t", "rack", false),
|
||||
button_2("T", "+", false),
|
||||
Fixed::y(1, Align::w(Tui::bg(theme.darker.rgb, Align::w(Fill::x(
|
||||
Tui::bg(theme.darker.rgb, Fixed::y(1, Fill::x(
|
||||
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
for (index, track, x1, x2) in self.tracks_with_sizes() {
|
||||
add(&Fixed::x(track.width as u16,
|
||||
add(&Fixed::x(self.track_width(index, track),
|
||||
Tui::bg(if self.selection().track() == Some(index) {
|
||||
track.color.light.rgb
|
||||
} else {
|
||||
|
|
@ -66,7 +68,7 @@ pub trait TracksView:
|
|||
Tui::fg(Rgb(255, 255, 255), Tui::bold(true, &track.name))
|
||||
)))));
|
||||
}
|
||||
})))))))
|
||||
})))))
|
||||
}
|
||||
fn view_track_outputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||
let mut h = 0u16;
|
||||
|
|
@ -81,16 +83,17 @@ pub trait TracksView:
|
|||
Tui::bg(theme.darker.rgb, Align::w(Fill::x(
|
||||
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
for (index, track, x1, x2) in self.tracks_with_sizes() {
|
||||
add(&Fixed::x(track.width as u16, Align::nw(Bsp::n(
|
||||
Tui::bg(if self.selection().track() == Some(index) {
|
||||
track.color.light.rgb
|
||||
} else {
|
||||
track.color.base.rgb
|
||||
}, Fill::x(Align::w(format!("·mute ·solo")))),
|
||||
Map::south(2, ||track.sequencer.midi_outs.iter(),
|
||||
|port, index|Tui::fg(Rgb(255, 255, 255),
|
||||
Fixed::y(2, Tui::bg(track.color.dark.rgb, Fill::x(Align::w(
|
||||
format!("·o{index:02} {}", port.name())))))))))));
|
||||
add(&Fixed::x(self.track_width(index, track),
|
||||
Align::nw(Bsp::n(
|
||||
Tui::bg(if self.selection().track() == Some(index) {
|
||||
track.color.light.rgb
|
||||
} else {
|
||||
track.color.base.rgb
|
||||
}, Fill::x(Align::w(format!("·mute ·solo")))),
|
||||
Map::south(2, ||track.sequencer.midi_outs.iter(),
|
||||
|port, index|Tui::fg(Rgb(255, 255, 255),
|
||||
Fixed::y(2, Tui::bg(track.color.dark.rgb, Fill::x(Align::w(
|
||||
format!("·o{index:02} {}", port.name())))))))))));
|
||||
}
|
||||
})))))))
|
||||
}
|
||||
|
|
@ -106,7 +109,7 @@ pub trait TracksView:
|
|||
Fixed::y(h, Tui::bg(theme.darker.rgb, Align::w(Fill::x(Stack::east(
|
||||
move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
for (index, track, x1, x2) in self.tracks_with_sizes() {
|
||||
add(&Fixed::xy(track.width as u16, h + 1,
|
||||
add(&Fixed::xy(self.track_width(index, track), h + 1,
|
||||
Tui::bg(track.color.dark.rgb, Align::nw(Map::south(1, move||0..h,
|
||||
|_, index|format!("·d{index:02} {}", "--------"))))));
|
||||
}
|
||||
|
|
@ -124,7 +127,7 @@ pub trait TracksView:
|
|||
Tui::bg(theme.darker.rgb, Align::w(Fill::x(
|
||||
Stack::east(move|add: &mut dyn FnMut(&dyn Render<TuiOut>)|{
|
||||
for (index, track, x1, x2) in self.tracks_with_sizes() {
|
||||
add(&Fixed::xy(track.width as u16, h + 1,
|
||||
add(&Fixed::xy(self.track_width(index, track), h + 1,
|
||||
Align::nw(Bsp::s(
|
||||
Tui::bg(track.color.base.rgb,
|
||||
Fill::x(Align::w(format!("·mon ·rec ·dub")))),
|
||||
|
|
@ -133,6 +136,15 @@ pub trait TracksView:
|
|||
Fill::x(Align::w(format!("·i{index:02} {}", port.name())))))))));
|
||||
}})))))
|
||||
}
|
||||
fn track_width (&self, index: usize, track: &Track) -> u16 {
|
||||
(if self.selection().track() == Some(index)
|
||||
&& let Some(editor) = self.editor()
|
||||
{
|
||||
editor.width().max(24).max(track.width)
|
||||
} else {
|
||||
track.width
|
||||
}) as u16
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ScenesView: HasEditor + HasSelection + HasSceneScroll + Send + Sync {
|
||||
|
|
@ -173,10 +185,7 @@ pub trait ScenesView: HasEditor + HasSelection + HasSceneScroll + Send + Sync {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: TracksView + ScenesView + Send + Sync> ClipsView for T {}
|
||||
|
||||
pub trait ClipsView: TracksView + ScenesView + Send + Sync {
|
||||
|
||||
fn view_scenes_clips <'a> (&'a self)
|
||||
-> impl Content<TuiOut> + 'a
|
||||
{
|
||||
|
|
@ -185,7 +194,7 @@ pub trait ClipsView: TracksView + ScenesView + Send + Sync {
|
|||
//column(&Fixed::x(5, Fill::xy(Tui::bg(Green, "kyp"))));
|
||||
column(&Fixed::x(
|
||||
if self.selection().track() == Some(track_index)
|
||||
&& let Some(editor) = self.editor ()
|
||||
&& let Some(editor) = self.editor()
|
||||
{
|
||||
editor.width().max(24).max(track.width)
|
||||
} else {
|
||||
|
|
@ -245,82 +254,9 @@ pub trait ClipsView: TracksView + ScenesView + Send + Sync {
|
|||
Fill::xy(When(self.selection().track() == Some(track_index)
|
||||
&& self.selection().scene() == Some(scene_index)
|
||||
&& self.is_editing(), self.editor())))))));
|
||||
//let (name, theme) = if let Some(clip) = &scene.clips.get(track_index).flatten() {
|
||||
//let clip = clip.read().unwrap();
|
||||
//(Some(clip.name.clone()), clip.color)
|
||||
//} else {
|
||||
//(None, ItemTheme::G[32])
|
||||
//};
|
||||
//let content = Fill::x(Align::w(Tui::bold(true, Bsp::e(" ⏹ ", name))));
|
||||
//let same_track = self.track_selected() == Some(track_index);
|
||||
//let selected = same_track && self.scene_selected() == Some(s);
|
||||
//let neighbor = same_track && s > 0 && self.scene_selected() == Some(s - 1);
|
||||
//let is_last = self.scenes().len().saturating_sub(1) == s;
|
||||
//let fg = theme.lightest.rgb;
|
||||
//let bg = if selected { theme.light } else { theme.base }.rgb;
|
||||
//let hi = if let Some(previous) = previous {
|
||||
//if neighbor { previous.light.rgb } else { previous.base.rgb }
|
||||
//} else {
|
||||
//Reset
|
||||
//};
|
||||
//let lo = if is_last {
|
||||
//Reset
|
||||
//} else if selected {
|
||||
//theme.light.rgb
|
||||
//} else {
|
||||
//theme.base.rgb
|
||||
//};
|
||||
//let height = (1 + y2 - y1) as u16;
|
||||
//let is_editing = false; //FIXME
|
||||
//let editor = (); //FIXME
|
||||
//cell(&Fixed::xy(track.width as u16, 2, Bsp::b(Fixed::y(height, Phat {
|
||||
//width: 0, height: 0, content, colors: [fg, bg, hi, lo]
|
||||
//}), When(
|
||||
//is_editing && same_track && self.scene_selected() == Some(s),
|
||||
//editor
|
||||
//))))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn scenes_clips_2 <'a> (
|
||||
&'a self,
|
||||
theme: ItemTheme
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
Fixed::y(self.scenes().len() as u16 * 2, Tui::bg(theme.darker.rgb,
|
||||
Align::w(Fill::x(Map::new(||self.scenes().iter().skip(self.scene_scroll()),
|
||||
move|scene: &'a Scene, index|self.track_scenes(index, scene))))))
|
||||
}
|
||||
|
||||
fn track_scenes <'a> (
|
||||
&'a self,
|
||||
scene_index: usize,
|
||||
scene: &'a Scene
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
Push::y(scene_index as u16 * 2u16, Fixed::xy(20, 2, Map::new(
|
||||
move||scene.clips.iter().skip(self.track_scroll()),
|
||||
move|clip: &'a Option<Arc<RwLock<MidiClip>>>, track_index|
|
||||
self.track_scene_clip(scene_index, scene, track_index, clip))))
|
||||
}
|
||||
|
||||
fn track_scene_clip (
|
||||
&self,
|
||||
scene_index: usize,
|
||||
scene: &Scene,
|
||||
track_index: usize,
|
||||
clip: &Option<Arc<RwLock<MidiClip>>>
|
||||
) -> impl Content<TuiOut> {
|
||||
let (theme, text) = if let Some(clip) = clip {
|
||||
let clip = clip.read().unwrap();
|
||||
(clip.color, clip.name.clone())
|
||||
} else {
|
||||
(scene.color, Default::default())
|
||||
};
|
||||
Push::x(track_index as u16 * 14, Tui::bg(theme.dark.rgb, Bsp::e(
|
||||
format!(" {scene_index:2} {track_index:2} "),
|
||||
Tui::fg(Rgb(255, 255, 255),
|
||||
Tui::bold(true, format!("{}", text))))))
|
||||
}
|
||||
}
|
||||
|
||||
pub trait HasWidth {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue