editor: add fine time step and overflow

This commit is contained in:
🪞👃🪞 2025-05-11 19:19:14 +03:00
parent d647fc68e9
commit d1be569b48
3 changed files with 18 additions and 3 deletions

View file

@ -5,6 +5,10 @@ use crate::*;
todo!()
}
fn clip_length (&self) -> usize {
self.clip().as_ref().map(|p|p.read().unwrap().length).unwrap_or(1)
}
fn note_length (&self) -> usize {
self.get_note_len()
}
@ -49,10 +53,19 @@ use crate::*;
self.get_time_pos()
}
fn time_pos_next (&self) -> usize {
self.get_time_pos() + self.get_note_len()
(self.get_time_pos() + self.get_note_len()) % self.clip_length()
}
fn time_pos_next_fine (&self) -> usize {
(self.get_time_pos() + 1) % self.clip_length()
}
fn time_pos_prev (&self) -> usize {
self.get_time_pos().saturating_sub(self.get_note_len())
let step = self.get_note_len();
self.get_time_pos().overflowing_sub(step)
.0.min(self.clip_length().saturating_sub(step))
}
fn time_pos_prev_fine (&self) -> usize {
self.get_time_pos().overflowing_sub(1)
.0.min(self.clip_length().saturating_sub(1))
}
fn time_zoom (&self) -> usize {

View file

@ -61,7 +61,7 @@ impl MidiEditor {
clip.notes[note_end].push(note_off);
}
if advance {
self.set_time_pos(note_end + 1);
self.set_time_pos((note_end + 1) % clip.length);
}
redraw = true;
}