From 3d5ba6735411174460a36ad9e9a4e02bdd3e64d4 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Mon, 2 Dec 2024 18:14:56 +0100 Subject: [PATCH] editor: renders correctly when maximized? --- crates/tek_tui/src/tui_view_phrase_editor.rs | 36 +++++++++----------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/crates/tek_tui/src/tui_view_phrase_editor.rs b/crates/tek_tui/src/tui_view_phrase_editor.rs index 0565b283..e4544f31 100644 --- a/crates/tek_tui/src/tui_view_phrase_editor.rs +++ b/crates/tek_tui/src/tui_view_phrase_editor.rs @@ -24,7 +24,7 @@ impl<'a, T: HasEditor> From<&'a T> for PhraseView<'a> { fn from (state: &'a T) -> Self { let editor = state.editor(); - let [width, height] = editor.size.wh(); + let height = editor.size.h(); let note_point = editor.note_point.load(Ordering::Relaxed); @@ -114,14 +114,6 @@ impl<'a> Content for PhraseView<'a> { } } - //to.buffer_update(to.area().set_w(5), &|cell, x, y|{ - ////let y = y + (note_hi / 2) as u16; - //if x < keys.area.width && y < keys.area.height { - //[>cell = keys.get(x, y).clone() - ////cell.set_symbol(&format!("{y}")); - ////} - //} - //}); }); let notes_bg_null = Color::Rgb(28, 35, 25); let notes = move|to: &mut TuiOutput|{ @@ -135,7 +127,7 @@ impl<'a> Content for PhraseView<'a> { let src_x = (x as usize + time_start) * time_scale; let src_y = y as usize + note_lo / 2; if src_x < buffer.width && src_y < buffer.height - 1 { - buffer.get(src_x, buffer.height - src_y - 2).map(|src|{ + buffer.get(src_x, 63 - (buffer.height - src_y - 2)).map(|src|{ cell.set_symbol(src.symbol()); cell.set_fg(src.fg); cell.set_bg(src.bg); @@ -196,8 +188,8 @@ impl<'a> Content for PhraseView<'a> { if let Some(phrase) = phrase { name = phrase.read().unwrap().name.clone(); } - let mut upper_left = format!("{note_hi} {note_hi_name} {name}"); - let mut lower_left = format!("{note_lo} {note_lo_name}"); + let upper_left = format!("{note_hi} {note_hi_name} {name}"); + let lower_left = format!("{note_lo} {note_lo_name}"); let mut lower_right = format!("┤{}├", size.format()); if *focused && *entered { lower_right = format!("┤Note: {} ({}) {}├─{lower_right}", @@ -224,10 +216,10 @@ impl<'a> Content for PhraseView<'a> { } } -const NTH_OCTAVE: [&'static str; 11] = [ - "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "X", - //"-2", "-1", "0", "1", "2", "3", "4", "5", "6", "7", "8", -]; +//const NTH_OCTAVE: [&'static str; 11] = [ + //"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "X", + ////"-2", "-1", "0", "1", "2", "3", "4", "5", "6", "7", "8", +//]; impl PhraseEditorModel { pub(crate) fn redraw (phrase: &Phrase) -> BigBuffer { @@ -241,7 +233,10 @@ impl PhraseEditorModel { // Only fill as far as phrase length if x as usize >= length { break } // Fill each row with background characters - for y in 0 .. buf.height { + for y in 0..buf.height { + if y >= 64 { + break + } buf.get_mut(x, y).map(|cell|{ cell.set_char(if ppq == 0 { '·' @@ -288,11 +283,12 @@ impl PhraseEditorModel { if y >= 64 { break } + let y = 63 - y; if let Some(block) = half_block( - notes_on[127 - (y as usize * 2)], - notes_on[127 - (y as usize * 2 + 1)], + notes_on[y as usize * 2 + 1], + notes_on[y as usize * 2], ) { - buf.get_mut(x, 64 - y).map(|cell|{ + buf.get_mut(x, y).map(|cell|{ cell.set_char(block); cell.set_fg(Color::White); });