diff --git a/crates/tek/src/layout/bsp.rs b/crates/tek/src/layout/bsp.rs index 4b0b255f..af3ac295 100644 --- a/crates/tek/src/layout/bsp.rs +++ b/crates/tek/src/layout/bsp.rs @@ -42,6 +42,11 @@ impl, Y: Render> Render for Bsp { let b = b.min_size(to)?.unwrap_or([0.into(), 0.into()].into()); [a.w().max(b.w()), a.h() + b.h()].into() }, + Self::E(a, b) => { + let a = a.min_size(to)?.unwrap_or([0.into(), 0.into()].into()); + let b = b.min_size(to)?.unwrap_or([0.into(), 0.into()].into()); + [a.w() + b.w(), a.h().max(b.h())].into() + }, Self::W(a, b) => { let a = a.min_size(to)?.unwrap_or([0.into(), 0.into()].into()); let b = b.min_size(to)?.unwrap_or([0.into(), 0.into()].into()); @@ -62,6 +67,15 @@ impl, Y: Render> Render for Bsp { to.render_in(to.area().clip_h(s_y).into(), a)?; to.render_in(to.area().push_y(s_y).shrink_y(s_y).into(), b)?; }, + Self::E(a, b) => { + let n = [0.into(), 0.into()].into(); + 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); + let s_x = s_a.w().into(); + to.render_in(to.area().clip_w(s_x).into(), a)?; + to.render_in(to.area().push_x(s_x).shrink_x(s_x).into(), b)?; + }, Self::W(a, b) => { let n = [0.into(), 0.into()].into(); let s = to.area().wh().into(); diff --git a/crates/tek/src/tui/app_sequencer.rs b/crates/tek/src/tui/app_sequencer.rs index cc1bf7e3..94679b86 100644 --- a/crates/tek/src/tui/app_sequencer.rs +++ b/crates/tek/src/tui/app_sequencer.rs @@ -169,7 +169,7 @@ render!(|self: SequencerTui|{ let pool = Tui::fill_y(Tui::at_e(PhraseListView(&self.phrases))); let with_pool = move|x|Tui::split_w(false, pool_w, pool, x); let with_status = |x|Tui::split_n(false, 2, SequencerStatusBar::from(self), x); - let with_editbar = |x|x;//Tui::split_n(false, 3, PhraseEditStatus(&self.editor), x); + let with_editbar = |x|Tui::split_n(false, 3, PhraseEditStatus(&self.editor), x); let with_size = |x|lay!([self.size, x]); let editor = with_editbar(with_pool(Tui::fill_xy(&self.editor))); let color = self.player.play_phrase().as_ref().map(|(_,p)|p.as_ref().map(|p|p.read().unwrap().color)).flatten().clone(); diff --git a/crates/tek/src/tui/piano_horizontal.rs b/crates/tek/src/tui/piano_horizontal.rs index f55b07f3..a89483ac 100644 --- a/crates/tek/src/tui/piano_horizontal.rs +++ b/crates/tek/src/tui/piano_horizontal.rs @@ -66,26 +66,29 @@ render!(|self: PianoHorizontal|{ let notes = move||PianoHorizontalNotes(&self); let cursor = move||PianoHorizontalCursor(&self); let keys_width = 5; - Tui::fill_xy(Tui::bg(color.darker.rgb, Bsp::s( - Tui::fixed_y(1, Tui::fill_x(Tui::push_x(keys_width, timeline()))), - Bsp::w( - Tui::shrink_x(keys_width, Tui::fill_xy( - lay!([&self.size, Tui::fill_xy(lay!([ + Tui::fill_xy(Tui::bg(color.darker.rgb, + Bsp::s( + Tui::fixed_y(1, Bsp::e( + Tui::fixed_x(keys_width, ""), + Tui::fill_x(timeline()), + )), + Bsp::e( + Tui::fixed_x(keys_width, keys()), + Tui::fill_xy(lay!([&self.size, Tui::fill_xy(lay!([ Tui::fill_xy(notes()), Tui::fill_xy(cursor()), - ]))]) - )), - Tui::fixed_x(keys_width, keys()) - ), - ))) + ]))])), + ), + ) + )) }); pub struct PianoHorizontalTimeline<'a>(&'a PianoHorizontal); -render!(|self: PianoHorizontalTimeline<'a>|Tui::fixed_y(1, Tui::fg_bg( +render!(|self: PianoHorizontalTimeline<'a>|Tui::fg_bg( self.0.color.lightest.rgb, self.0.color.darkest.rgb, format!("{}*{}", self.0.time_start(), self.0.time_zoom()).as_str() -))); +)); pub struct PianoHorizontalKeys<'a>(&'a PianoHorizontal); render!(|self: PianoHorizontalKeys<'a>|render(|to|Ok({ @@ -108,16 +111,16 @@ render!(|self: PianoHorizontalKeys<'a>|render(|to|Ok({ to.blit(&to_note_name(note), x, screen_y, off_style) }; } - let debug = false; - 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!("w={w}"), x, y0+3, None); - to.blit(&format!("h={h}"), x, y0+4, None); - to.blit(&format!("note_lo={note_lo}"), x, y0+5, None); - to.blit(&format!("note_hi={note_hi}"), x, y0+6, None); - } + //let debug = false; + //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!("w={w}"), x, y0+3, None); + //to.blit(&format!("h={h}"), x, y0+4, None); + //to.blit(&format!("note_lo={note_lo}"), x, y0+5, None); + //to.blit(&format!("note_hi={note_hi}"), x, y0+6, None); + //} }))); pub struct PianoHorizontalCursor<'a>(&'a PianoHorizontal); @@ -164,52 +167,35 @@ render!(|self: PianoHorizontalNotes<'a>|render(|to|Ok({ } 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) { - if area_x % 10 == 0 { - to.blit(&format!("{area_y} {note}"), screen_x, screen_y, None); + //if area_x % 10 == 0 { + //to.blit(&format!("{area_y} {note}"), screen_x, screen_y, None); + //} + let source_x = time_start + area_x; + let source_y = note_hi - area_y; + ////// TODO: enable loop rollover: + //////let source_x = (time_start + area_x) % source.width.max(1); + //////let source_y = (note_hi - area_y) % source.height.max(1); + let is_in_x = source_x < source.width; + let is_in_y = source_y < source.height; + if is_in_x && is_in_y { + if let Some(source_cell) = source.get(source_x, source_y) { + *to.buffer.get_mut(screen_x, screen_y) = source_cell.clone(); + } } } - - //for (area_y, screen_y) in (y0..=y0+h).enumerate() { - //if note_hi < area_y { - //continue - //} - //if note_hi > 127 { - //continue - //} - //let note = note_hi - area_y; - //if area_x % 4 == 0 { - //to.blit(&format!("{note}"), screen_x, screen_y, None); - //} - ////if y >= note_hi { - ////break - ////} - ////let source_x = time_start + x; - ////let source_y = note_hi - y; - ////// TODO: enable loop rollover: - //////let source_x = (time_start + x) % source.width.max(1); - //////let source_y = (note_hi - y) % source.height.max(1); - ////let in_x = source_x < source.width; - ////let in_y = source_y < source.height; - ////if in_x && in_y { - ////let output_cell = to.buffer.get_mut(screen_x, screen_y); - ////if let Some(source_cell) = source.get(source_x, source_y) { - //*output_cell = source_cell.clone(); - ////} - ////} - //} - } - let debug = true; - if debug { - let x0=20+x0; - to.blit(&format!("KYP "), x0, y0, None); - to.blit(&format!("x0={x0} "), x0, y0+1, None); - to.blit(&format!("y0={y0} "), x0, y0+2, None); - to.blit(&format!("note_lo={note_lo}, {} ", to_note_name(note_lo)), x0, y0+3, None); - to.blit(&format!("note_hi={note_hi}, {} ", to_note_name(note_hi)), x0, y0+4, None); - to.blit(&format!("note_point={note_point}, {} ", to_note_name(note_point)), x0, y0+5, None); - to.blit(&format!("time_start={time_start} "), x0, y0+6, None); - return Ok(()); } + //let debug = true; + //if debug { + //let x0=20+x0; + //to.blit(&format!("KYP "), x0, y0, None); + //to.blit(&format!("x0={x0} "), x0, y0+1, None); + //to.blit(&format!("y0={y0} "), x0, y0+2, None); + //to.blit(&format!("note_lo={note_lo}, {} ", to_note_name(note_lo)), x0, y0+3, None); + //to.blit(&format!("note_hi={note_hi}, {} ", to_note_name(note_hi)), x0, y0+4, None); + //to.blit(&format!("note_point={note_point}, {} ", to_note_name(note_point)), x0, y0+5, None); + //to.blit(&format!("time_start={time_start} "), x0, y0+6, None); + //return Ok(()); + //} }))); impl PianoHorizontal {