mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +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 {
|
#[tengri_proc::command(MidiEditor)] impl MidiEditCommand {
|
||||||
fn append_note (editor: &mut MidiEditor, advance: bool) -> Perhaps<Self> {
|
fn append_note (editor: &mut MidiEditor, advance: bool) -> Perhaps<Self> {
|
||||||
editor.put_note(advance);
|
editor.put_note(advance);
|
||||||
|
editor.redraw();
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
fn delete_note (_editor: &mut MidiEditor) -> Perhaps<Self> {
|
fn delete_note (editor: &mut MidiEditor) -> Perhaps<Self> {
|
||||||
|
editor.redraw();
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
fn set_note_pos (editor: &mut MidiEditor, pos: usize) -> Perhaps<Self> {
|
fn set_note_pos (editor: &mut MidiEditor, pos: usize) -> Perhaps<Self> {
|
||||||
editor.set_note_pos(pos.min(127));
|
editor.set_note_pos(pos.min(127));
|
||||||
|
editor.redraw();
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
fn set_note_len (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
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);
|
editor.set_note_len(value);
|
||||||
//if note_len / time_zoom != x / time_zoom {
|
editor.redraw();
|
||||||
editor.redraw();
|
|
||||||
//}
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
fn set_note_scroll (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
fn set_note_scroll (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
||||||
editor.set_note_lo(value.min(127));
|
editor.set_note_lo(value.min(127));
|
||||||
|
editor.redraw();
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
fn set_time_pos (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
fn set_time_pos (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
||||||
editor.set_time_pos(value);
|
editor.set_time_pos(value);
|
||||||
|
editor.redraw();
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
fn set_time_scroll (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
fn set_time_scroll (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
||||||
editor.set_time_start(value);
|
editor.set_time_start(value);
|
||||||
|
editor.redraw();
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
fn set_time_zoom (editor: &mut MidiEditor, value: usize) -> Perhaps<Self> {
|
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> {
|
fn set_time_lock (editor: &mut MidiEditor, value: bool) -> Perhaps<Self> {
|
||||||
editor.set_time_lock(value);
|
editor.set_time_lock(value);
|
||||||
|
editor.redraw();
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
fn show (editor: &mut MidiEditor, clip: Option<Arc<RwLock<MidiClip>>>) -> Perhaps<Self> {
|
fn show (editor: &mut MidiEditor, clip: Option<Arc<RwLock<MidiClip>>>) -> Perhaps<Self> {
|
||||||
editor.set_clip(clip.as_ref());
|
editor.set_clip(clip.as_ref());
|
||||||
|
editor.redraw();
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
// TODO: 1-9 seek markers that by default start every 8th of the clip
|
// 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.
|
/// Draw the piano roll background.
|
||||||
///
|
///
|
||||||
/// This mode uses full blocks on note on and half blocks on legato: █▄ █▄ █▄
|
/// 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 (y, note) in (0..=127).rev().enumerate() {
|
||||||
for (x, time) in (0..buf.width).map(|x|(x, x*zoom)) {
|
for (x, time) in (0..buf.width).map(|x|(x, x*zoom)) {
|
||||||
let cell = buf.get_mut(x, y).unwrap();
|
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 {
|
if time % 384 == 0 {
|
||||||
cell.set_fg(clip.color.darker.rgb);
|
cell.set_fg(clip.color.darker.rgb);
|
||||||
cell.set_char('│');
|
cell.set_char('│');
|
||||||
|
|
@ -267,10 +278,10 @@ impl MidiViewer for PianoHorizontal {
|
||||||
let clip = clip.read().unwrap();
|
let clip = clip.read().unwrap();
|
||||||
let buf_size = self.buffer_size(&clip);
|
let buf_size = self.buffer_size(&clip);
|
||||||
let mut buffer = BigBuffer::from(buf_size);
|
let mut buffer = BigBuffer::from(buf_size);
|
||||||
let note_len = self.get_note_len();
|
|
||||||
let time_zoom = self.get_time_zoom();
|
let time_zoom = self.get_time_zoom();
|
||||||
self.time_len().set(clip.length);
|
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);
|
PianoHorizontal::draw_fg(&mut buffer, &clip, time_zoom);
|
||||||
buffer
|
buffer
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ pub fn to_rms (samples: &[f32]) -> f32 {
|
||||||
(sum / samples.len() as f32).sqrt()
|
(sum / samples.len() as f32).sqrt()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub (crate) fn view_meter <'a> (label: &'a str, value: f32) -> impl Content<TuiOut> + 'a {
|
pub fn view_meter <'a> (label: &'a str, value: f32) -> impl Content<TuiOut> + 'a {
|
||||||
col!(
|
col!(
|
||||||
FieldH(ItemTheme::G[128], label, format!("{:>+9.3}", value)),
|
FieldH(ItemTheme::G[128], label, format!("{:>+9.3}", value)),
|
||||||
Fixed::xy(if value >= 0.0 { 13 }
|
Fixed::xy(if value >= 0.0 { 13 }
|
||||||
|
|
@ -74,7 +74,7 @@ pub (crate) fn view_meter <'a> (label: &'a str, value: f32) -> impl Content<TuiO
|
||||||
else { Green }, ())))
|
else { Green }, ())))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn view_meters (values: &[f32;2]) -> impl Content<TuiOut> + use<'_> {
|
pub fn view_meters (values: &[f32;2]) -> impl Content<TuiOut> + use<'_> {
|
||||||
let left = format!("L/{:>+9.3}", values[0]);
|
let left = format!("L/{:>+9.3}", values[0]);
|
||||||
let right = format!("R/{:>+9.3}", values[1]);
|
let right = format!("R/{:>+9.3}", values[1]);
|
||||||
Bsp::s(left, right)
|
Bsp::s(left, right)
|
||||||
|
|
|
||||||
|
|
@ -223,12 +223,12 @@ fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + us
|
||||||
let sample = sample.unwrap().read().unwrap();
|
let sample = sample.unwrap().read().unwrap();
|
||||||
let theme = sample.color;
|
let theme = sample.color;
|
||||||
row!(
|
row!(
|
||||||
FieldH(theme, "Name", format!("{:<10}", sample.name.clone())),
|
FieldH(theme, "Name", format!("{:<10}", sample.name.clone())),
|
||||||
FieldH(theme, "Length", format!("{:<8}", sample.channels[0].len())),
|
FieldH(theme, "Length", format!("{:<8}", sample.channels[0].len())),
|
||||||
FieldH(theme, "Start", format!("{:<8}", sample.start)),
|
FieldH(theme, "Start", format!("{:<8}", sample.start)),
|
||||||
FieldH(theme, "End", format!("{:<8}", sample.end)),
|
FieldH(theme, "End", format!("{:<8}", sample.end)),
|
||||||
FieldH(theme, "Transpose", " 0 "),
|
FieldH(theme, "Trans", "0"),
|
||||||
FieldH(theme, "Gain", format!("{}", sample.gain)),
|
FieldH(theme, "Gain", format!("{}", sample.gain)),
|
||||||
)
|
)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
@ -239,11 +239,11 @@ fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> +
|
||||||
let theme = sample.color;
|
let theme = sample.color;
|
||||||
Fixed::x(20, col!(
|
Fixed::x(20, col!(
|
||||||
Fill::x(Align::w(FieldH(theme, "Name ", format!("{:<10}", sample.name.clone())))),
|
Fill::x(Align::w(FieldH(theme, "Name ", format!("{:<10}", sample.name.clone())))),
|
||||||
Fill::x(Align::w(FieldH(theme, "Length", format!("{:<8}", sample.channels[0].len())))),
|
Fill::x(Align::w(FieldH(theme, "Length", format!("{:<8}", sample.channels[0].len())))),
|
||||||
Fill::x(Align::w(FieldH(theme, "Start ", format!("{:<8}", sample.start)))),
|
Fill::x(Align::w(FieldH(theme, "Start ", format!("{:<8}", sample.start)))),
|
||||||
Fill::x(Align::w(FieldH(theme, "End ", format!("{:<8}", sample.end)))),
|
Fill::x(Align::w(FieldH(theme, "End ", format!("{:<8}", sample.end)))),
|
||||||
Fill::x(Align::w(FieldH(theme, "Trans ", "0 "))),
|
Fill::x(Align::w(FieldH(theme, "Trans ", "0"))),
|
||||||
Fill::x(Align::w(FieldH(theme, "Gain ", format!("{}", sample.gain)))),
|
Fill::x(Align::w(FieldH(theme, "Gain ", format!("{}", sample.gain)))),
|
||||||
))
|
))
|
||||||
}), Thunk::new(move||Tui::fg(Red, col!(
|
}), Thunk::new(move||Tui::fg(Red, col!(
|
||||||
"× No sample.",
|
"× No sample.",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue