wip: clip launcher

This commit is contained in:
🪞👃🪞 2024-06-24 23:30:09 +03:00
parent 2f52e97c58
commit 90998b1c6e
3 changed files with 78 additions and 52 deletions

View file

@ -35,6 +35,24 @@ pub fn timer (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, beat: usize) {
}
}
pub fn keys (s: &Sequencer, buf: &mut Buffer, mut area: Rect) -> Usually<Rect> {
let bw = Style::default().dim();
let Rect { x, y, .. } = area;
let (note0, note1) = s.note_axis;
let (time0, time1) = s.time_axis;
for i in 0..32.max(note1-note0)/2 {
let y = y + i;
buf.set_string(x + 1, y, KEYS_VERTICAL[(i % 6) as usize], bw);
buf.set_string(x + 2, y, "", bw);
buf.set_string(x + 5, y, &"·".repeat((time1 - time0) as usize), bw.black());
if i % 6 == 0 {
let octave = format!("C{}", ((note1 - i) / 6) as i8 - 4);
buf.set_string(x + 3, y, &octave, Style::default());
}
}
Ok(area)
}
pub fn lanes (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, width: u16) {
let bw = Style::default().dim();
let bg = Style::default();
@ -55,6 +73,15 @@ pub fn lanes (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16, width: u16) {
}
}
pub fn cursor (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16) {
buf.set_string(
x + 6 + s.time_cursor,
y + s.note_cursor / 2,
if s.note_cursor % 2 == 0 { "" } else { "" },
Style::default().green().not_dim()
);
}
pub fn footer (s: &Sequencer, buf: &mut Buffer, mut x: u16, y: u16, width: u16, height: u16) {
let bw = Style::default().dim();
let bg = Style::default();
@ -88,30 +115,3 @@ pub fn footer (s: &Sequencer, buf: &mut Buffer, mut x: u16, y: u16, width: u16,
}
}
}
pub fn cursor (s: &Sequencer, buf: &mut Buffer, x: u16, y: u16) {
buf.set_string(
x + 6 + s.time_cursor,
y + s.note_cursor / 2,
if s.note_cursor % 2 == 0 { "" } else { "" },
Style::default()
);
}
pub fn keys (s: &Sequencer, buf: &mut Buffer, mut area: Rect) -> Usually<Rect> {
let bw = Style::default().dim();
let Rect { x, y, .. } = area;
let (note0, note1) = s.note_axis;
let (time0, time1) = s.time_axis;
for i in 0..32.max(note1-note0)/2 {
let y = y + i;
buf.set_string(x + 1, y, KEYS_VERTICAL[(i % 6) as usize], bw);
buf.set_string(x + 2, y, "", bw);
buf.set_string(x + 5, y, &"·".repeat((time1 - time0) as usize), bw.black());
if i % 6 == 0 {
let octave = format!("C{}", ((note1 - i) / 6) as i8 - 4);
buf.set_string(x + 3, y, &octave, Style::default());
}
}
Ok(area)
}