show phrase names again

This commit is contained in:
🪞👃🪞 2024-07-11 17:17:18 +03:00
parent 4a8f5b267f
commit 888ed642d0
3 changed files with 58 additions and 48 deletions

View file

@ -85,6 +85,9 @@ impl<'a> SequencerView<'a> {
}
impl<'a> SequencerView<'a> {
const H_KEYS_OFFSET: u16 = 5;
fn horizontal_draw (&self, buf: &mut Buffer, area: Rect) -> Usually<()> {
self.horizontal_keys(buf, area)?;
self.horizontal_quant(buf, area)?;
@ -103,7 +106,7 @@ impl<'a> SequencerView<'a> {
fn horizontal_cursor (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
let (time, note) = (self.time_cursor, self.note_cursor);
let x = area.x + 5 + time as u16;
let x = area.x + Self::H_KEYS_OFFSET + time as u16;
let y = area.y + 1 + note as u16 / 2;
let c = if note % 2 == 0 { "" } else { "" };
c.blit(buf, x, y, self.style_focus())
@ -113,10 +116,9 @@ impl<'a> SequencerView<'a> {
if let Some(phrase) = phrase {
let (time0, time_z, now) = (self.time_start, self.time_zoom, self.now % phrase.length);
let Rect { x, width, .. } = area;
let offset = 5;
for x in x+offset..x+width-offset {
let step = (time0 + (x-offset) as usize) * time_z;
let next_step = (time0 + (x-offset) as usize + 1) * time_z;
for x in x+Self::H_KEYS_OFFSET..x+width {
let step = (time0 + (x-Self::H_KEYS_OFFSET) as usize) * time_z;
let next_step = (time0 + (x-Self::H_KEYS_OFFSET) as usize + 1) * time_z;
let style = Self::style_timer_step(now, step, next_step);
"-".blit(buf, x, area.y, Some(style))?;
}
@ -152,11 +154,11 @@ impl<'a> SequencerView<'a> {
key2.set_style(not_dim);
key2.set_fg(self.index_to_color(index as usize * 2, Color::White));
key2.set_bg(self.index_to_color(index as usize * 2 + 1, Color::White));
for x in x+5..x+width-1 {
let cell = buf.get_mut(x, y);
cell.set_char('░');
cell.set_style(black);
}
//for x in x+Self::H_KEYS_OFFSET..x+width-1 {
//let cell = buf.get_mut(x, y);
//cell.set_char('░');
//cell.set_style(black);
//}
let note_a = note0 + (index * 2) as usize;
if note_a % 12 == 0 {
let octave = format!("C{}", (note_a / 12) as i8 - 2);
@ -177,26 +179,28 @@ impl<'a> SequencerView<'a> {
if phrase.is_none() {
return Ok(Rect { x: area.x, y: area.x, width: 0, height: 0 })
}
let phrase = phrase.unwrap();
let (ppq, time_z, time0, note0) =
(self.ppq, self.time_zoom, self.time_start, self.note_start);
let dim = Style::default().dim();
let Rect { x, y, width, height } = area;
let offset = 5;
let phrase_area = Rect {
x: x + offset, y, width: width - offset, height: height - 2
};
let mut steps = vec![];
let phrase = phrase.unwrap();
let now = self.now % phrase.length;
let ppq = self.ppq;
let time_z = self.time_zoom;
let time0 = self.time_start;
let note0 = self.note_start;
let dim = Style::default().dim();
let offset = Self::H_KEYS_OFFSET;
let phrase_area = Rect { x: x + offset, y, width: width - offset, height: height - 2 };
let mut steps = Vec::with_capacity(phrase_area.width as usize);
for x in phrase_area.x .. phrase_area.x + phrase_area.width {
let x0 = x.saturating_sub(phrase_area.x) as usize;
let step = (0 + time0 + x0) * time_z;
let next = (1 + time0 + x0) * time_z;
if step > phrase.length {
if step >= phrase.length {
break
}
let style = Self::style_timer_step(now, step, next);
let cell = buf.get_mut(x, area.y);
cell.set_char('-');
cell.set_style(style);
steps.push((x, step, next));
for y in phrase_area.y .. phrase_area.y + phrase_area.height {
if y == phrase_area.y {