mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
wip: fix keys rendering (notes still offset though)
This commit is contained in:
parent
2fc8e84551
commit
7ef97bcf3a
7 changed files with 60 additions and 19 deletions
|
|
@ -66,23 +66,48 @@ fn keys_vert () -> Buffer {
|
|||
let area = Rect { x: 0, y: 0, width: 5, height: 64 };
|
||||
let mut buffer = Buffer::empty(area);
|
||||
buffer_update(&mut buffer, area, &|cell, x, y| {
|
||||
cell.set_char('▀');
|
||||
let y = 63 - y;
|
||||
match x {
|
||||
0 => {
|
||||
let (fg, bg) = key_colors(y);
|
||||
cell.set_char('▀');
|
||||
let (fg, bg) = key_colors(6 - y % 6);
|
||||
cell.set_fg(fg);
|
||||
cell.set_bg(bg);
|
||||
},
|
||||
1 => {
|
||||
cell.set_char('▀');
|
||||
cell.set_fg(Color::White);
|
||||
cell.set_bg(Color::White);
|
||||
}
|
||||
},
|
||||
2 => if y % 6 == 0 {
|
||||
cell.set_char('C');
|
||||
},
|
||||
3 => if y % 6 == 0 {
|
||||
cell.set_symbol(nth_octave(y / 6));
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
buffer
|
||||
}
|
||||
|
||||
fn nth_octave (index: u16) -> &'static str {
|
||||
match index {
|
||||
0 => "-1",
|
||||
1 => "0",
|
||||
2 => "1",
|
||||
3 => "2",
|
||||
4 => "3",
|
||||
5 => "4",
|
||||
6 => "5",
|
||||
7 => "6",
|
||||
8 => "7",
|
||||
9 => "8",
|
||||
10 => "9",
|
||||
_ => unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
fn key_colors (index: u16) -> (Color, Color) {
|
||||
match index % 6 {
|
||||
0 => (Color::White, Color::Black),
|
||||
|
|
@ -104,16 +129,28 @@ fn fill_seq_bg (buf: &mut Buffer, length: usize, ppq: usize) -> Usually<()> {
|
|||
let cell = buf.get_mut(x, buf.area.y);
|
||||
cell.set_char('-');
|
||||
cell.set_style(style);
|
||||
let character = if ppq > 0 && x as usize % ppq == 0 { '|' } else { '·' };
|
||||
for y in 0 .. buf.area.height - buf.area.y {
|
||||
let cell = buf.get_mut(x, y);
|
||||
cell.set_char(character);
|
||||
cell.set_char(char_seq_bg(ppq, x));
|
||||
cell.set_fg(Color::Gray);
|
||||
cell.modifier = Modifier::DIM;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn char_seq_bg (ppq: usize, x: u16) -> char {
|
||||
if ppq == 0 {
|
||||
'·'
|
||||
} else if x % (4 * ppq as u16) == 0 {
|
||||
'│'
|
||||
} else if x % ppq as u16 == 0 {
|
||||
'╎'
|
||||
} else {
|
||||
'·'
|
||||
}
|
||||
}
|
||||
|
||||
fn fill_seq_fg (buf: &mut Buffer, phrase: &Phrase) -> Usually<()> {
|
||||
let mut notes_on = [false;128];
|
||||
for x in 0 .. buf.area.width - buf.area.x {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue