mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-07-17 15:56:57 +02:00
109e...
This commit is contained in:
parent
b44dc635ef
commit
80fe958476
8 changed files with 69 additions and 45 deletions
|
|
@ -525,6 +525,7 @@ impl PianoHorizontal {
|
|||
}
|
||||
|
||||
impl PianoHorizontal {
|
||||
|
||||
/// Draw the piano roll background.
|
||||
///
|
||||
/// This mode uses full blocks on note on and half blocks on legato: █▄ █▄ █▄
|
||||
|
|
@ -559,6 +560,7 @@ impl PianoHorizontal {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Draw the piano roll foreground.
|
||||
///
|
||||
/// This mode uses full blocks on note on and half blocks on legato: █▄ █▄ █▄
|
||||
|
|
@ -596,14 +598,16 @@ impl PianoHorizontal {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
fn notes (&self) -> impl Draw<Tui> {
|
||||
let time_start = self.get_time_start();
|
||||
let note_lo = self.get_note_lo();
|
||||
let note_hi = self.get_note_hi();
|
||||
let buffer = self.buffer.clone();
|
||||
Thunk::new(move|to: &mut Tui|{
|
||||
thunk(move|to: &mut Tui|{
|
||||
let xywh = to.area().into();
|
||||
let XYWH(x0, y0, w, _h) = xywh;
|
||||
let source = buffer.read().unwrap();
|
||||
let XYWH(x0, y0, w, _h) = to.area();
|
||||
//if h as usize != note_axis {
|
||||
//panic!("area height mismatch: {h} <> {note_axis}");
|
||||
//}
|
||||
|
|
@ -618,15 +622,17 @@ impl PianoHorizontal {
|
|||
let is_in_y = source_y < source.height;
|
||||
if is_in_x && is_in_y {
|
||||
if let Some(source_cell) = source.get(source_x, source_y) {
|
||||
if let Some(cell) = to.buffer.cell_mut(ratatui::prelude::Position::from((screen_x, screen_y))) {
|
||||
if let Some(cell) = to.0.cell_mut(ratatui::prelude::Position::from((screen_x, screen_y))) {
|
||||
*cell = source_cell.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(xywh)
|
||||
})
|
||||
}
|
||||
|
||||
fn cursor (&self) -> impl Draw<Tui> {
|
||||
let note_hi = self.get_note_hi();
|
||||
let note_lo = self.get_note_lo();
|
||||
|
|
@ -636,8 +642,9 @@ impl PianoHorizontal {
|
|||
let time_start = self.get_time_start();
|
||||
let time_zoom = self.get_time_zoom();
|
||||
let style = Some(Style::default().fg(self.color.lightest.term));
|
||||
Thunk::new(move|to: &mut Tui|{
|
||||
let XYWH(x0, y0, w, _) = to.area();
|
||||
thunk(move|to: &mut Tui|{
|
||||
let xywh = to.area().into();
|
||||
let XYWH(x0, y0, w, _h) = xywh;
|
||||
for (_area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
|
||||
if note == note_pos {
|
||||
for x in 0..w {
|
||||
|
|
@ -656,8 +663,10 @@ impl PianoHorizontal {
|
|||
break
|
||||
}
|
||||
}
|
||||
Ok(xywh)
|
||||
})
|
||||
}
|
||||
|
||||
fn keys (&self) -> impl Draw<Tui> {
|
||||
let state = self;
|
||||
let color = state.color;
|
||||
|
|
@ -667,8 +676,9 @@ impl PianoHorizontal {
|
|||
let key_style = Some(Style::default().fg(Rgb(192, 192, 192)).bg(Rgb(0, 0, 0)));
|
||||
let off_style = Some(Style::default().fg(g(255)));
|
||||
let on_style = Some(Style::default().fg(Rgb(255,0,0)).bg(color.base.term).bold());
|
||||
h_full(w_exact(self.keys_width, Thunk::new(move|to: &mut Tui|{
|
||||
let XYWH(x, y0, _w, _h) = to.area();
|
||||
h_full(w_exact(self.keys_width, thunk(move|to: &mut Tui|{
|
||||
let xywh = to.area().into();
|
||||
let XYWH(x, y0, _w, _h) = xywh;
|
||||
for (_area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
|
||||
to.blit(&to_key(note), x, screen_y, key_style);
|
||||
if note > 127 {
|
||||
|
|
@ -680,11 +690,14 @@ impl PianoHorizontal {
|
|||
to.blit(¬e_pitch_to_name(note), x, screen_y, off_style)
|
||||
};
|
||||
}
|
||||
Ok(xywh)
|
||||
})))
|
||||
}
|
||||
|
||||
fn timeline (&self) -> impl Draw<Tui> + '_ {
|
||||
w_full(h_exact(1, Thunk::new(move|to: &mut Tui|{
|
||||
let XYWH(x, y, w, _h) = to.area();
|
||||
w_full(h_exact(1, thunk(move|to: &mut Tui|{
|
||||
let xywh = to.area().into();
|
||||
let XYWH(x, y, w, _h) = xywh;
|
||||
let style = Some(Style::default().dim());
|
||||
let length = self.clip.as_ref().map(|p|p.read().unwrap().length).unwrap_or(1);
|
||||
for (area_x, screen_x) in (0..w).map(|d|(d, d+x)) {
|
||||
|
|
@ -693,6 +706,7 @@ impl PianoHorizontal {
|
|||
to.blit(&"|", screen_x, y, style);
|
||||
}
|
||||
}
|
||||
Ok(xywh)
|
||||
})))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue