align note vertical positions in sequencer

This commit is contained in:
🪞👃🪞 2024-10-29 09:41:31 +02:00
parent 6d7577553a
commit 4ecd6eab3d

View file

@ -62,7 +62,7 @@ impl Content for PhraseEditor<Tui> {
let keys = CustomWidget::new(|to:[u16;2]|Ok(Some(to.clip_w(5))), move|to: &mut TuiOutput|{ let keys = CustomWidget::new(|to:[u16;2]|Ok(Some(to.clip_w(5))), move|to: &mut TuiOutput|{
if to.area().h() >= 2 { if to.area().h() >= 2 {
to.buffer_update(to.area().set_w(5), &|cell, x, y|{ to.buffer_update(to.area().set_w(5), &|cell, x, y|{
let y = y + note_start as u16; let y = y + (note_start / 2) as u16;
if x < keys.area.width && y < keys.area.height { if x < keys.area.width && y < keys.area.height {
*cell = keys.get(x, y).clone() *cell = keys.get(x, y).clone()
} }
@ -72,10 +72,10 @@ impl Content for PhraseEditor<Tui> {
}).fill_y(); }).fill_y();
let notes_bg_null = Color::Rgb(28, 35, 25); let notes_bg_null = Color::Rgb(28, 35, 25);
let notes = CustomWidget::new(|to|Ok(Some(to)), move|to: &mut TuiOutput|{ let notes = CustomWidget::new(|to|Ok(Some(to)), move|to: &mut TuiOutput|{
let w = to.area.w() as usize; let area = to.area();
let h = to.area.h() as usize; let h = area.h() as usize;
self.width.store(w, Ordering::Relaxed);
self.height.store(h, Ordering::Relaxed); self.height.store(h, Ordering::Relaxed);
self.width.store(area.w() as usize, Ordering::Relaxed);
let mut axis = self.note_axis.write().unwrap(); let mut axis = self.note_axis.write().unwrap();
if let Some(point) = axis.point { if let Some(point) = axis.point {
if point.saturating_sub(axis.start) > (h * 2).saturating_sub(1) { if point.saturating_sub(axis.start) > (h * 2).saturating_sub(1) {
@ -87,9 +87,9 @@ impl Content for PhraseEditor<Tui> {
to.buffer_update(area, &move |cell, x, y|{ to.buffer_update(area, &move |cell, x, y|{
cell.set_bg(notes_bg_null); cell.set_bg(notes_bg_null);
let src_x = (x as usize + time_start) * time_scale; let src_x = (x as usize + time_start) * time_scale;
let src_y = y as usize + note_start; let src_y = y as usize + note_start / 2;
if src_x < buffer.width && src_y < buffer.height - 1 { if src_x < buffer.width && src_y < buffer.height - 1 {
buffer.get(src_x, buffer.height - src_y - 1).map(|src|{ buffer.get(src_x, buffer.height - src_y - 2).map(|src|{
cell.set_symbol(src.symbol()); cell.set_symbol(src.symbol());
cell.set_fg(src.fg); cell.set_fg(src.fg);
cell.set_bg(src.bg); cell.set_bg(src.bg);