mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
editor: reverse highlight
This commit is contained in:
parent
4a9e9132f3
commit
b7152ef807
4 changed files with 38 additions and 23 deletions
|
|
@ -95,34 +95,36 @@ use crate::*;
|
|||
#[tengri_proc::command(MidiEditor)] impl MidiEditCommand {
|
||||
fn append_note (editor: &mut MidiEditor, advance: bool) -> Perhaps<Self> {
|
||||
editor.put_note(advance);
|
||||
editor.redraw();
|
||||
Ok(None)
|
||||
}
|
||||
fn delete_note (_editor: &mut MidiEditor) -> Perhaps<Self> {
|
||||
fn delete_note (editor: &mut MidiEditor) -> Perhaps<Self> {
|
||||
editor.redraw();
|
||||
todo!()
|
||||
}
|
||||
fn set_note_pos (editor: &mut MidiEditor, pos: usize) -> Perhaps<Self> {
|
||||
editor.set_note_pos(pos.min(127));
|
||||
editor.redraw();
|
||||
Ok(None)
|
||||
}
|
||||
fn set_note_len (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
||||
//let note_len = editor.get_note_len();
|
||||
//let time_zoom = editor.get_time_zoom();
|
||||
editor.set_note_len(value);
|
||||
//if note_len / time_zoom != x / time_zoom {
|
||||
editor.redraw();
|
||||
//}
|
||||
editor.redraw();
|
||||
Ok(None)
|
||||
}
|
||||
fn set_note_scroll (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
||||
editor.set_note_lo(value.min(127));
|
||||
editor.redraw();
|
||||
Ok(None)
|
||||
}
|
||||
fn set_time_pos (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
||||
editor.set_time_pos(value);
|
||||
editor.redraw();
|
||||
Ok(None)
|
||||
}
|
||||
fn set_time_scroll (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
||||
editor.set_time_start(value);
|
||||
editor.redraw();
|
||||
Ok(None)
|
||||
}
|
||||
fn set_time_zoom (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
||||
|
|
@ -132,10 +134,12 @@ use crate::*;
|
|||
}
|
||||
fn set_time_lock (editor: &mut MidiEditor, value: bool) -> Perhaps<Self> {
|
||||
editor.set_time_lock(value);
|
||||
editor.redraw();
|
||||
Ok(None)
|
||||
}
|
||||
fn show (editor: &mut MidiEditor, clip: Option<Arc<RwLock<MidiClip>>>) -> Perhaps<Self> {
|
||||
editor.set_clip(clip.as_ref());
|
||||
editor.redraw();
|
||||
Ok(None)
|
||||
}
|
||||
// TODO: 1-9 seek markers that by default start every 8th of the clip
|
||||
|
|
|
|||
|
|
@ -64,11 +64,22 @@ impl PianoHorizontal {
|
|||
/// Draw the piano roll background.
|
||||
///
|
||||
/// This mode uses full blocks on note on and half blocks on legato: █▄ █▄ █▄
|
||||
fn draw_bg (buf: &mut BigBuffer, clip: &MidiClip, zoom: usize, note_len: usize) {
|
||||
fn draw_bg (
|
||||
buf: &mut BigBuffer,
|
||||
clip: &MidiClip,
|
||||
zoom: usize,
|
||||
note_len: usize,
|
||||
note_point: usize,
|
||||
time_point: usize,
|
||||
) {
|
||||
for (y, note) in (0..=127).rev().enumerate() {
|
||||
for (x, time) in (0..buf.width).map(|x|(x, x*zoom)) {
|
||||
let cell = buf.get_mut(x, y).unwrap();
|
||||
cell.set_bg(clip.color.darkest.rgb);
|
||||
if note == (127-note_point) || time == time_point {
|
||||
cell.set_bg(Rgb(0,0,0));
|
||||
} else {
|
||||
cell.set_bg(clip.color.darkest.rgb);
|
||||
}
|
||||
if time % 384 == 0 {
|
||||
cell.set_fg(clip.color.darker.rgb);
|
||||
cell.set_char('│');
|
||||
|
|
@ -267,10 +278,10 @@ impl MidiViewer for PianoHorizontal {
|
|||
let clip = clip.read().unwrap();
|
||||
let buf_size = self.buffer_size(&clip);
|
||||
let mut buffer = BigBuffer::from(buf_size);
|
||||
let note_len = self.get_note_len();
|
||||
let time_zoom = self.get_time_zoom();
|
||||
self.time_len().set(clip.length);
|
||||
PianoHorizontal::draw_bg(&mut buffer, &clip, time_zoom, note_len);
|
||||
PianoHorizontal::draw_bg(&mut buffer, &clip, time_zoom,
|
||||
self.get_note_len(), self.get_note_pos(), self.get_time_pos());
|
||||
PianoHorizontal::draw_fg(&mut buffer, &clip, time_zoom);
|
||||
buffer
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue