mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-10-08 18:56:42 +02:00
colorize; show editor
This commit is contained in:
parent
9a50ce6613
commit
ea74aba7b7
3 changed files with 79 additions and 60 deletions
113
src/tek_view.rs
113
src/tek_view.rs
|
|
@ -607,45 +607,6 @@ impl OctaveVertical {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn view_editor_clip_status (editor: &MidiEditor) -> impl Draw<Tui> + '_ {
|
||||
let (
|
||||
_color, name, length, looped
|
||||
) = if let Some(clip) = editor.mode.clip.read().as_ref().map(|p|p.read()) {
|
||||
(clip.color, clip.name.clone(), clip.length, clip.looped)
|
||||
} else {
|
||||
(ItemTheme::G[64], String::new().into(), 0, false)
|
||||
};
|
||||
south!(
|
||||
east(button_2("f2", "name ", false), fg(Rgb(255, 255, 255), format!("{name} "))
|
||||
.origin_e().full_w()).origin_w().full_w(),
|
||||
east(button_2("l", "ength ", false), fg(Rgb(255, 255, 255), format!("{length} ")).origin_e().full_w())
|
||||
.origin_w().full_w(),
|
||||
east(button_2("r", "epeat ", false), fg(Rgb(255, 255, 255), format!("{looped} ")).origin_e().full_w())
|
||||
.origin_w().full_w(),
|
||||
).exact_w(20)
|
||||
}
|
||||
|
||||
pub fn view_editor_edit_status (editor: &MidiEditor) -> impl Draw<Tui> + '_ {
|
||||
let (_color, length) = if let Some(clip) = editor.mode.clip.read().as_ref().map(|p|p.read()) {
|
||||
(clip.color, clip.length)
|
||||
} else { (ItemTheme::G[64], 0) };
|
||||
let time_pos = editor.get_time_pos();
|
||||
let time_zoom = editor.get_time_zoom();
|
||||
let time_lock = if editor.get_time_lock() { "[lock]" } else { " " };
|
||||
let note_pos = editor.get_note_pos();
|
||||
let note_name = format!("{:4}", note_pitch_to_name(note_pos));
|
||||
let note_pos = format!("{:>3}", note_pos);
|
||||
let note_len = format!("{:>4}", editor.get_note_len());
|
||||
south!(
|
||||
east(button_2("t", "ime ", false),
|
||||
fg(Rgb(255, 255, 255), format!("{length} /{time_zoom} +{time_pos} ")).origin_e().full_w()).origin_w().full_w(),
|
||||
east(button_2("z", "lock ", false),
|
||||
fg(Rgb(255, 255, 255), format!("{time_lock}")).origin_e().full_w()).origin_w().full_w(),
|
||||
east(button_2("x", "note ", false),
|
||||
fg(Rgb(255, 255, 255), format!("{note_name} {note_pos} {note_len}")).origin_e().full_w()).origin_w().full_w(),
|
||||
).exact_w(20)
|
||||
}
|
||||
|
||||
impl Draw<Tui> for MidiEditor {
|
||||
fn draw (&self, to: &mut Tui) -> Drawn<u16> {
|
||||
self.autoscroll();
|
||||
|
|
@ -1197,18 +1158,66 @@ pub fn view_scene_name <'a> (
|
|||
} else {
|
||||
Scene::DEFAULT_HEIGHT as u16
|
||||
};
|
||||
let a = east!("·s", index, " ", fg(g(255), bold(true, &scene.name))).align_w().full_w();
|
||||
let a = east!("·s", index, " ", fg(g(255), bold(true, &scene.name))).align_nw().full_w();
|
||||
let s = select.scene() == Some(index) && editing;
|
||||
let b = when(s, south(
|
||||
editor.map(view_editor_clip_status),
|
||||
editor.map(view_editor_edit_status)
|
||||
).full_wh().align_se());
|
||||
let b = when(s, south(editor.map(view_clip_info), editor.map(view_edit_info)).full_wh().align_se());
|
||||
let c = if select.scene() == Some(index) {
|
||||
scene.color.light.term
|
||||
} else {
|
||||
scene.color.base.term
|
||||
};
|
||||
bg(c, south(a, b).align_nw().exact_h(h))
|
||||
bg(c, above(a, b.push_y(1)).align_nw().exact_h(h))
|
||||
}
|
||||
|
||||
pub fn view_clip_info (editor: &MidiEditor) -> impl Draw<Tui> + '_ {
|
||||
let (
|
||||
_color, name, length, looped
|
||||
) = if let Some(clip) = editor.mode.clip.read().as_ref().map(|p|p.read()) {
|
||||
(clip.color, clip.name.clone(), clip.length, clip.looped)
|
||||
} else {
|
||||
(ItemTheme::G[64], String::new().into(), 0, false)
|
||||
};
|
||||
south!(
|
||||
south(
|
||||
button_2("f", "name ", false),
|
||||
fg_bg(Rgb(255, 255, 255), Rgb(16, 16, 16), format!("{name} ").origin_e().pad_w(1).full_w())
|
||||
).origin_w().full_w(),
|
||||
east(
|
||||
button_2("l", "ength ", false),
|
||||
fg(Rgb(255, 255, 255), format!("{length} ")).origin_e().full_w()
|
||||
).origin_w().full_w(),
|
||||
east(
|
||||
button_2("r", "epeat ", false),
|
||||
fg(Rgb(255, 255, 255), format!("{looped} ")).origin_e().full_w()
|
||||
).origin_w().full_w(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn view_edit_info (editor: &MidiEditor) -> impl Draw<Tui> + '_ {
|
||||
let (_color, length) = if let Some(clip) = editor.mode.clip.read().as_ref().map(|p|p.read()) {
|
||||
(clip.color, clip.length)
|
||||
} else { (ItemTheme::G[64], 0) };
|
||||
let time_pos = editor.get_time_pos();
|
||||
let time_zoom = editor.get_time_zoom();
|
||||
let time_lock = if editor.get_time_lock() { "[lock]" } else { " " };
|
||||
let note_pos = editor.get_note_pos();
|
||||
let note_name = format!("{:4}", note_pitch_to_name(note_pos));
|
||||
let note_pos = format!("{:>3}", note_pos);
|
||||
let note_len = format!("{:>4}", editor.get_note_len());
|
||||
south!(
|
||||
east(
|
||||
button_2("t", "ime ", false),
|
||||
fg(Rgb(255, 255, 255), format!("{length} /{time_zoom} +{time_pos} ")).origin_e().pad_w(1).full_w()
|
||||
).origin_w().full_w(),
|
||||
east(
|
||||
button_2("z", "lock ", false),
|
||||
fg(Rgb(255, 255, 255), format!("{time_lock}")).origin_e().full_w()
|
||||
).origin_w().full_w(),
|
||||
south(
|
||||
button_2("x", "note ", false),
|
||||
fg_bg(Rgb(255, 255, 255), Rgb(16, 16, 16), format!("{note_name} {note_pos} {note_len}").origin_e().full_w())
|
||||
).origin_w().full_w(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn view_scene_name_theme (scene: &Scene, track_index: usize) -> (Arc<str>, ItemTheme) {
|
||||
|
|
@ -1458,6 +1467,20 @@ pub fn view_wrap <'a> (bg: Color, fg: Color, content: impl Draw<Tui>)
|
|||
east(left, west(right, fg_bg(fg, bg, content)))
|
||||
}
|
||||
|
||||
pub fn redraw_piano (state: &PianoHorizontal) -> BigBuffer {
|
||||
state.clip.map_inner(|clip|{
|
||||
let mut buffer = BigBuffer::from(state.buffer_size(&clip));
|
||||
let time_zoom = state.get_time_zoom().max(1);
|
||||
state.time_len().store(clip.length, Relaxed);
|
||||
let note_len = state.get_note_len();
|
||||
let note_pos = state.get_note_pos();
|
||||
let time_pos = state.get_time_pos();
|
||||
draw_piano_bg(&mut buffer, &clip, time_zoom, note_len, note_pos, time_pos);
|
||||
draw_piano_fg(&mut buffer, &clip, time_zoom);
|
||||
buffer
|
||||
}).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Draw the piano roll background.
|
||||
pub fn draw_piano_bg (
|
||||
buf: &mut BigBuffer,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue