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

@ -11,7 +11,7 @@ pub struct PianoHorizontal {
/// Buffer where the whole clip is rerendered on change
pub buffer: Arc<RwLock<BigBuffer>>,
/// Size of actual notes area
pub size: Size,
pub size: Sizer,
/// The display window
pub range: MidiSelection,
/// The note cursor
@ -22,17 +22,21 @@ pub struct PianoHorizontal {
pub keys_width: u16,
}
impl_has!(Size: |self: PianoHorizontal| self.size);
impl Draw<Tui> for PianoHorizontal {
fn draw (self, to: &mut Tui) -> Usually<XYWH<u16>> {
self.tui().draw(to)
impl_has!(Sizer: |self: PianoHorizontal| self.size);
impl View<Tui> for PianoHorizontal {
fn view (&self) -> impl Draw<Tui> {
south(
east(w_exact(5, format!("{}x{}", self.size.w(), self.size.h())), self.timeline()),
east(self.keys(), self.size.of(below(wh_full(self.notes()), wh_full(self.cursor())))),
)
}
}
impl PianoHorizontal {
pub fn new (clip: Option<&Arc<RwLock<MidiClip>>>) -> Self {
let size = Size::default();
let size = Sizer::default();
let mut range = MidiSelection::from((12, true));
range.time_axis = size.0.clone();
range.note_axis = size.1.clone();
@ -49,13 +53,6 @@ impl PianoHorizontal {
piano
}
pub fn tui (&self) -> impl Draw<Tui> {
south(
east(w_exact(5, format!("{}x{}", self.size.w(), self.size.h())), self.timeline()),
east(self.keys(), self.size.of(below(wh_full(self.notes()), wh_full(self.cursor())))),
)
}
/// Draw the piano roll background.
///
/// This mode uses full blocks on note on and half blocks on legato: █▄ █▄ █▄