arranger: spawning clips once again!1

This commit is contained in:
🪞👃🪞 2025-05-17 12:22:43 +03:00
parent b663c53b0a
commit 48603e4812
6 changed files with 41 additions and 18 deletions

View file

@ -168,11 +168,11 @@ impl Arrangement {
mins: &[PortConnect],
mouts: &[PortConnect],
) -> Usually<(usize, &mut Track)> {
self.track_last += 1;
let name: Arc<str> = name.map_or_else(
||format!("Track{:02}", self.track_last).into(),
||format!("t{:02}", self.track_last).into(),
|x|x.to_string().into()
);
self.track_last += 1;
let mut track = Track {
width: (name.len() + 2).max(12),
color: color.unwrap_or_else(ItemTheme::random),

View file

@ -28,7 +28,7 @@ pub trait HasScenes: Has<Vec<Scene>> + Send + Sync {
}
/// Generate the default name for a new scene
fn scene_default_name (&self) -> Arc<str> {
format!("Sc{:3>}", self.scenes().len() + 1).into()
format!("s{:3>}", self.scenes().len() + 1).into()
}
fn scene_longest_name (&self) -> usize {
self.scenes().iter().map(|s|s.name.len()).fold(0, usize::max)

View file

@ -207,8 +207,12 @@ pub trait TracksView: HasSize<TuiOut> + HasTrackScroll + HasSelection + HasMidiI
.tracks_with_sizes(&self.selection(), None)
.skip(self.track_scroll())
{
(add)(&Fixed::x(track.width as u16,
Tui::bg(track.color.base.rgb, Align::nw(Tui::fg(
add(&Fixed::x(track.width as u16,
Tui::bg(if self.selection().track() == Some(index) {
track.color.light.rgb
} else {
track.color.base.rgb
}, Align::nw(Tui::fg(
Rgb(255, 255, 255), Tui::bold(true,
format!("{}", track.name)))))));
}
@ -424,18 +428,23 @@ pub trait ClipsView: TracksView + ScenesView + Send + Sync {
(None, ItemTheme::G[32])
};
let fg = theme.lightest.rgb;
let mut outline = theme.base.rgb;
let bg = if self.selection().track() == Some(track_index)
&& self.selection().scene() == Some(scene_index)
{
outline = theme.lightest.rgb;
theme.light.rgb
} else if self.selection().track() == Some(track_index)
|| self.selection().scene() == Some(scene_index)
{
outline = theme.darkest.rgb;
theme.base.rgb
} else {
theme.dark.rgb
};
cell(&Fixed::xy(track.width as u16, 2, Tui::fg_bg(fg, bg, Align::nw(name.unwrap_or(" ---- ".into())))));
cell(&Fixed::xy(track.width as u16, 2, Bsp::b(
Fill::xy(Outer(true, Style::default().fg(outline))),
Fill::xy(Align::nw(Tui::fg_bg(fg, bg, Align::nw(name.unwrap_or(" ---- ".into()))))))));
//let (name, theme) = if let Some(clip) = &scene.clips.get(track_index).flatten() {
//let clip = clip.read().unwrap();
//(Some(clip.name.clone()), clip.color)