mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
fix autoscroll keys range
This commit is contained in:
parent
b799f6dbd0
commit
2198d14a40
4 changed files with 8 additions and 7 deletions
|
|
@ -6,12 +6,12 @@ pub trait MidiViewport<E: Engine>: MidiRange + MidiPoint + HasSize<E> {
|
|||
fn autoscroll (&self) {
|
||||
let note_lo = self.note_lo();
|
||||
let note_axis = self.note_axis();
|
||||
let note_hi = (note_lo + note_axis).min(127);
|
||||
let note_hi = self.note_hi().saturating_sub(1);
|
||||
let note_point = self.note_point().min(127);
|
||||
if note_point < note_lo {
|
||||
self.set_note_lo(note_point);
|
||||
} else if note_point > note_hi {
|
||||
self.set_note_lo(note_lo + note_point - note_hi);
|
||||
self.set_note_lo((note_lo + note_point).saturating_sub(note_hi));
|
||||
}
|
||||
}
|
||||
/// Make sure best usage of screen space is achieved by default
|
||||
|
|
@ -57,7 +57,7 @@ pub trait MidiRange {
|
|||
fn set_note_lo (&self, x: usize);
|
||||
fn note_axis (&self) -> usize;
|
||||
fn time_axis (&self) -> usize;
|
||||
fn note_hi (&self) -> usize { self.note_lo() + self.note_axis() }
|
||||
fn note_hi (&self) -> usize { self.note_lo() + self.note_axis().saturating_sub(1) }
|
||||
fn time_end (&self) -> usize { self.time_start() + self.time_axis() * self.time_zoom() }
|
||||
}
|
||||
impl MidiRange for MidiRangeModel {
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ render!(|self: SequencerTui|lay!([self.size, Tui::split_n(false, 5,
|
|||
PhraseEditStatus(&self.editor),
|
||||
SequencerStatusBar::from(self),
|
||||
])),
|
||||
Tui::split_e(false, if self.size.w() > 60 {
|
||||
Tui::split_w(false, if self.size.w() > 60 {
|
||||
20
|
||||
} else if self.size.w() > 40 {
|
||||
15
|
||||
|
|
|
|||
|
|
@ -143,8 +143,8 @@ impl MidiRange for PhraseEditorModel {
|
|||
fn note_lo (&self) -> usize { self.mode.note_lo() }
|
||||
fn note_axis (&self) -> usize { self.mode.note_axis() }
|
||||
fn time_axis (&self) -> usize { self.mode.time_axis() }
|
||||
fn note_hi (&self) -> usize { self.note_lo() + self.note_axis() }
|
||||
}
|
||||
|
||||
impl MidiPoint for PhraseEditorModel {
|
||||
fn note_len (&self) -> usize { self.mode.note_len()}
|
||||
fn set_note_len (&self, x: usize) { self.mode.set_note_len(x) }
|
||||
|
|
@ -153,6 +153,7 @@ impl MidiPoint for PhraseEditorModel {
|
|||
fn time_point (&self) -> usize { self.mode.time_point() }
|
||||
fn set_time_point (&self, x: usize) { self.mode.set_time_point(x) }
|
||||
}
|
||||
|
||||
impl PhraseViewMode for PhraseEditorModel {
|
||||
fn buffer_size (&self, phrase: &Phrase) -> (usize, usize) {
|
||||
self.mode.buffer_size(phrase)
|
||||
|
|
@ -221,7 +222,7 @@ impl From<Option<Arc<RwLock<Phrase>>>> for PhraseEditorModel {
|
|||
impl std::fmt::Debug for PhraseEditorModel {
|
||||
fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
|
||||
f.debug_struct("PhraseEditorModel")
|
||||
.field("point", &self)
|
||||
.field("mode", &self.mode)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ render!(|self: PianoHorizontalKeys|render(|to|Ok({
|
|||
let key_style = Some(Style::default().fg(Color::Rgb(192, 192, 192)).bg(Color::Rgb(0, 0, 0)));
|
||||
let off_style = Some(Style::default().fg(TuiTheme::g(160)));
|
||||
let on_style = Some(Style::default().fg(TuiTheme::g(255)).bg(self.color.base.rgb).bold());
|
||||
for (y, note) in (self.note_lo..=self.note_hi).rev().enumerate().map(|(y, n)|(y0 + y as u16, n)) {
|
||||
for (y, note) in (self.note_lo..self.note_hi).rev().enumerate().map(|(y, n)|(y0 + y as u16, n)) {
|
||||
let key = match note % 12 {
|
||||
11 => "████▌",
|
||||
10 => " ",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue