add Measure::of

This commit is contained in:
🪞👃🪞 2025-01-02 14:11:32 +01:00
parent 6b073988c2
commit 5b57f2b998
4 changed files with 21 additions and 54 deletions

View file

@ -65,6 +65,9 @@ impl<E: Engine> Measure<E> {
y: Arc::new(0.into()),
}
}
pub fn of <T: Content<E>> (&self, item: T) -> Bsp<E, Fill<E, &Self>, T> {
Bsp::b(Fill::xy(&self), item)
}
}
///// A scrollable area.

View file

@ -45,7 +45,7 @@ has_size!(<Tui>|self: MidiEditor|&self.size);
render!(Tui: (self: MidiEditor) => {
self.autoscroll();
self.autozoom();
Fill::xy(Tui::bg(Color::Black, Bsp::b(&self.size, &self.mode)))
Fill::xy(Bsp::b(&self.size, &self.mode))
});
impl MidiView<Tui> for MidiEditor {}

View file

@ -11,67 +11,30 @@ render!(Tui: (self: PianoHorizontal) => {
} else {
(ItemPalette::from(TuiTheme::g(64)), String::new(), 0, false)
};
//let field = move|x, y|row!(
//Tui::fg_bg(color.lighter.rgb, color.darker.rgb, Tui::bold(true, x)),
//Tui::fg_bg(color.lighter.rgb, color.dark.rgb, y),
//);
let keys_width = 5;
let keys = move||PianoHorizontalKeys(self);
let timeline = move||PianoHorizontalTimeline(self);
let notes = move||PianoHorizontalNotes(self);
let cursor = move||PianoHorizontalCursor(self);
let status = move||row!(
//" ",
row!("Edit:", name.to_string()), " ",
row!("Length:", length.to_string()), " ",
row!("Loop:", looped.to_string())
let field = move|x, y|row!(
Tui::fg_bg(color.lighter.rgb, color.darker.rgb, Tui::bold(true, x)),
Tui::fg_bg(color.lighter.rgb, color.dark.rgb, y),
);
Bsp::s(
Fixed::y(1, status()),
Fixed::y(1, row!(
field("Edit:", name.to_string()), " ",
field("Length:", length.to_string()), " ",
field("Loop:", looped.to_string())
)),
Bsp::s(
Fixed::y(1, Bsp::e(
Fixed::x(self.keys_width, ""),
Fill::x(timeline()),
Fill::x(PianoHorizontalTimeline(self)),
)),
Fill::xy(Bsp::e(
Fixed::x(self.keys_width, keys()),
Fill::xy("test")
//Fill::xy(lay!(
//&self.size,
//Fill::xy(lay!(
//Fill::xy(notes()),
//Fill::xy(cursor()),
//))
//)),
Fixed::x(self.keys_width, PianoHorizontalKeys(self)),
Fill::xy(self.size.of(lay!(
Fill::xy(PianoHorizontalNotes(self)),
Fill::xy(PianoHorizontalCursor(self)),
))),
)),
)
)
//"kyp"
//Outer(Style::default().fg(self.color.dark.rgb).bg(self.color.darkest.rgb)).enclose("kyp");
//with_border(lay!(
//row!(
////" ",
//field("Edit:", name.to_string()), " ",
//field("Length:", length.to_string()), " ",
//field("Loop:", looped.to_string())
//)),
//Padding::xy(0, 1, Fill::xy(Bsp::s(
//Fixed::y(1, Bsp::e(
//Fixed::x(self.keys_width, ""),
//Fill::x(timeline()),
//)),
//Bsp::e(
//Fixed::x(self.keys_width, keys()),
//Fill::xy(lay!(
//&self.size,
//Fill::xy(lay!(
//Fill::xy(notes()),
//Fill::xy(cursor()),
//))
//)),
//),
//)))
//))
});
impl PianoHorizontal {

View file

@ -5,13 +5,14 @@ pub struct PianoHorizontalNotes<'a>(pub(crate) &'a PianoHorizontal);
render!(Tui: |self: PianoHorizontalNotes<'a>, render|{
let time_start = self.0.time_start().get();
let note_axis = self.0.note_axis().get();
let note_lo = self.0.note_lo().get();
let note_hi = self.0.note_hi();
let note_point = self.0.note_point();
let source = &self.0.buffer;
let [x0, y0, w, h] = render.area().xywh();
if h as usize != self.0.note_axis().get() {
panic!("area height mismatch");
if h as usize != note_axis {
panic!("area height mismatch: {h} <> {note_axis}");
}
for (area_x, screen_x) in (x0..x0+w).enumerate() {
for (area_y, screen_y, note) in note_y_iter(note_lo, note_hi, y0) {