arranger: ClipsView at last

This commit is contained in:
🪞👃🪞 2025-05-17 08:03:38 +03:00
parent b5326b578c
commit 4d0868add8
6 changed files with 55 additions and 33 deletions

View file

@ -34,3 +34,33 @@ impl ClipCommand {
impl Arrangement {
}
impl ClipsView for Arrangement {}
impl<'a> ClipsView for ArrangerView<'a> {}
pub trait ClipsView: HasTrackScroll + HasSceneScroll + Send + Sync {
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(scene, index))))))
}
fn track_scenes (&self, scene: &Scene, scene_index: usize) -> impl Content<TuiOut> {
Push::y(scene_index as u16 * 2u16, Fixed::xy(20, 2, Map::new(
move||scene.clips.iter().skip(self.track_scroll()),
move|clip: &Option<Arc<RwLock<MidiClip>>>, track_index|{
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))))))
})))
}
}

View file

@ -159,28 +159,6 @@ pub trait ScenesView: HasSceneScroll + Send + Sync {
)))
})))
}
fn scenes_clips_2 (&self, theme: ItemTheme) -> impl Content<TuiOut> {
let h = self.scenes().len() as u16 * 2;
let bg = theme.darker.rgb;
Fixed::y(h, Tui::bg(bg, Align::w(Fill::x(Map::new(
||self.scenes().iter().skip(self.scene_scroll()),
move|scene: &Scene, index1|
Push::y(index1 as u16 * 2u16, Fixed::xy(20, 2,
Map::new(
move||scene.clips.iter().skip(self.track_scroll()),
move|clip: &Option<Arc<RwLock<MidiClip>>>, index2|{
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(index2 as u16 * 14, Tui::bg(theme.dark.rgb, Bsp::e(
format!(" {index1:2} {index2:2} "),
Tui::fg(Rgb(255, 255, 255),
Tui::bold(true, format!("{}", text))))))
}))))))))
}
fn scenes_with_clip (&self, track_index: usize) -> impl Iterator<Item=SceneWith<'_, Option<ItemTheme>>> + Send + Sync {
self.scenes_iter().map(move|(s, scene, y1, y2)|(s, scene, y1, y2,
(s>0).then(||self.arrangement().scenes()[s-1].clips[track_index].as_ref()

View file

@ -79,8 +79,8 @@ impl<'a> HasTrackScroll for ArrangerView<'a> {
impl<T: HasTrackScroll + HasSelection> TracksView for T {}
pub trait TracksView: HasTracks + HasSelection {
fn view_track_names (&self, theme: ItemTheme) -> impl Content<TuiOut> + use<'_> {
pub trait TracksView: HasTrackScroll + HasSelection {
fn view_track_names (&self, theme: ItemTheme) -> impl Content<TuiOut> {
let mut max_outputs = 0u16;
for track in self.tracks().iter() {
max_outputs = max_outputs.max(track.sequencer.midi_outs.len() as u16);
@ -90,7 +90,7 @@ pub trait TracksView: HasTracks + HasSelection {
col!(Tui::bold(true, "[t]rack"), "[T] Add"))),
Align::w(Fixed::y(max_outputs + 1, Tui::bg(theme.darker.rgb,
Align::w(Fill::x(Map::new(
||self.tracks_with_sizes(&self.project.selection, None).skip(self.track_scroll()),
||self.tracks_with_sizes(&self.selection(), None).skip(self.track_scroll()),
move|(index, track, x1, x2): (usize, &Track, usize, usize), _|
Push::x(index as u16 * 14, Fixed::xy(track.width as u16, max_outputs + 1,
Tui::bg(track.color.dark.rgb, Align::nw(Bsp::s(Tui::fg(
@ -98,7 +98,7 @@ pub trait TracksView: HasTracks + HasSelection {
Tui::bold(true, format!("{}", track.name))
), format!("{index} {x1} {x2}")))))))))))))
}
fn view_track_outputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + use<'a> {
fn view_track_outputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
let mut max_outputs = 0u16;
for track in self.tracks().iter() {
max_outputs = max_outputs.max(track.sequencer.midi_outs.len() as u16);
@ -107,7 +107,7 @@ pub trait TracksView: HasTracks + HasSelection {
Fixed::x(20, Tui::bg(theme.darkest.rgb,
col!(Tui::bold(true, "[o]utput"), "[O] Add"))),
Align::w(Fixed::y(max_outputs + 1, Tui::bg(theme.darker.rgb, Align::w(Fill::x(Map::new(
||self.tracks_with_sizes(&self.project.selection, None).skip(self.track_scroll()),
||self.tracks_with_sizes(&self.selection(), None).skip(self.track_scroll()),
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|
Push::x(x2 as u16, Tui::bg(track.color.dark.rgb, Fixed::xy(
track.width as u16,
@ -118,7 +118,7 @@ pub trait TracksView: HasTracks + HasSelection {
|port, index|Tui::fg(Rgb(255, 255, 255),
format!("{index}: {}", port.name())))))))))))))))
}
fn view_track_inputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + use<'a> {
fn view_track_inputs <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
let mut max_inputs = 0u16;
for track in self.tracks().iter() {
max_inputs = max_inputs.max(track.sequencer.midi_ins.len() as u16);
@ -127,7 +127,7 @@ pub trait TracksView: HasTracks + HasSelection {
Fixed::x(20, Tui::bg(theme.darkest.rgb,
col!(Tui::bold(true, "[i]nputs"), "[I] Add"))),
Fill::x(Align::w(Fixed::y(max_inputs + 1, Tui::bg(theme.darker.rgb, Align::w(Fill::x(Map::new(
||self.tracks_with_sizes(&self.project.selection, None).skip(self.track_scroll()),
||self.tracks_with_sizes(&self.selection(), None).skip(self.track_scroll()),
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|
Push::x(x2 as u16, Fixed::xy(track.width as u16, max_inputs + 1,
Tui::bg(track.color.dark.rgb, Align::nw(Bsp::s(
@ -136,7 +136,7 @@ pub trait TracksView: HasTracks + HasSelection {
|port, index|Tui::fg(Rgb(255, 255, 255),
format!("{index}: {}", port.name()))))))))))))))))
}
fn view_track_devices <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> + use<'a> {
fn view_track_devices <'a> (&'a self, theme: ItemTheme) -> impl Content<TuiOut> {
let mut max_devices = 2u16;
for track in self.tracks().iter() {
max_devices = max_devices.max(track.devices.len() as u16);
@ -145,7 +145,7 @@ pub trait TracksView: HasTracks + HasSelection {
Fixed::x(20, Tui::bg(theme.darkest.rgb,
col!(Tui::bold(true, "[d]evice"), "[D] Add"))),
Fixed::y(max_devices, Tui::bg(theme.darker.rgb, Align::w(Fill::x(Map::new(
||self.tracks_with_sizes(&self.project.selection, None).skip(self.track_scroll()),
||self.tracks_with_sizes(&self.selection(), None).skip(self.track_scroll()),
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|
Push::x(x2 as u16, Fixed::xy(track.width as u16, max_devices + 1,
Tui::bg(track.color.dark.rgb, Align::nw(Map::south(1, move||0..max_devices,

View file

@ -21,7 +21,15 @@ impl<'a> Has<Vec<Scene>> for ArrangerView<'a> {
&self.arrangement.scenes
}
fn get_mut (&mut self) -> &mut Vec<Scene> {
&mut self.arrangement.scenes
unreachable!()
}
}
impl<'a> Has<Vec<Track>> for ArrangerView<'a> {
fn get (&self) -> &Vec<Track> {
&self.arrangement.tracks
}
fn get_mut (&mut self) -> &mut Vec<Track> {
unreachable!()
}
}