mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +01:00
remove Samplerviewer, SamplerStatus
This commit is contained in:
parent
532b648a9e
commit
a9cad18891
2 changed files with 59 additions and 61 deletions
|
|
@ -124,24 +124,21 @@ render!(TuiOut: (self: SampleList<'a>) => {
|
||||||
}))
|
}))
|
||||||
});
|
});
|
||||||
impl Sampler {
|
impl Sampler {
|
||||||
pub fn viewer (&self, note_pt: usize) -> impl Content<TuiOut> {
|
|
||||||
if let Some((_, sample)) = &self.recording {
|
|
||||||
SampleViewer(Some(sample.clone()))
|
|
||||||
} else if let Some(sample) = &self.mapped[note_pt] {
|
|
||||||
SampleViewer(Some(sample.clone()))
|
|
||||||
} else {
|
|
||||||
SampleViewer(None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const EMPTY: &[(f64, f64)] = &[(0., 0.), (1., 1.), (2., 2.), (0., 2.), (2., 0.)];
|
const EMPTY: &[(f64, f64)] = &[(0., 0.), (1., 1.), (2., 2.), (0., 2.), (2., 0.)];
|
||||||
pub struct SampleViewer(pub Option<Arc<RwLock<Sample>>>);
|
pub fn viewer (&self, note_pt: usize) -> impl Content<TuiOut> {
|
||||||
render!(TuiOut: |self: SampleViewer, to|{
|
let sample = if let Some((_, sample)) = &self.recording {
|
||||||
|
Some(sample.clone())
|
||||||
|
} else if let Some(sample) = &self.mapped[note_pt] {
|
||||||
|
Some(sample.clone())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
let min_db = -40.0;
|
||||||
|
RenderThunk::new(move|to: &mut TuiOut|{
|
||||||
let [x, y, width, height] = to.area();
|
let [x, y, width, height] = to.area();
|
||||||
let area = Rect { x, y, width, height };
|
let area = Rect { x, y, width, height };
|
||||||
let min_db = -40.0;
|
|
||||||
let (x_bounds, y_bounds, lines): ([f64;2], [f64;2], Vec<Line>) =
|
let (x_bounds, y_bounds, lines): ([f64;2], [f64;2], Vec<Line>) =
|
||||||
if let Some(sample) = &self.0 {
|
if let Some(sample) = &sample {
|
||||||
let sample = sample.read().unwrap();
|
let sample = sample.read().unwrap();
|
||||||
let start = sample.start as f64;
|
let start = sample.start as f64;
|
||||||
let end = sample.end as f64;
|
let end = sample.end as f64;
|
||||||
|
|
@ -180,12 +177,13 @@ render!(TuiOut: |self: SampleViewer, to|{
|
||||||
.y_bounds(y_bounds)
|
.y_bounds(y_bounds)
|
||||||
.paint(|ctx| { for line in lines.iter() { ctx.draw(line) } })
|
.paint(|ctx| { for line in lines.iter() { ctx.draw(line) } })
|
||||||
.render(area, &mut to.buffer);
|
.render(area, &mut to.buffer);
|
||||||
});
|
})
|
||||||
|
}
|
||||||
pub struct SamplerStatus<'a>(pub &'a Sampler, pub usize);
|
pub fn status (&self, index: usize) -> impl Content<TuiOut> {
|
||||||
|
Tui::bold(true, Tui::fg(TuiTheme::g(224), self.mapped[index].as_ref().map(|sample|format!(
|
||||||
render!(TuiOut: (self: SamplerStatus<'a>) => Tui::bold(true, Tui::fg(TuiTheme::g(224), self.0.mapped[self.1].as_ref().map(|sample|format!(
|
|
||||||
"Sample {}-{}",
|
"Sample {}-{}",
|
||||||
sample.read().unwrap().start,
|
sample.read().unwrap().start,
|
||||||
sample.read().unwrap().end,
|
sample.read().unwrap().end,
|
||||||
)).unwrap_or_else(||"No sample".to_string()))));
|
)).unwrap_or_else(||"No sample".to_string())))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ impl Groovebox {
|
||||||
let sample_h = if self.compact { 0 } else { 5 };
|
let sample_h = if self.compact { 0 } else { 5 };
|
||||||
Max::y(sample_h, Fill::xy(
|
Max::y(sample_h, Fill::xy(
|
||||||
Bsp::a(
|
Bsp::a(
|
||||||
Fill::x(Align::w(Fixed::y(1, SamplerStatus(&self.sampler, note_pt)))),
|
Fill::x(Align::w(Fixed::y(1, self.sampler.status(note_pt)))),
|
||||||
self.sampler.viewer(note_pt))))
|
self.sampler.viewer(note_pt))))
|
||||||
}
|
}
|
||||||
fn pool_view (&self) -> impl Content<TuiOut> + use<'_> {
|
fn pool_view (&self) -> impl Content<TuiOut> + use<'_> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue