This commit is contained in:
🪞👃🪞 2024-12-10 00:10:43 +01:00
parent 43154c486d
commit deb5348c69

View file

@ -28,6 +28,24 @@ pub struct PhraseEditorModel {
pub(crate) view_mode: PhraseViewMode,
}
#[derive(Copy, Clone, Debug)]
pub enum PhraseEditMode {
Note,
Scroll,
}
#[derive(Copy, Clone, Debug)]
pub enum PhraseViewMode {
PianoHorizontal {
time_zoom: usize,
note_zoom: PhraseViewNoteZoom,
},
PianoVertical {
time_zoom: usize,
note_zoom: PhraseViewNoteZoom,
},
}
impl std::fmt::Debug for PhraseEditorModel {
fn fmt (&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
f.debug_struct("PhraseEditorModel")
@ -75,7 +93,7 @@ impl PhraseEditorModel {
let time = self.time_point.load(Ordering::Relaxed);
let note = self.note_point.load(Ordering::Relaxed);
let mut phrase = phrase.write().unwrap();
let key: u7 = u7::from((127 - note) as u8);
let key: u7 = u7::from(note as u8);
let vel: u7 = 100.into();
let start = time;
let end = (start + self.note_len) % phrase.length;
@ -226,12 +244,12 @@ render!(|self: PhraseView<'a>|{
Ok(if to.area().h() >= 2 { view_mode.render_keys(to, *note_hi, *note_lo) })
}))),
Tui::fill_x(lay!([
Tui::push_y(1, Tui::fill_x(render(|to: &mut TuiOutput|{
Tui::push_y(1, Tui::fill_x(Widget::new(|to|Ok(Some(to)), |to: &mut TuiOutput|{
size.set_wh(to.area.w(), to.area.h() as usize - 1);
let draw = to.area().h() >= 2;
Ok(if draw { view_mode.render_notes(to, buffer, *time_start, *note_hi) })
}))),
Tui::push_y(1, render(move|to: &mut TuiOutput|{
Tui::push_y(1, Widget::new(|to|Ok(Some(to)), move|to: &mut TuiOutput|{
Ok(if *focused && *entered {
view_mode.render_cursor(
to,
@ -245,18 +263,6 @@ render!(|self: PhraseView<'a>|{
])
});
#[derive(Copy, Clone, Debug)]
pub enum PhraseViewMode {
PianoHorizontal {
time_zoom: usize,
note_zoom: PhraseViewNoteZoom,
},
PianoVertical {
time_zoom: usize,
note_zoom: PhraseViewNoteZoom,
},
}
#[derive(Copy, Clone, Debug)]
pub enum PhraseViewNoteZoom {
N(usize),
@ -704,9 +710,3 @@ impl Command<PhraseEditorModel> for PhraseCommand {
})
}
}
#[derive(Copy, Clone, Debug)]
pub enum PhraseEditMode {
Note,
Scroll,
}