wip: switch piano to Bsp components

This commit is contained in:
🪞👃🪞 2024-12-16 19:13:09 +01:00
parent 6cc81acd70
commit 8861dab9db
2 changed files with 22 additions and 37 deletions

View file

@ -17,15 +17,15 @@ pub enum Bsp<E: Engine, X: Render<E>, Y: Render<E>> {
Null(PhantomData<E>), Null(PhantomData<E>),
} }
render!(|self:Bsp<E: Engine, X: Render<E>, Y: Render<E>>|match self { render!(|self:Bsp<E: Engine, X: Render<E>, Y: Render<E>>|render(|to|{Ok(match self {
Bsp::Null(_) => { () }, Bsp::Null(_) => (),
Bsp::N(a, b) => { todo!("") }, Bsp::N(a, b) => (),
Bsp::S(a, b) => { todo!("") }, Bsp::S(a, b) => (),
Bsp::E(a, b) => { todo!("") }, Bsp::E(a, b) => (),
Bsp::W(a, b) => { todo!("") }, Bsp::W(a, b) => (),
Bsp::A(a, b) => { todo!("") }, Bsp::A(a, b) => (),
Bsp::B(a, b) => { todo!("") }, Bsp::B(a, b) => (),
}); })}));
impl<E: Engine, X: Render<E>, Y: Render<E>> Bsp<E, X, Y> { impl<E: Engine, X: Render<E>, Y: Render<E>> Bsp<E, X, Y> {
pub fn new (x: X) -> Self { Self::A(Some(x), None) } pub fn new (x: X) -> Self { Self::A(Some(x), None) }

View file

@ -48,34 +48,19 @@ render!(|self: PianoHorizontal|{
let time_point = self.point.time_point(); let time_point = self.point.time_point();
let note_point = self.point.note_point(); let note_point = self.point.note_point();
let note_len = self.point.note_len(); let note_len = self.point.note_len();
let timeline = move||PianoHorizontalTimeline { let keys = move||PianoHorizontalKeys { color, note_lo, note_hi, note_point: Some(note_point), };
color, let timeline = move||PianoHorizontalTimeline { color, time_start, time_zoom, };
time_start, let notes = move||PianoHorizontalNotes { source: &self.buffer, time_start, note_hi, };
time_zoom, let cursor = move||PianoHorizontalCursor { time_zoom, time_point, time_start, note_point, note_len, note_hi, note_lo, };
}; let keys_width = 5;
let notes = move||PianoHorizontalNotes { Tui::fill_xy(Tui::bg(bg, Bsp::s(
source: &self.buffer, Tui::fill_x(Tui::push_x(keys_width, timeline())),
time_start, Bsp::w(
note_hi, Tui::shrink_x(keys_width,
}; Tui::fill_x(Tui::debug(lay!([&self.size, notes(), cursor()]))),
let cursor = move||PianoHorizontalCursor { ),
time_zoom, Tui::fixed_x(keys_width, keys())
time_point, ),
time_start,
note_point: note_point,
note_len: note_len,
note_hi: note_hi,
note_lo: note_lo,
};
let keys = move||PianoHorizontalKeys {
color: self.color,
note_lo,
note_hi,
note_point: Some(note_point),
};
Tui::fill_xy(Tui::bg(bg, Tui::split_s(false, 1,
Tui::fill_x(Tui::push_x(5, timeline())),
Tui::split_e(true, 5, Tui::debug(lay!([&self.size, notes(), cursor()])), keys()),
))) )))
}); });