mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
draw x for no sample
This commit is contained in:
parent
b63a5e31ba
commit
f09a6072f8
1 changed files with 18 additions and 11 deletions
|
|
@ -6,16 +6,23 @@ pub struct SampleViewer<'a>(pub Option<&'a Arc<RwLock<Sample>>>);
|
|||
render!(<Tui>|self: SampleViewer<'a>|render(|to|{
|
||||
let [x, y, width, height] = to.area();
|
||||
let area = Rect { x, y, width, height };
|
||||
Canvas::default()
|
||||
.x_bounds([0.0, f64::from(width)])
|
||||
.y_bounds([0.0, f64::from(height)])
|
||||
.paint(|ctx|{
|
||||
ctx.draw(&Points {
|
||||
coords: &[(0., 0.), (1., 2.), (3., 4.)],
|
||||
color: Color::Rgb(255,0,0)
|
||||
})
|
||||
// TODO
|
||||
})
|
||||
.render(area, &mut to.buffer);
|
||||
let (x_bounds, y_bounds, coords): ([f64;2], [f64;2], &[(f64,f64)]) =
|
||||
if let Some(sample) = self.0 {
|
||||
let sample = sample.read().unwrap();
|
||||
(
|
||||
[sample.start as f64, sample.end as f64],
|
||||
[0 as f64, f32::MAX as f64],
|
||||
&[]
|
||||
)
|
||||
} else {
|
||||
(
|
||||
[0.0, f64::from(width)],
|
||||
[0.0, f64::from(height)],
|
||||
&[(0., 0.), (1., 1.), (2., 2.), (0., 2.), (2., 0.)]
|
||||
)
|
||||
};
|
||||
Canvas::default().x_bounds(x_bounds).y_bounds(y_bounds).paint(|ctx|{
|
||||
ctx.draw(&Points { coords, color: Color::Rgb(255,0,0) })
|
||||
}).render(area, &mut to.buffer);
|
||||
Ok(())
|
||||
}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue