mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
add sample viewer area
This commit is contained in:
parent
df00fedfd6
commit
b63a5e31ba
5 changed files with 50 additions and 8 deletions
|
|
@ -61,6 +61,7 @@ render!(<Tui>|self:GrooveboxTui|{
|
|||
let phrase_w = if w > 60 { 20 } else if w > 40 { 15 } else { 10 };
|
||||
let pool_w = if self.pool.visible { phrase_w } else { 0 };
|
||||
let sampler_w = 11;
|
||||
let note_pt = self.editor.note_point();
|
||||
Fill::wh(lay!([
|
||||
&self.size,
|
||||
Fill::wh(Align::s(Fixed::h(2, GrooveboxStatus::from(self)))),
|
||||
|
|
@ -76,8 +77,20 @@ render!(<Tui>|self:GrooveboxTui|{
|
|||
PhraseSelector::next_phrase(&self.player),
|
||||
]))),
|
||||
row!([
|
||||
Tui::split_n(false, 1,
|
||||
MidiEditStatus(&self.editor),
|
||||
Tui::split_n(false, 5,
|
||||
col!([
|
||||
row!(|add|{
|
||||
if let Some(sample) = &self.sampler.mapped[note_pt] {
|
||||
add(&format!("Sample {}", sample.read().unwrap().end))?;
|
||||
}
|
||||
add(&MidiEditStatus(&self.editor))?;
|
||||
Ok(())
|
||||
}),
|
||||
lay!([
|
||||
Outer(Style::default().fg(TuiTheme::g(128))),
|
||||
Fill::w(Fixed::h(4, SampleViewer(None))),
|
||||
]),
|
||||
]),
|
||||
Tui::split_w(false, pool_w,
|
||||
Tui::pull_y(1, Fill::h(Align::e(PoolView(&self.pool)))),
|
||||
Tui::split_e(false, sampler_w, Fill::wh(col!([
|
||||
|
|
@ -91,12 +104,6 @@ render!(<Tui>|self:GrooveboxTui|{
|
|||
]))
|
||||
});
|
||||
|
||||
struct Meters<'a>(&'a[f32]);
|
||||
render!(<Tui>|self: Meters<'a>|col!([
|
||||
&format!("L/{:>+9.3}", self.0[0]),
|
||||
&format!("R/{:>+9.3}", self.0[1]),
|
||||
]));
|
||||
|
||||
struct GrooveboxSamples<'a>(&'a GrooveboxTui);
|
||||
render!(<Tui>|self: GrooveboxSamples<'a>|{
|
||||
let note_lo = self.0.editor.note_lo().load(Relaxed);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ pub use self::jack::*;
|
|||
|
||||
pub mod midi; pub(crate) use self::midi::*;
|
||||
|
||||
pub mod meter; pub(crate) use self::meter::*;
|
||||
|
||||
pub mod piano_h; pub(crate) use self::piano_h::*;
|
||||
|
||||
pub mod transport; pub(crate) use self::transport::*;
|
||||
|
|
|
|||
8
crates/tek/src/meter.rs
Normal file
8
crates/tek/src/meter.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
use crate::*;
|
||||
|
||||
pub struct Meters<'a>(pub &'a[f32]);
|
||||
|
||||
render!(<Tui>|self: Meters<'a>|col!([
|
||||
&format!("L/{:>+9.3}", self.0[0]),
|
||||
&format!("R/{:>+9.3}", self.0[1]),
|
||||
]));
|
||||
|
|
@ -28,6 +28,10 @@ pub use self::sampler_tui::SamplerTui;
|
|||
pub mod sample_import;
|
||||
pub(crate) use self::sample_import::*;
|
||||
|
||||
pub mod sample_viewer;
|
||||
pub(crate) use self::sample_viewer::*;
|
||||
pub use self::sample_viewer::SampleViewer;
|
||||
|
||||
/// The sampler plugin plays sounds.
|
||||
#[derive(Debug)]
|
||||
pub struct Sampler {
|
||||
|
|
|
|||
21
crates/tek/src/sampler/sample_viewer.rs
Normal file
21
crates/tek/src/sampler/sample_viewer.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
use crate::*;
|
||||
use std::ops::Deref;
|
||||
use ratatui::{prelude::Rect, widgets::{Widget, canvas::{Canvas, Points}}};
|
||||
|
||||
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);
|
||||
Ok(())
|
||||
}));
|
||||
Loading…
Add table
Add a link
Reference in a new issue