add PgUp/PgDown in sequencer

This commit is contained in:
🪞👃🪞 2024-10-18 22:42:30 +03:00
parent 359afb2e8c
commit eccb355815
3 changed files with 17 additions and 10 deletions

View file

@ -2,19 +2,19 @@ use crate::*;
macro_rules! impl_axis_common { ($A:ident $T:ty) => {
impl $A<$T> {
pub fn start_inc (&mut self) -> $T {
#[inline] pub fn start_inc (&mut self) -> $T {
self.start += 1;
self.start
}
pub fn start_dec (&mut self) -> $T {
#[inline] pub fn start_dec (&mut self) -> $T {
self.start = self.start.saturating_sub(1);
self.start
}
pub fn point_inc (&mut self) -> Option<$T> {
#[inline] pub fn point_inc (&mut self) -> Option<$T> {
self.point = self.point.map(|p|p + 1);
self.point
}
pub fn point_dec (&mut self) -> Option<$T> {
#[inline] pub fn point_dec (&mut self) -> Option<$T> {
self.point = self.point.map(|p|p.saturating_sub(1));
self.point
}

View file

@ -89,7 +89,12 @@ 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::Up) => match self.entered {
true => { self.note_axis.point_dec(); },
false => { self.note_axis.start_dec(); },
@ -108,15 +113,17 @@ impl Handle<Tui> for PhraseEditor<Tui> {
},
key!(KeyCode::Char(',')) => match self.entered {
true => { self.note_len = prev_note_length(self.note_len) },
false => { self.time_axis.scale = prev_note_length(self.time_axis.scale) },
false => { self.time_axis.scale = next_note_length(self.time_axis.scale) },
},
key!(KeyCode::Char('.')) => match self.entered {
true => { self.note_len = next_note_length(self.note_len) },
false => { self.time_axis.scale = next_note_length(self.time_axis.scale) },
false => { self.time_axis.scale = prev_note_length(self.time_axis.scale) },
},
key!(KeyCode::Char('a')) => if self.entered {
self.put();
self.time_axis.point = self.time_axis.point.map(|time|time + self.note_len);
self.time_axis.point = self.time_axis.point.map(|time|{
time + self.note_len / self.time_axis.scale
});
},
key!(KeyCode::Char('s')) => if self.entered {
self.put();

View file

@ -139,7 +139,7 @@ impl Content for PhraseEditor<Tui> {
if *focused {
if *entered {
lower_left = "[Esc] Exit edit mode [A]ppend [S]et".to_string();
lower_right = format!("[,.] Length: {} {lower_right}", ppq_to_name(*note_len));
lower_right = format!("[,.] Note: {} {lower_right}", ppq_to_name(*note_len));
} else {
lower_left = "[Enter] Edit notes".to_string();
lower_right = format!("[,.] {lower_right}");
@ -206,7 +206,7 @@ impl PhraseEditor<Tui> {
} else {
'·'
});
cell.set_fg(Color::Gray);
cell.set_fg(Color::Rgb(48, 64, 56));
cell.modifier = Modifier::DIM;
});
}