wip: refactor pt.10, 165 errors

This commit is contained in:
🪞👃🪞 2024-11-10 19:58:16 +01:00
parent 1405b82341
commit 355b34c738
9 changed files with 96 additions and 204 deletions

View file

@ -117,4 +117,37 @@ impl ArrangementScene {
//clips,
//})
//}
pub fn ppqs (scenes: &[Self], factor: usize) -> Vec<(usize, usize)> {
let mut total = 0;
if factor == 0 {
scenes.iter().map(|scene|{
let pulses = scene.pulses().max(PPQ);
total = total + pulses;
(pulses, total - pulses)
}).collect()
} else {
(0..=scenes.len()).map(|i|{
(factor*PPQ, factor*PPQ*i)
}).collect()
}
}
pub fn longest_name (scenes: &[Self]) -> usize {
scenes.iter().map(|s|s.name.read().unwrap().len()).fold(0, usize::max)
}
}
impl ArrangementTrack {
pub fn longest_name (tracks: &[Self]) -> usize {
tracks.iter().map(|s|s.name.read().unwrap().len()).fold(0, usize::max)
}
pub const MIN_WIDTH: usize = 3;
pub fn width_inc (&mut self) {
self.width += 1;
}
pub fn width_dec (&mut self) {
if self.width > Self::MIN_WIDTH {
self.width -= 1;
}
}
}