mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
update all to use TuiOutput; still slow?
This commit is contained in:
parent
bb7d215ba1
commit
f5fbc11b24
21 changed files with 873 additions and 888 deletions
|
|
@ -203,12 +203,13 @@ impl Widget for Sequencer<Tui> {
|
|||
fn layout (&self, area: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
todo!()
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
self.horizontal_draw(to)?;
|
||||
if self.focused && self.entered {
|
||||
Corners(Style::default().green().not_dim()).draw(to)?;
|
||||
}
|
||||
Ok(Some(to.area()))
|
||||
//Ok(Some(to.area()))
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -404,7 +405,7 @@ impl Sequencer<Tui> {
|
|||
|
||||
const H_KEYS_OFFSET: usize = 5;
|
||||
|
||||
pub(crate) fn horizontal_draw <'a> (&self, to: &mut Tui) -> Usually<()> {
|
||||
pub(crate) fn horizontal_draw <'a> (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
let area = to.area();
|
||||
Split::down(|add|{
|
||||
add(&SequenceName(&self))?;
|
||||
|
|
@ -451,13 +452,13 @@ impl<'a> Widget for SequenceName<'a> {
|
|||
fn layout (&self, area: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
todo!()
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
let [x, y, ..] = to.area();
|
||||
let frame = [x, y, 10, 4];
|
||||
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?;
|
||||
to.blit(&"Name:", x + 1, y + 1, STYLE_LABEL)?;
|
||||
to.blit(&*self.0.name.read().unwrap(), x + 1, y + 2, STYLE_VALUE)?;
|
||||
Ok(Some(frame))
|
||||
to.blit(&"Name:", x + 1, y + 1, STYLE_LABEL);
|
||||
to.blit(&*self.0.name.read().unwrap(), x + 1, y + 2, STYLE_VALUE);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -468,15 +469,15 @@ impl Widget for SequenceRange {
|
|||
fn layout (&self, area: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
todo!()
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
let [x, y, ..] = to.area();
|
||||
let frame = [x, y, 10, 6];
|
||||
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(frame))?;
|
||||
to.blit(&"Start: ", x + 1, y + 1, STYLE_LABEL)?;
|
||||
to.blit(&" 1.1.1", x + 1, y + 2, STYLE_VALUE)?;
|
||||
to.blit(&"End: ", x + 1, y + 3, STYLE_LABEL)?;
|
||||
to.blit(&" 2.1.1", x + 1, y + 4, STYLE_VALUE)?;
|
||||
Ok(Some(frame))
|
||||
to.blit(&"Start: ", x + 1, y + 1, STYLE_LABEL);
|
||||
to.blit(&" 1.1.1", x + 1, y + 2, STYLE_VALUE);
|
||||
to.blit(&"End: ", x + 1, y + 3, STYLE_LABEL);
|
||||
to.blit(&" 2.1.1", x + 1, y + 4, STYLE_VALUE);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -487,16 +488,16 @@ impl Widget for SequenceLoopRange {
|
|||
fn layout (&self, area: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
todo!()
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
let [x, y, ..] = to.area();
|
||||
let range = [x, y, 10, 7];
|
||||
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?;
|
||||
to.blit(&"Loop [ ]", x + 1, y + 1, STYLE_LABEL)?;
|
||||
to.blit(&"From: ", x + 1, y + 2, STYLE_LABEL)?;
|
||||
to.blit(&" 1.1.1", x + 1, y + 3, STYLE_VALUE)?;
|
||||
to.blit(&"Length: ", x + 1, y + 4, STYLE_LABEL)?;
|
||||
to.blit(&" 1.0.0", x + 1, y + 5, STYLE_VALUE)?;
|
||||
Ok(Some(range))
|
||||
to.blit(&"Loop [ ]", x + 1, y + 1, STYLE_LABEL);
|
||||
to.blit(&"From: ", x + 1, y + 2, STYLE_LABEL);
|
||||
to.blit(&" 1.1.1", x + 1, y + 3, STYLE_VALUE);
|
||||
to.blit(&"Length: ", x + 1, y + 4, STYLE_LABEL);
|
||||
to.blit(&" 1.0.0", x + 1, y + 5, STYLE_VALUE);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -507,18 +508,18 @@ impl Widget for SequenceNoteRange {
|
|||
fn layout (&self, area: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
todo!()
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
let [x, y, ..] = to.area();
|
||||
let range = [x, y, 10, 9];
|
||||
Lozenge(Style::default().fg(Nord::BG2)).draw(to.with_rect(range))?;
|
||||
to.blit(&"Notes: ", x + 1, y + 1, STYLE_LABEL)?;
|
||||
to.blit(&"C#0-C#9 ", x + 1, y + 2, STYLE_VALUE)?;
|
||||
to.blit(&"[ /2 ]", x + 1, y + 3, STYLE_LABEL)?;
|
||||
to.blit(&"[ x2 ]", x + 1, y + 4, STYLE_LABEL)?;
|
||||
to.blit(&"[ Rev ]", x + 1, y + 5, STYLE_LABEL)?;
|
||||
to.blit(&"[ Inv ]", x + 1, y + 6, STYLE_LABEL)?;
|
||||
to.blit(&"[ Dup ]", x + 1, y + 7, STYLE_LABEL)?;
|
||||
Ok(Some(to.area()))
|
||||
to.blit(&"Notes: ", x + 1, y + 1, STYLE_LABEL);
|
||||
to.blit(&"C#0-C#9 ", x + 1, y + 2, STYLE_VALUE);
|
||||
to.blit(&"[ /2 ]", x + 1, y + 3, STYLE_LABEL);
|
||||
to.blit(&"[ x2 ]", x + 1, y + 4, STYLE_LABEL);
|
||||
to.blit(&"[ Rev ]", x + 1, y + 5, STYLE_LABEL);
|
||||
to.blit(&"[ Inv ]", x + 1, y + 6, STYLE_LABEL);
|
||||
to.blit(&"[ Dup ]", x + 1, y + 7, STYLE_LABEL);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -529,19 +530,19 @@ impl<'a> Widget for SequenceKeys<'a> {
|
|||
fn layout (&self, area: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
todo!()
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
let area = to.area();
|
||||
if area.h() < 2 {
|
||||
return Ok(Some(area))
|
||||
return Ok(())
|
||||
}
|
||||
let area = [area.x(), area.y() + 1, 5, area.h() - 2];
|
||||
buffer_update(to.buffer(), area, &|cell, x, y|{
|
||||
to.buffer_update(area, &|cell, x, y|{
|
||||
let y = y + self.0.note_axis.start as u16;
|
||||
if x < self.0.keys.area.width && y < self.0.keys.area.height {
|
||||
*cell = self.0.keys.get(x, y).clone()
|
||||
}
|
||||
});
|
||||
Ok(Some(area))
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -552,10 +553,10 @@ impl<'a> Widget for SequenceNotes<'a> {
|
|||
fn layout (&self, area: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
todo!()
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
let area = to.area();
|
||||
if area.h() < 2 {
|
||||
return Ok(Some(area))
|
||||
return Ok(())//Some(area))
|
||||
}
|
||||
let area = [
|
||||
area.x() + Sequencer::H_KEYS_OFFSET as u16,
|
||||
|
|
@ -574,7 +575,7 @@ impl<'a> Widget for SequenceNotes<'a> {
|
|||
});
|
||||
}
|
||||
});
|
||||
Ok(Some(area))
|
||||
Ok(())//Some(area))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -585,15 +586,17 @@ impl<'a> Widget for SequenceCursor<'a> {
|
|||
fn layout (&self, area: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
todo!()
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
let area = to.area();
|
||||
if let (Some(time), Some(note)) = (self.0.time_axis.point, self.0.note_axis.point) {
|
||||
let x = area.x() + Sequencer::H_KEYS_OFFSET as u16 + time as u16;
|
||||
let y = area.y() + 1 + note as u16 / 2;
|
||||
let c = if note % 2 == 0 { "▀" } else { "▄" };
|
||||
to.blit(&c, x, y, self.0.style_focus())
|
||||
to.blit(&c, x, y, self.0.style_focus());
|
||||
Ok(())
|
||||
} else {
|
||||
Ok(Some([0,0,0,0]))
|
||||
//Ok(Some([0,0,0,0]))
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -605,12 +608,13 @@ impl<'a> Widget for SequenceZoom<'a> {
|
|||
fn layout (&self, area: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
todo!()
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
let area = to.area();
|
||||
let quant = ppq_to_name(self.0.time_axis.scale);
|
||||
let quant_x = area.x() + area.w() - 1 - quant.len() as u16;
|
||||
let quant_y = area.y() + area.h() - 2;
|
||||
to.blit(&quant, quant_x, quant_y, self.0.style_focus())
|
||||
to.blit(&quant, quant_x, quant_y, self.0.style_focus());
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -621,7 +625,7 @@ impl<'a> Widget for SequenceTimer<'a> {
|
|||
fn layout (&self, area: [u16;2]) -> Perhaps<[u16;2]> {
|
||||
todo!()
|
||||
}
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<[u16;4]> {
|
||||
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||
let area = to.area();
|
||||
let phrase = self.1.read().unwrap();
|
||||
let (time0, time_z, now) = (
|
||||
|
|
@ -634,9 +638,10 @@ impl<'a> Widget for SequenceTimer<'a> {
|
|||
let step = (time0 + x2) * time_z;
|
||||
let next_step = (time0 + x2 + 1) * time_z;
|
||||
let style = Sequencer::<Tui>::style_timer_step(now, step as usize, next_step as usize);
|
||||
to.blit(&"-", x as u16, area.y(), Some(style))?;
|
||||
to.blit(&"-", x as u16, area.y(), Some(style));
|
||||
}
|
||||
return Ok(Some([area.x(), area.y(), area.w(), 1]))
|
||||
//return Ok(Some([area.x(), area.y(), area.w(), 1]))
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue