mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
36 lines
1.6 KiB
Rust
36 lines
1.6 KiB
Rust
use crate::*;
|
|
|
|
pub struct MidiEditClip<'a>(pub &'a MidiEditor);
|
|
render!(TuiOut: (self: MidiEditClip<'a>) => {
|
|
let (color, name, length, looped) = if let Some(phrase) = self.0.phrase().as_ref().map(|p|p.read().unwrap()) {
|
|
(phrase.color, phrase.name.clone(), phrase.length, phrase.looped)
|
|
} else {
|
|
(ItemPalette::from(TuiTheme::g(64)), String::new(), 0, false)
|
|
};
|
|
row!(
|
|
FieldV(color, "Edit", format!("{name} ({length})")),
|
|
FieldV(color, "Loop", looped.to_string())
|
|
)
|
|
});
|
|
|
|
pub struct MidiEditStatus<'a>(pub &'a MidiEditor);
|
|
render!(TuiOut: (self: MidiEditStatus<'a>) => {
|
|
let (color, name, length, looped) = if let Some(phrase) = self.0.phrase().as_ref().map(|p|p.read().unwrap()) {
|
|
(phrase.color, phrase.name.clone(), phrase.length, phrase.looped)
|
|
} else {
|
|
(ItemPalette::from(TuiTheme::g(64)), String::new(), 0, false)
|
|
};
|
|
let time_point = self.0.time_point();
|
|
let time_start = self.0.time_start();
|
|
let time_end = self.0.time_end();
|
|
let time_axis = self.0.time_axis().get();
|
|
let time_zoom = self.0.time_zoom().get();
|
|
let time_lock = if self.0.time_lock().get() { "[lock]" } else { " " };
|
|
let time_field = FieldV(color, "Time", format!("{length}/{time_zoom}+{time_point} {time_lock}"));
|
|
|
|
let note_point = format!("{:>3}", self.0.note_point());
|
|
let note_name = format!("{:4}", Note::pitch_to_name(self.0.note_point()));
|
|
let note_len = format!("{:>4}", self.0.note_len());;;;
|
|
let note_field = FieldV(color, "Note", format!("{note_name} {note_point} {note_len}"));
|
|
Bsp::e(time_field, note_field,)
|
|
});
|