mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
wip: fix note range
This commit is contained in:
parent
41f17bb0e7
commit
ccb4a01a29
2 changed files with 35 additions and 18 deletions
|
|
@ -58,8 +58,9 @@ impl<E: Engine, X: Render<E>, Y: Render<E>> Render<E> for Bsp<E, X, Y> {
|
|||
let s = to.area().wh().into();
|
||||
let s_a = a.min_size(s)?.unwrap_or(n);
|
||||
let s_b = b.min_size(s)?.unwrap_or(n);
|
||||
to.render_in(to.area().clip(s_a).into(), a)?;
|
||||
to.render_in(to.area().push_y(s_a.h().into()).into(), b)?;
|
||||
let s_y = s_a.h().into();
|
||||
to.render_in(to.area().clip_h(s_y).into(), a)?;
|
||||
to.render_in(to.area().push_y(s_y).into(), b)?;
|
||||
},
|
||||
Self::W(a, b) => {
|
||||
let n = [0.into(), 0.into()].into();
|
||||
|
|
|
|||
|
|
@ -48,7 +48,9 @@ render!(|self: PianoHorizontal|{
|
|||
let time_point = self.point.time_point();
|
||||
let note_point = self.point.note_point();
|
||||
let note_len = self.point.note_len();
|
||||
let keys = move||PianoHorizontalKeys { color, note_lo, note_hi, note_point: Some(note_point), };
|
||||
let range = &self.range;
|
||||
let point = &self.point;
|
||||
let keys = move||PianoHorizontalKeys { color, range, point }; //note_lo, note_hi, note_point: Some(note_point), };
|
||||
let timeline = move||PianoHorizontalTimeline { color, time_start, time_zoom, };
|
||||
let notes = move||PianoHorizontalNotes { source: &self.buffer, time_start, note_hi, };
|
||||
let cursor = move||PianoHorizontalCursor { time_zoom, time_point, time_start, note_point, note_len, note_hi, note_lo, };
|
||||
|
|
@ -56,9 +58,9 @@ render!(|self: PianoHorizontal|{
|
|||
Tui::fill_xy(Tui::bg(bg, Bsp::s(
|
||||
Tui::fill_x(Tui::push_x(keys_width, timeline())),
|
||||
Bsp::w(
|
||||
Tui::shrink_x(keys_width,
|
||||
Tui::fill_x(Tui::debug(lay!([&self.size, notes(), cursor()]))),
|
||||
),
|
||||
Tui::shrink_x(keys_width, Tui::fill_xy(
|
||||
lay!([&self.size, Tui::debug(Tui::fill_xy(lay!([notes(), cursor()])))])
|
||||
)),
|
||||
Tui::fixed_x(keys_width, keys())
|
||||
),
|
||||
)))
|
||||
|
|
@ -75,18 +77,32 @@ render!(|self: PianoHorizontalTimeline|Tui::fg_bg(
|
|||
format!("{}*{}", self.time_start, self.time_zoom).as_str()
|
||||
));
|
||||
|
||||
pub struct PianoHorizontalKeys {
|
||||
color: ItemPalette,
|
||||
note_lo: usize,
|
||||
note_hi: usize,
|
||||
note_point: Option<usize>,
|
||||
pub struct PianoHorizontalKeys<'a> {
|
||||
color: ItemPalette,
|
||||
range: &'a MidiRangeModel,
|
||||
point: &'a MidiPointModel,
|
||||
}
|
||||
render!(|self: PianoHorizontalKeys|render(|to|Ok({
|
||||
let [x, y0, _, _] = to.area().xywh();
|
||||
let key_style = Some(Style::default().fg(Color::Rgb(192, 192, 192)).bg(Color::Rgb(0, 0, 0)));
|
||||
let off_style = Some(Style::default().fg(TuiTheme::g(160)));
|
||||
let on_style = Some(Style::default().fg(TuiTheme::g(255)).bg(self.color.light.rgb).bold());
|
||||
for (y, note) in (self.note_lo..self.note_hi).rev().enumerate().map(|(y, n)|(y0 + y as u16, n)) {
|
||||
render!(|self: PianoHorizontalKeys<'a>|render(|to|Ok({
|
||||
let color = self.color;
|
||||
let note_lo = self.range.note_lo();
|
||||
let note_hi = self.range.note_hi();
|
||||
let note_point = self.point.note_point();
|
||||
let [x, y0, ..] = to.area().xywh();
|
||||
let key_style = Some(Style::default().fg(Color::Rgb(192, 192, 192)).bg(Color::Rgb(0, 0, 0)));
|
||||
let off_style = Some(Style::default().fg(TuiTheme::g(160)));
|
||||
let on_style = Some(Style::default().fg(TuiTheme::g(255)).bg(self.color.light.rgb).bold());
|
||||
|
||||
let debug = true;
|
||||
if debug {
|
||||
to.blit(&format!("XYU"), x, y0, None);
|
||||
to.blit(&format!("x={x}"), x, y0+1, None);
|
||||
to.blit(&format!("y0={y0}"), x, y0+2, None);
|
||||
to.blit(&format!("note_lo={note_lo}"), x, y0+3, None);
|
||||
to.blit(&format!("note_hi={note_hi}"), x, y0+4, None);
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
for (y, note) in (note_lo..note_hi).rev().enumerate().map(|(y, n)|(y0 + y as u16, n)) {
|
||||
let key = match note % 12 {
|
||||
11 => "████▌",
|
||||
10 => " ",
|
||||
|
|
@ -104,7 +120,7 @@ render!(|self: PianoHorizontalKeys|render(|to|Ok({
|
|||
};
|
||||
to.blit(&key, x, y, key_style);
|
||||
|
||||
if Some(note) == self.note_point {
|
||||
if note == note_point {
|
||||
to.blit(&format!("{:<5}", to_note_name(note)), x, y, on_style)
|
||||
} else {
|
||||
to.blit(&to_note_name(note), x, y, off_style)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue