scroll sequencer

This commit is contained in:
🪞👃🪞 2024-07-03 21:39:46 +03:00
parent 47b2c5da29
commit 7f3425fe04
3 changed files with 18 additions and 7 deletions

View file

@ -85,7 +85,11 @@ const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
}
},
2 => {
app.time_cursor = app.time_cursor.saturating_sub(1);
if app.entered {
app.time_cursor = app.time_cursor.saturating_sub(1);
} else {
app.time_start = app.time_start.saturating_sub(1);
}
Ok(true)
},
_ => Ok(false)
@ -106,7 +110,11 @@ const KEYMAP: &'static [KeyBinding<App>] = keymap!(App {
}
},
2 => {
app.time_cursor = app.time_cursor + 1;
if app.entered {
app.time_cursor = app.time_cursor + 1;
} else {
app.time_start = app.time_start + 1;
}
Ok(true)
},
_ => Ok(false)

View file

@ -46,6 +46,9 @@ impl Track {
pub fn device (&self) -> Option<&Box<dyn Device>> {
self.devices.get(self.device)
}
pub fn device_mut (&mut self) -> Option<&mut Box<dyn Device>> {
self.devices.get_mut(self.device)
}
pub fn first_device (&self) -> Option<&Box<dyn Device>> {
self.devices.get(0)
}

View file

@ -131,7 +131,7 @@ mod horizontal {
phrase: &Phrase,
ppq: usize,
time_z: usize,
_time0: usize,
time0: usize,
note0: usize,
) {
let Rect { x, y, width, height } = area;
@ -142,7 +142,8 @@ mod horizontal {
let (bw, wh) = (bg.dim(), bg.white().not_dim());
let offset = 5;
for x in x+offset..x+width-offset {
let step = (x-offset) as usize * time_z;
let step = (time0 + (x-offset) as usize) * time_z;
let next_step = (time0 + (x-offset) as usize + 1) * time_z;
if step % ppq == 0 {
"|".blit(buf, x as u16, y, Some(Style::default().dim()));
}
@ -151,13 +152,12 @@ mod horizontal {
format!("{}", (step/bar)+1)
.blit(buf, x as u16, y, Some(Style::default().bold().not_dim()));
}
let (a, b) = (step, step + time_z);
for index in 0..height-2 {
let note_a = note0 + index as usize * 2;
let note_b = note0 + index as usize * 2 + 1;
let (character, mut style) = match (
phrase.contains_note_on(u7::from_int_lossy(note_a as u8), a, b),
phrase.contains_note_on(u7::from_int_lossy(note_b as u8), a, b),
phrase.contains_note_on(u7::from_int_lossy(note_a as u8), step, next_step),
phrase.contains_note_on(u7::from_int_lossy(note_b as u8), step, next_step),
) {
(true, true) => ("", wh),
(false, true) => ("", wh),