editor: renders correctly when maximized?

This commit is contained in:
🪞👃🪞 2024-12-02 18:14:56 +01:00
parent 82a326d6f8
commit 3d5ba67354

View file

@ -24,7 +24,7 @@ impl<'a, T: HasEditor> From<&'a T> for PhraseView<'a> {
fn from (state: &'a T) -> Self { fn from (state: &'a T) -> Self {
let editor = state.editor(); let editor = state.editor();
let [width, height] = editor.size.wh(); let height = editor.size.h();
let note_point = editor.note_point.load(Ordering::Relaxed); 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_bg_null = Color::Rgb(28, 35, 25);
let notes = move|to: &mut TuiOutput|{ 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_x = (x as usize + time_start) * time_scale;
let src_y = y as usize + note_lo / 2; let src_y = y as usize + note_lo / 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 - 2).map(|src|{ buffer.get(src_x, 63 - (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);
@ -196,8 +188,8 @@ impl<'a> Content for PhraseView<'a> {
if let Some(phrase) = phrase { if let Some(phrase) = phrase {
name = phrase.read().unwrap().name.clone(); name = phrase.read().unwrap().name.clone();
} }
let mut upper_left = format!("{note_hi} {note_hi_name} {name}"); let upper_left = format!("{note_hi} {note_hi_name} {name}");
let mut lower_left = format!("{note_lo} {note_lo_name}"); let lower_left = format!("{note_lo} {note_lo_name}");
let mut lower_right = format!("{}", size.format()); let mut lower_right = format!("{}", size.format());
if *focused && *entered { if *focused && *entered {
lower_right = format!("┤Note: {} ({}) {}├─{lower_right}", lower_right = format!("┤Note: {} ({}) {}├─{lower_right}",
@ -224,10 +216,10 @@ impl<'a> Content for PhraseView<'a> {
} }
} }
const NTH_OCTAVE: [&'static str; 11] = [ //const NTH_OCTAVE: [&'static str; 11] = [
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "X", //"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "X",
//"-2", "-1", "0", "1", "2", "3", "4", "5", "6", "7", "8", ////"-2", "-1", "0", "1", "2", "3", "4", "5", "6", "7", "8",
]; //];
impl PhraseEditorModel { impl PhraseEditorModel {
pub(crate) fn redraw (phrase: &Phrase) -> BigBuffer { pub(crate) fn redraw (phrase: &Phrase) -> BigBuffer {
@ -241,7 +233,10 @@ impl PhraseEditorModel {
// Only fill as far as phrase length // Only fill as far as phrase length
if x as usize >= length { break } if x as usize >= length { break }
// Fill each row with background characters // 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|{ buf.get_mut(x, y).map(|cell|{
cell.set_char(if ppq == 0 { cell.set_char(if ppq == 0 {
'·' '·'
@ -288,11 +283,12 @@ impl PhraseEditorModel {
if y >= 64 { if y >= 64 {
break break
} }
let y = 63 - y;
if let Some(block) = half_block( if let Some(block) = half_block(
notes_on[127 - (y as usize * 2)], notes_on[y as usize * 2 + 1],
notes_on[127 - (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_char(block);
cell.set_fg(Color::White); cell.set_fg(Color::White);
}); });