mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: big flat pt.12, down to 1 error
This commit is contained in:
parent
b718e54d33
commit
e21ef1af94
9 changed files with 53 additions and 30 deletions
|
|
@ -21,7 +21,7 @@ pub struct AddSampleModal {
|
|||
_search: Option<String>,
|
||||
}
|
||||
|
||||
impl Exit for AddSampleModal {
|
||||
impl AddSampleModal {
|
||||
fn exited (&self) -> bool {
|
||||
self.exited
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,16 +49,10 @@ render!(<Tui>(self: SampleViewer)
|
|||
)
|
||||
};
|
||||
|
||||
let draw = |ctx| {
|
||||
for line in lines.iter() {
|
||||
ctx.draw(line)
|
||||
}
|
||||
};
|
||||
|
||||
Canvas::default()
|
||||
.x_bounds(x_bounds)
|
||||
.y_bounds(y_bounds)
|
||||
.paint(draw)
|
||||
.paint(|ctx| { for line in lines.iter() { ctx.draw(line) } })
|
||||
.render(area, &mut render.buffer);
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -56,25 +56,38 @@ render!(<Tui>|self: SamplerTui|{
|
|||
Tui::fg(self.color.light.rgb, Tui::bold(true, &"Sampler")),
|
||||
with_size(Shrink::y(1, Bsp::e(
|
||||
Fixed::x(keys_width, keys()),
|
||||
Fill::xy(render(|to: &mut TuiOutput|Ok({
|
||||
let x = to.area.x();
|
||||
let bg_base = self.color.darkest.rgb;
|
||||
let bg_selected = self.color.darker.rgb;
|
||||
let style_empty = Style::default().fg(self.color.base.rgb);
|
||||
let style_full = Style::default().fg(self.color.lighter.rgb);
|
||||
let note_hi = self.note_hi();
|
||||
let note_pt = self.note_point();
|
||||
for y in 0..self.size.h() {
|
||||
let note = note_hi - y as usize;
|
||||
let bg = if note == note_pt { bg_selected } else { bg_base };
|
||||
let style = Some(style_empty.bg(bg));
|
||||
to.blit(&" (no sample) ", x, to.area.y() + y as u16, style)
|
||||
}
|
||||
})))
|
||||
Fill::xy(SamplesTui {
|
||||
color: self.color,
|
||||
note_hi: self.note_hi(),
|
||||
note_pt: self.note_point(),
|
||||
height: self.size.h(),
|
||||
}),
|
||||
))),
|
||||
))))
|
||||
});
|
||||
|
||||
struct SamplesTui {
|
||||
color: ItemPalette,
|
||||
note_hi: usize,
|
||||
note_pt: usize,
|
||||
height: usize,
|
||||
}
|
||||
render!(<Tui>(self: SamplesTui)
|
||||
|area|Ok(Some([15, 1])),
|
||||
|render|Ok({
|
||||
let x = render.area.x();
|
||||
let bg_base = self.color.darkest.rgb;
|
||||
let bg_selected = self.color.darker.rgb;
|
||||
let style_empty = Style::default().fg(self.color.base.rgb);
|
||||
let style_full = Style::default().fg(self.color.lighter.rgb);
|
||||
for y in 0..self.height {
|
||||
let note = self.note_hi - y as usize;
|
||||
let bg = if note == self.note_pt { bg_selected } else { bg_base };
|
||||
let style = Some(style_empty.bg(bg));
|
||||
render.blit(&" (no sample) ", x, render.area.y() + y as u16, style)
|
||||
}
|
||||
}));
|
||||
|
||||
impl NoteRange for SamplerTui {
|
||||
fn note_lo (&self) -> &AtomicUsize { &self.note_lo }
|
||||
fn note_axis (&self) -> &AtomicUsize { &self.size.y }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue