mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
arranger: ClipsView at last
This commit is contained in:
parent
b5326b578c
commit
4d0868add8
6 changed files with 55 additions and 33 deletions
|
|
@ -42,6 +42,12 @@ maybe_has!(Track: |self: App|
|
||||||
maybe_has!(Scene: |self: App|
|
maybe_has!(Scene: |self: App|
|
||||||
{ MaybeHas::<Scene>::get(&self.project) };
|
{ MaybeHas::<Scene>::get(&self.project) };
|
||||||
{ MaybeHas::<Scene>::get_mut(&mut self.project) });
|
{ MaybeHas::<Scene>::get_mut(&mut self.project) });
|
||||||
|
impl HasSceneScroll for App {
|
||||||
|
fn scene_scroll (&self) -> usize { self.project.scene_scroll() }
|
||||||
|
}
|
||||||
|
impl HasTrackScroll for App {
|
||||||
|
fn track_scroll (&self) -> usize { self.project.track_scroll() }
|
||||||
|
}
|
||||||
|
|
||||||
has_clips!(|self: App|self.project.pool.clips);
|
has_clips!(|self: App|self.project.pool.clips);
|
||||||
has_editor!(|self: App|{
|
has_editor!(|self: App|{
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ impl App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ArrangerSceneRows for App {
|
impl ScenesView for App {
|
||||||
fn arrangement (&self) -> &Arrangement {
|
fn arrangement (&self) -> &Arrangement {
|
||||||
&self.project
|
&self.project
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,3 +34,33 @@ impl ClipCommand {
|
||||||
impl Arrangement {
|
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))))))
|
||||||
|
})))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
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,
|
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()
|
(s>0).then(||self.arrangement().scenes()[s-1].clips[track_index].as_ref()
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,8 @@ impl<'a> HasTrackScroll for ArrangerView<'a> {
|
||||||
|
|
||||||
impl<T: HasTrackScroll + HasSelection> TracksView for T {}
|
impl<T: HasTrackScroll + HasSelection> TracksView for T {}
|
||||||
|
|
||||||
pub trait TracksView: HasTracks + HasSelection {
|
pub trait TracksView: HasTrackScroll + HasSelection {
|
||||||
fn view_track_names (&self, theme: ItemTheme) -> impl Content<TuiOut> + use<'_> {
|
fn view_track_names (&self, theme: ItemTheme) -> impl Content<TuiOut> {
|
||||||
let mut max_outputs = 0u16;
|
let mut max_outputs = 0u16;
|
||||||
for track in self.tracks().iter() {
|
for track in self.tracks().iter() {
|
||||||
max_outputs = max_outputs.max(track.sequencer.midi_outs.len() as u16);
|
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"))),
|
col!(Tui::bold(true, "[t]rack"), "[T] Add"))),
|
||||||
Align::w(Fixed::y(max_outputs + 1, Tui::bg(theme.darker.rgb,
|
Align::w(Fixed::y(max_outputs + 1, Tui::bg(theme.darker.rgb,
|
||||||
Align::w(Fill::x(Map::new(
|
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), _|
|
move|(index, track, x1, x2): (usize, &Track, usize, usize), _|
|
||||||
Push::x(index as u16 * 14, Fixed::xy(track.width as u16, max_outputs + 1,
|
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(
|
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))
|
Tui::bold(true, format!("{}", track.name))
|
||||||
), format!("{index} {x1} {x2}")))))))))))))
|
), 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;
|
let mut max_outputs = 0u16;
|
||||||
for track in self.tracks().iter() {
|
for track in self.tracks().iter() {
|
||||||
max_outputs = max_outputs.max(track.sequencer.midi_outs.len() as u16);
|
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,
|
Fixed::x(20, Tui::bg(theme.darkest.rgb,
|
||||||
col!(Tui::bold(true, "[o]utput"), "[O] Add"))),
|
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(
|
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), _|
|
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|
|
||||||
Push::x(x2 as u16, Tui::bg(track.color.dark.rgb, Fixed::xy(
|
Push::x(x2 as u16, Tui::bg(track.color.dark.rgb, Fixed::xy(
|
||||||
track.width as u16,
|
track.width as u16,
|
||||||
|
|
@ -118,7 +118,7 @@ pub trait TracksView: HasTracks + HasSelection {
|
||||||
|port, index|Tui::fg(Rgb(255, 255, 255),
|
|port, index|Tui::fg(Rgb(255, 255, 255),
|
||||||
format!("{index}: {}", port.name())))))))))))))))
|
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;
|
let mut max_inputs = 0u16;
|
||||||
for track in self.tracks().iter() {
|
for track in self.tracks().iter() {
|
||||||
max_inputs = max_inputs.max(track.sequencer.midi_ins.len() as u16);
|
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,
|
Fixed::x(20, Tui::bg(theme.darkest.rgb,
|
||||||
col!(Tui::bold(true, "[i]nputs"), "[I] Add"))),
|
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(
|
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), _|
|
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|
|
||||||
Push::x(x2 as u16, Fixed::xy(track.width as u16, max_inputs + 1,
|
Push::x(x2 as u16, Fixed::xy(track.width as u16, max_inputs + 1,
|
||||||
Tui::bg(track.color.dark.rgb, Align::nw(Bsp::s(
|
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),
|
|port, index|Tui::fg(Rgb(255, 255, 255),
|
||||||
format!("{index}: {}", port.name()))))))))))))))))
|
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;
|
let mut max_devices = 2u16;
|
||||||
for track in self.tracks().iter() {
|
for track in self.tracks().iter() {
|
||||||
max_devices = max_devices.max(track.devices.len() as u16);
|
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,
|
Fixed::x(20, Tui::bg(theme.darkest.rgb,
|
||||||
col!(Tui::bold(true, "[d]evice"), "[D] Add"))),
|
col!(Tui::bold(true, "[d]evice"), "[D] Add"))),
|
||||||
Fixed::y(max_devices, Tui::bg(theme.darker.rgb, Align::w(Fill::x(Map::new(
|
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), _|
|
move|(index, track, x1, x2): (usize, &'a Track, usize, usize), _|
|
||||||
Push::x(x2 as u16, Fixed::xy(track.width as u16, max_devices + 1,
|
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,
|
Tui::bg(track.color.dark.rgb, Align::nw(Map::south(1, move||0..max_devices,
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,15 @@ impl<'a> Has<Vec<Scene>> for ArrangerView<'a> {
|
||||||
&self.arrangement.scenes
|
&self.arrangement.scenes
|
||||||
}
|
}
|
||||||
fn get_mut (&mut self) -> &mut Vec<Scene> {
|
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!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue