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",
|
"./time",
|
||||||
"./tui"
|
"./tui"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
lto = true
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ impl Default for MidiEditor {
|
||||||
has_size!(<TuiOut>|self: MidiEditor|&self.size);
|
has_size!(<TuiOut>|self: MidiEditor|&self.size);
|
||||||
render!(TuiOut: (self: MidiEditor) => {
|
render!(TuiOut: (self: MidiEditor) => {
|
||||||
self.autoscroll();
|
self.autoscroll();
|
||||||
self.autozoom();
|
//self.autozoom();
|
||||||
Fill::xy(Bsp::b(&self.size, &self.mode))
|
Fill::xy(Bsp::b(&self.size, &self.mode))
|
||||||
});
|
});
|
||||||
impl TimeRange for MidiEditor {
|
impl TimeRange for MidiEditor {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ impl PianoHorizontal {
|
||||||
let mut range = MidiRangeModel::from((24, true));
|
let mut range = MidiRangeModel::from((24, true));
|
||||||
range.time_axis = size.x.clone();
|
range.time_axis = size.x.clone();
|
||||||
range.note_axis = size.y.clone();
|
range.note_axis = size.y.clone();
|
||||||
let mut piano = Self {
|
let piano = Self {
|
||||||
keys_width: 5,
|
keys_width: 5,
|
||||||
size,
|
size,
|
||||||
range,
|
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)> {
|
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))
|
(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::y(1, Bsp::e(
|
||||||
Fixed::x(self.keys_width, ""),
|
Fixed::x(self.keys_width, ""),
|
||||||
Fill::x(PianoHorizontalTimeline(self)),
|
Fill::x(PianoHorizontalTimeline(self)),
|
||||||
)),
|
)),
|
||||||
Fill::xy(Bsp::e(
|
Fill::xy(Bsp::e(
|
||||||
Fixed::x(self.keys_width, PianoHorizontalKeys(self)),
|
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 {
|
impl PianoHorizontal {
|
||||||
|
|
@ -84,7 +79,6 @@ impl PianoHorizontal {
|
||||||
let style = Style::default().fg(clip.color.base.rgb);//.bg(Color::Rgb(0, 0, 0));
|
let style = Style::default().fg(clip.color.base.rgb);//.bg(Color::Rgb(0, 0, 0));
|
||||||
let mut notes_on = [false;128];
|
let mut notes_on = [false;128];
|
||||||
for (x, time_start) in (0..clip.length).step_by(zoom).enumerate() {
|
for (x, time_start) in (0..clip.length).step_by(zoom).enumerate() {
|
||||||
|
|
||||||
for (y, note) in (0..=127).rev().enumerate() {
|
for (y, note) in (0..=127).rev().enumerate() {
|
||||||
if let Some(cell) = buf.get_mut(x, note) {
|
if let Some(cell) = buf.get_mut(x, note) {
|
||||||
if notes_on[note] {
|
if notes_on[note] {
|
||||||
|
|
@ -93,7 +87,6 @@ impl PianoHorizontal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let time_end = time_start + zoom;
|
let time_end = time_start + zoom;
|
||||||
for time in time_start..time_end.min(clip.length) {
|
for time in time_start..time_end.min(clip.length) {
|
||||||
for event in clip.notes[time].iter() {
|
for event in clip.notes[time].iter() {
|
||||||
|
|
@ -122,32 +115,31 @@ impl PianoHorizontal {
|
||||||
let note_hi = self.note_hi();
|
let note_hi = self.note_hi();
|
||||||
let note_point = self.note_point();
|
let note_point = self.note_point();
|
||||||
let buffer = self.buffer.clone();
|
let buffer = self.buffer.clone();
|
||||||
return ""
|
RenderThunk::new(move|render: &mut TuiOut|{
|
||||||
//RenderThunk::new(move|render: &mut TuiOut|{
|
let source = buffer.read().unwrap();
|
||||||
//let source = buffer.read().unwrap();
|
let [x0, y0, w, h] = render.area().xywh();
|
||||||
//let [x0, y0, w, h] = render.area().xywh();
|
|
||||||
//if h as usize != note_axis {
|
//if h as usize != note_axis {
|
||||||
//panic!("area height mismatch: {h} <> {note_axis}");
|
//panic!("area height mismatch: {h} <> {note_axis}");
|
||||||
//}
|
//}
|
||||||
//for (area_x, screen_x) in (x0..x0+w).enumerate() {
|
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) {
|
for (area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
|
||||||
//let source_x = time_start + area_x;
|
let source_x = time_start + area_x;
|
||||||
//let source_y = note_hi - area_y;
|
let source_y = note_hi - area_y;
|
||||||
//// TODO: enable loop rollover:
|
// TODO: enable loop rollover:
|
||||||
////let source_x = (time_start + area_x) % source.width.max(1);
|
//let source_x = (time_start + area_x) % source.width.max(1);
|
||||||
////let source_y = (note_hi - area_y) % source.height.max(1);
|
//let source_y = (note_hi - area_y) % source.height.max(1);
|
||||||
//let is_in_x = source_x < source.width;
|
let is_in_x = source_x < source.width;
|
||||||
//let is_in_y = source_y < source.height;
|
let is_in_y = source_y < source.height;
|
||||||
//if is_in_x && is_in_y {
|
if is_in_x && is_in_y {
|
||||||
//if let Some(source_cell) = source.get(source_x, source_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))) {
|
if let Some(cell) = render.buffer.cell_mut(ratatui::prelude::Position::from((screen_x, screen_y))) {
|
||||||
//*cell = source_cell.clone();
|
*cell = source_cell.clone();
|
||||||
//}
|
}
|
||||||
//}
|
}
|
||||||
//}
|
}
|
||||||
//}
|
}
|
||||||
//}
|
}
|
||||||
//})
|
})
|
||||||
}
|
}
|
||||||
fn cursor (&self) -> impl Content<TuiOut> {
|
fn cursor (&self) -> impl Content<TuiOut> {
|
||||||
let style = Some(Style::default().fg(self.color.lightest.rgb));
|
let style = Some(Style::default().fg(self.color.lightest.rgb));
|
||||||
|
|
@ -158,28 +150,27 @@ impl PianoHorizontal {
|
||||||
let time_point = self.time_point();
|
let time_point = self.time_point();
|
||||||
let time_start = self.time_start().get();
|
let time_start = self.time_start().get();
|
||||||
let time_zoom = self.time_zoom().get();
|
let time_zoom = self.time_zoom().get();
|
||||||
""
|
RenderThunk::new(move|render: &mut TuiOut|{
|
||||||
//RenderThunk::new(move|render: &mut TuiOut|{
|
let [x0, y0, w, _] = render.area().xywh();
|
||||||
////let [x0, y0, w, _] = render.area().xywh();
|
for (_area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
|
||||||
////for (_area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {
|
if note == note_point {
|
||||||
////if note == note_point {
|
for x in 0..w {
|
||||||
////for x in 0..w {
|
let screen_x = x0 + x;
|
||||||
////let screen_x = x0 + x;
|
let time_1 = time_start + x as usize * time_zoom;
|
||||||
////let time_1 = time_start + x as usize * time_zoom;
|
let time_2 = time_1 + time_zoom;
|
||||||
////let time_2 = time_1 + time_zoom;
|
if time_1 <= time_point && time_point < time_2 {
|
||||||
////if time_1 <= time_point && time_point < time_2 {
|
render.blit(&"█", screen_x, screen_y, style);
|
||||||
////render.blit(&"█", screen_x, screen_y, style);
|
let tail = note_len as u16 / time_zoom as u16;
|
||||||
////let tail = note_len as u16 / time_zoom as u16;
|
for x_tail in (screen_x + 1)..(screen_x + tail) {
|
||||||
////for x_tail in (screen_x + 1)..(screen_x + tail) {
|
render.blit(&"▂", x_tail, screen_y, style);
|
||||||
////render.blit(&"▂", x_tail, screen_y, style);
|
}
|
||||||
////}
|
break
|
||||||
////break
|
}
|
||||||
////}
|
}
|
||||||
////}
|
break
|
||||||
////break
|
}
|
||||||
////}
|
}
|
||||||
////}
|
})
|
||||||
//})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,3 @@ wavers = "1.4.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
lto = true
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue