fbpr: align cursor/keys/notes

This commit is contained in:
🪞👃🪞 2024-12-06 01:32:36 +01:00
parent 2561e5221d
commit b70d7a08a6
2 changed files with 18 additions and 24 deletions

View file

@ -56,7 +56,7 @@ impl Default for PhraseEditorModel {
size: Measure::new(),
edit_mode: PhraseEditMode::Scroll,
note_lo: 0.into(),
note_point: 24.into(),
note_point: 0.into(),
time_start: 0.into(),
time_point: 0.into(),
time_scale: 24.into(),

View file

@ -22,16 +22,16 @@ impl<'a, T: HasEditor> From<&'a T> for PhraseView<'a> {
let height = editor.size.h();
let note_point = editor.note_point.load(Ordering::Relaxed);
let mut note_lo = editor.note_lo.load(Ordering::Relaxed);
if note_point < note_lo {
note_lo = note_point;
editor.note_lo.store(note_lo, Ordering::Relaxed);
}
let mut note_hi = 127.min(note_lo + height);
if note_point > note_hi {
note_lo += note_point - note_hi;
note_hi = note_point;
editor.note_lo.store(note_lo, Ordering::Relaxed);
}
//if note_point < note_lo {
//note_lo = note_point;
//editor.note_lo.store(note_lo, Ordering::Relaxed);
//}
let mut note_hi = 127.min((note_lo + height).saturating_sub(2));
//if note_point > note_hi {
//note_lo += note_point - note_hi;
//note_hi = note_point;
//editor.note_lo.store(note_lo, Ordering::Relaxed);
//}
Self {
focused: state.editor_focused(),
entered: state.editor_entered(),
@ -105,20 +105,14 @@ impl<'a> Content for PhraseView<'a> {
lay!(
row!(
Widget::new(|to:[u16;2]|Ok(Some(to.clip_w(2))), move|to: &mut TuiOutput|{
Ok(if to.area().h() >= 2 {
view_mode.render_keys(to, *note_hi, *note_lo)
})
}).fill_y(),
Ok(if to.area().h() >= 2 { view_mode.render_keys(to, *note_hi, *note_lo) })
}).fill_y().push_y(1),
lay!(
Widget::new(|to|Ok(Some(to)), |to: &mut TuiOutput|{
size.set_wh(to.area.w(), to.area.h() as usize - 1);
let draw = to.area().h() >= 2;
Ok(if draw {
view_mode.render_notes(
to, buffer, *time_start, *note_hi
)
})
}).fill_x(),
Ok(if draw { view_mode.render_notes(to, buffer, *time_start, *note_hi) })
}).fill_x().push_y(1),
Widget::new(|to|Ok(Some(to)), move|to: &mut TuiOutput|{
Ok(if *focused && *entered {
view_mode.render_cursor(
@ -127,7 +121,7 @@ impl<'a> Content for PhraseView<'a> {
*note_point, *note_len, *note_hi, *note_lo,
)
})
})
}).push_y(1)
).fill_x()
)
.fill_x()
@ -247,7 +241,7 @@ impl PhraseViewMode {
match self {
Self::PianoHorizontal { .. } => {
let [x0, y0, _, h] = to.area().xywh();
for (y, note) in (note_lo..note_hi).rev().enumerate() {
for (y, note) in (note_lo..=note_hi).rev().enumerate() {
to.blit(&match note % 12 {
11 => "██",
10 => " ",
@ -283,7 +277,7 @@ impl PhraseViewMode {
match self {
Self::PianoHorizontal { .. } => {
let [x0, y0, w, _] = to.area().xywh();
for (y, note) in (note_lo..note_hi).rev().enumerate() {
for (y, note) in (note_lo..=note_hi).rev().enumerate() {
if note == note_point {
for x in 0..w {
let time_1 = time_start + x as usize * time_zoom;