wip: simplify and document

This commit is contained in:
i do not exist 2026-07-05 18:46:33 +03:00
parent 701a651fbd
commit b9e7b9732e
12 changed files with 116 additions and 72 deletions

View file

@ -19,12 +19,12 @@ pub struct MidiEditor {
/// View mode and state of editor
pub mode: PianoHorizontal,
/// Size of editor on screen
pub size: Size,
pub size: Sizer,
}
impl_default!(MidiEditor: Self {
mode: PianoHorizontal::new(None),
size: Size(
size: Sizer(
Arc::new(0usize.into()),
Arc::new(0usize.into()),
),
@ -255,13 +255,7 @@ pub trait MidiViewer: MidiRange + MidiPoint + Debug + Send + Sync {
}
}
impl_has!(Size: |self: MidiEditor| self.size);
impl Draw<Tui> for MidiEditor {
fn draw (self, to: &mut Tui) -> Usually<XYWH<u16>> {
self.mode.tui().draw(to)
}
}
impl_has!(Sizer: |self: MidiEditor| self.size);
impl std::fmt::Debug for MidiEditor {
fn fmt (&self, f: &mut Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
@ -303,7 +297,7 @@ impl View<Tui> for MidiEditor {
fn view (&self) -> impl Draw<Tui> {
self.autoscroll();
/*self.autozoom();*/
self.size.of(&self.mode)
self.size.of(self.mode.view())
}
}