mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
the freeze was the autozoom
This commit is contained in:
parent
08f7a62692
commit
36707fc7eb
4 changed files with 50 additions and 59 deletions
|
|
@ -11,3 +11,6 @@ members = [
|
|||
"./time",
|
||||
"./tui"
|
||||
]
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ impl Default for MidiEditor {
|
|||
has_size!(<TuiOut>|self: MidiEditor|&self.size);
|
||||
render!(TuiOut: (self: MidiEditor) => {
|
||||
self.autoscroll();
|
||||
self.autozoom();
|
||||
//self.autozoom();
|
||||
Fill::xy(Bsp::b(&self.size, &self.mode))
|
||||
});
|
||||
impl TimeRange for MidiEditor {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ impl PianoHorizontal {
|
|||
let mut range = MidiRangeModel::from((24, true));
|
||||
range.time_axis = size.x.clone();
|
||||
range.note_axis = size.y.clone();
|
||||
let mut piano = Self {
|
||||
let piano = Self {
|
||||
keys_width: 5,
|
||||
size,
|
||||
range,
|
||||
|
|
@ -40,19 +40,14 @@ impl PianoHorizontal {
|
|||
pub(crate) fn note_y_iter (note_lo: usize, note_hi: usize, y0: u16) -> impl Iterator<Item=(usize, u16, usize)> {
|
||||
(note_lo..=note_hi).rev().enumerate().map(move|(y, n)|(y, y0 + y as u16, n))
|
||||
}
|
||||
render!(TuiOut: (self: PianoHorizontal) => Bsp::s( // the freeze is in the piano
|
||||
render!(TuiOut: (self: PianoHorizontal) => Bsp::s( // the freeze is in the Measure
|
||||
Fixed::y(1, Bsp::e(
|
||||
Fixed::x(self.keys_width, ""),
|
||||
Fill::x(PianoHorizontalTimeline(self)),
|
||||
)),
|
||||
Fill::xy(Bsp::e(
|
||||
Fixed::x(self.keys_width, PianoHorizontalKeys(self)),
|
||||
Fill::xy(self.size.of("")),
|
||||
//"",
|
||||
//Fill::xy(self.size.of(lay!(
|
||||
////self.notes(),
|
||||
////self.cursor()
|
||||
//))),
|
||||
Fill::xy(self.size.of(lay!(self.notes(), self.cursor()))),
|
||||
)),
|
||||
));
|
||||
impl PianoHorizontal {
|
||||
|
|
@ -84,7 +79,6 @@ impl PianoHorizontal {
|
|||
let style = Style::default().fg(clip.color.base.rgb);//.bg(Color::Rgb(0, 0, 0));
|
||||
let mut notes_on = [false;128];
|
||||
for (x, time_start) in (0..clip.length).step_by(zoom).enumerate() {
|
||||
|
||||
for (y, note) in (0..=127).rev().enumerate() {
|
||||
if let Some(cell) = buf.get_mut(x, note) {
|
||||
if notes_on[note] {
|
||||
|
|
@ -93,7 +87,6 @@ impl PianoHorizontal {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
let time_end = time_start + zoom;
|
||||
for time in time_start..time_end.min(clip.length) {
|
||||
for event in clip.notes[time].iter() {
|
||||
|
|
@ -122,32 +115,31 @@ impl PianoHorizontal {
|
|||
let note_hi = self.note_hi();
|
||||
let note_point = self.note_point();
|
||||
let buffer = self.buffer.clone();
|
||||
return ""
|
||||
//RenderThunk::new(move|render: &mut TuiOut|{
|
||||
//let source = buffer.read().unwrap();
|
||||
//let [x0, y0, w, h] = render.area().xywh();
|
||||
RenderThunk::new(move|render: &mut TuiOut|{
|
||||
let source = buffer.read().unwrap();
|
||||
let [x0, y0, w, h] = render.area().xywh();
|
||||
//if h as usize != note_axis {
|
||||
//panic!("area height mismatch: {h} <> {note_axis}");
|
||||
//}
|
||||
//for (area_x, screen_x) in (x0..x0+w).enumerate() {
|
||||
//for (area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
|
||||
//let source_x = time_start + area_x;
|
||||
//let source_y = note_hi - area_y;
|
||||
//// TODO: enable loop rollover:
|
||||
////let source_x = (time_start + area_x) % source.width.max(1);
|
||||
////let source_y = (note_hi - area_y) % source.height.max(1);
|
||||
//let is_in_x = source_x < source.width;
|
||||
//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) = render.buffer.cell_mut(ratatui::prelude::Position::from((screen_x, screen_y))) {
|
||||
//*cell = source_cell.clone();
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//}
|
||||
//})
|
||||
for (area_x, screen_x) in (x0..x0+w).enumerate() {
|
||||
for (area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
|
||||
let source_x = time_start + area_x;
|
||||
let source_y = note_hi - area_y;
|
||||
// TODO: enable loop rollover:
|
||||
//let source_x = (time_start + area_x) % source.width.max(1);
|
||||
//let source_y = (note_hi - area_y) % source.height.max(1);
|
||||
let is_in_x = source_x < source.width;
|
||||
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) = render.buffer.cell_mut(ratatui::prelude::Position::from((screen_x, screen_y))) {
|
||||
*cell = source_cell.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
fn cursor (&self) -> impl Content<TuiOut> {
|
||||
let style = Some(Style::default().fg(self.color.lightest.rgb));
|
||||
|
|
@ -158,28 +150,27 @@ impl PianoHorizontal {
|
|||
let time_point = self.time_point();
|
||||
let time_start = self.time_start().get();
|
||||
let time_zoom = self.time_zoom().get();
|
||||
""
|
||||
//RenderThunk::new(move|render: &mut TuiOut|{
|
||||
////let [x0, y0, w, _] = render.area().xywh();
|
||||
////for (_area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
|
||||
////if note == note_point {
|
||||
////for x in 0..w {
|
||||
////let screen_x = x0 + x;
|
||||
////let time_1 = time_start + x as usize * time_zoom;
|
||||
////let time_2 = time_1 + time_zoom;
|
||||
////if time_1 <= time_point && time_point < time_2 {
|
||||
////render.blit(&"█", screen_x, screen_y, style);
|
||||
////let tail = note_len as u16 / time_zoom as u16;
|
||||
////for x_tail in (screen_x + 1)..(screen_x + tail) {
|
||||
////render.blit(&"▂", x_tail, screen_y, style);
|
||||
////}
|
||||
////break
|
||||
////}
|
||||
////}
|
||||
////break
|
||||
////}
|
||||
////}
|
||||
//})
|
||||
RenderThunk::new(move|render: &mut TuiOut|{
|
||||
let [x0, y0, w, _] = render.area().xywh();
|
||||
for (_area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
|
||||
if note == note_point {
|
||||
for x in 0..w {
|
||||
let screen_x = x0 + x;
|
||||
let time_1 = time_start + x as usize * time_zoom;
|
||||
let time_2 = time_1 + time_zoom;
|
||||
if time_1 <= time_point && time_point < time_2 {
|
||||
render.blit(&"█", screen_x, screen_y, style);
|
||||
let tail = note_len as u16 / time_zoom as u16;
|
||||
for x_tail in (screen_x + 1)..(screen_x + tail) {
|
||||
render.blit(&"▂", x_tail, screen_y, style);
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,3 @@ wavers = "1.4.3"
|
|||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue