display clamps; pass amount to axis inc/dec

This commit is contained in:
🪞👃🪞 2024-10-23 01:14:09 +03:00
parent 694aed6d9b
commit 27b1c27891
3 changed files with 24 additions and 26 deletions

View file

@ -89,27 +89,23 @@ impl Handle<Tui> for PhraseEditor<Tui> {
key!(KeyCode::Char('`')) => { self.mode = !self.mode; },
key!(KeyCode::Enter) => { self.entered = true; },
key!(KeyCode::Esc) => { self.entered = false; },
key!(KeyCode::PageUp) => {
self.note_axis.start = self.note_axis.start.saturating_sub(3);
}
key!(KeyCode::PageDown) => {
self.note_axis.start = self.note_axis.start + 3;
}
key!(KeyCode::PageUp) => { self.note_axis.start_dec(3); },
key!(KeyCode::PageDown) => { self.note_axis.start_inc(3); },
key!(KeyCode::Up) => match self.entered {
true => { self.note_axis.point_dec(); },
false => { self.note_axis.start_dec(); },
true => { self.note_axis.point_dec(1); },
false => { self.note_axis.start_dec(1); },
},
key!(KeyCode::Down) => match self.entered {
true => { self.note_axis.point_inc(); },
false => { self.note_axis.start_inc(); },
true => { self.note_axis.point_inc(1); },
false => { self.note_axis.start_inc(1); },
},
key!(KeyCode::Left) => match self.entered {
true => { self.time_axis.point_dec(); },
false => { self.time_axis.start_dec(); },
true => { self.time_axis.point_dec(self.time_axis.scale); },
false => { self.time_axis.start_dec(self.time_axis.scale); },
},
key!(KeyCode::Right) => match self.entered {
true => { self.time_axis.point_inc(); },
false => { self.time_axis.start_inc(); },
true => { self.time_axis.point_inc(self.time_axis.scale); },
false => { self.time_axis.start_inc(self.time_axis.scale); },
},
key!(KeyCode::Char('>')) => {
self.time_axis.scale = prev_note_length(self.time_axis.scale)

View file

@ -88,7 +88,7 @@ impl Content for PhraseEditor<Tui> {
if *entered {
let area = to.area();
if let (Some(time), Some(note)) = (time_axis.point, note_axis.point) {
let x = area.x() + time as u16;
let x = area.x() + (time / time_axis.scale) as u16;
let y = area.y() + 1 + note as u16 / 2;
let c = if note % 2 == 0 { "" } else { "" };
to.blit(&c, x, y, Some(Style::default().fg(color)));
@ -130,17 +130,19 @@ impl Content for PhraseEditor<Tui> {
if let Some(phrase) = phrase {
upper_left = format!("{upper_left}: {}", phrase.read().unwrap().name);
}
let mut upper_right = format!("Zoom: {} (+{}:{}*{})",
let mut upper_right = format!("Zoom: {} (+{}:{}*{}|{})",
ppq_to_name(time_axis.scale),
time_axis.start,
time_axis.point.unwrap_or(0),
time_axis.scale,
time_axis.clamp.unwrap_or(0),
);
if *focused && *entered {
upper_right = format!("Note: {} (+{}:{}) {upper_right}",
upper_right = format!("Note: {} (+{}:{}|{}) {upper_right}",
ppq_to_name(*note_len),
note_axis.start,
note_axis.point.unwrap_or(0)
note_axis.point.unwrap_or(0),
note_axis.clamp.unwrap_or(0),
);
}
lay!(