mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
compiles again
This commit is contained in:
parent
34070de5f7
commit
1434adae09
21 changed files with 654 additions and 591 deletions
|
|
@ -2,28 +2,31 @@ use crate::*;
|
|||
|
||||
impl Sampler {
|
||||
|
||||
pub fn view_grid (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
pub fn view_grid (&self) -> impl Draw<TuiOut> + Layout<TuiOut> + use<'_> {
|
||||
let cells_x = 8u16;
|
||||
let cells_y = 8u16;
|
||||
let cell_width = 10u16;
|
||||
let cell_height = 2u16;
|
||||
//let width = cells_x * cell_width;
|
||||
//let height = cells_y * cell_height;
|
||||
let cols = Map::east(
|
||||
cell_width,
|
||||
move||0..cells_x,
|
||||
move|x, _|Map::south(
|
||||
cell_height,
|
||||
move||0..cells_y,
|
||||
move|y, _|self.view_grid_cell("........", x, y, cell_width, cell_height)
|
||||
)
|
||||
);
|
||||
cols
|
||||
//let cols = Map::east(
|
||||
//cell_width,
|
||||
//move||0..cells_x,
|
||||
//move|x, _|Map::south(
|
||||
//cell_height,
|
||||
//move||0..cells_y,
|
||||
//move|y, _|self.view_grid_cell("........", x, y, cell_width, cell_height)
|
||||
//)
|
||||
//);
|
||||
//cols
|
||||
//Thunk::new(|to: &mut TuiOut|{
|
||||
//})
|
||||
"TODO"
|
||||
}
|
||||
|
||||
pub fn view_grid_cell <'a> (
|
||||
&'a self, name: &'a str, x: u16, y: u16, w: u16, h: u16
|
||||
) -> impl Content<TuiOut> + use<'a> {
|
||||
) -> impl Draw<TuiOut> + use<'a> {
|
||||
let cursor = self.cursor();
|
||||
let hi_fg = Color::Rgb(64, 64, 64);
|
||||
let hi_bg = if y == 0 { Color::Reset } else { Color::Rgb(64, 64, 64) /*prev*/ };
|
||||
|
|
@ -55,7 +58,7 @@ impl Sampler {
|
|||
|
||||
pub fn view_list <'a, T: NotePoint + NoteRange> (
|
||||
&'a self, compact: bool, editor: &T
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
) -> impl Draw<TuiOut> + 'a {
|
||||
let note_lo = editor.get_note_lo();
|
||||
let note_pt = editor.get_note_pos();
|
||||
let note_hi = editor.get_note_hi();
|
||||
|
|
@ -97,7 +100,7 @@ impl Sampler {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn view_sample (&self, note_pt: usize) -> impl Content<TuiOut> + use<'_> {
|
||||
pub fn view_sample (&self, note_pt: usize) -> impl Draw<TuiOut> + use<'_> {
|
||||
Outer(true, Style::default().fg(Tui::g(96)))
|
||||
.enclose(Fill::xy(draw_viewer(if let Some((_, Some(sample))) = &self.recording {
|
||||
Some(sample)
|
||||
|
|
@ -108,7 +111,7 @@ impl Sampler {
|
|||
})))
|
||||
}
|
||||
|
||||
pub fn view_sample_info (&self, note_pt: usize) -> impl Content<TuiOut> + use<'_> {
|
||||
pub fn view_sample_info (&self, note_pt: usize) -> impl Draw<TuiOut> + use<'_> {
|
||||
Fill::x(Fixed::y(1, draw_info(if let Some((_, Some(sample))) = &self.recording {
|
||||
Some(sample)
|
||||
} else if let Some(sample) = &self.mapped[note_pt] {
|
||||
|
|
@ -118,7 +121,7 @@ impl Sampler {
|
|||
})))
|
||||
}
|
||||
|
||||
pub fn view_sample_status (&self, note_pt: usize) -> impl Content<TuiOut> + use<'_> {
|
||||
pub fn view_sample_status (&self, note_pt: usize) -> impl Draw<TuiOut> + use<'_> {
|
||||
Fixed::x(20, draw_info_v(if let Some((_, Some(sample))) = &self.recording {
|
||||
Some(sample)
|
||||
} else if let Some(sample) = &self.mapped[note_pt] {
|
||||
|
|
@ -128,20 +131,20 @@ impl Sampler {
|
|||
}))
|
||||
}
|
||||
|
||||
pub fn view_status (&self, index: usize) -> impl Content<TuiOut> {
|
||||
pub fn view_status (&self, index: usize) -> impl Draw<TuiOut> {
|
||||
draw_status(self.mapped[index].as_ref())
|
||||
}
|
||||
|
||||
pub fn view_meters_input (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
pub fn view_meters_input (&self) -> impl Draw<TuiOut> + use<'_> {
|
||||
draw_meters(&self.input_meters)
|
||||
}
|
||||
|
||||
pub fn view_meters_output (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
pub fn view_meters_output (&self) -> impl Draw<TuiOut> + use<'_> {
|
||||
draw_meters(&self.output_meters)
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_meters (meters: &[f32]) -> impl Content<TuiOut> + use<'_> {
|
||||
fn draw_meters (meters: &[f32]) -> impl Draw<TuiOut> + use<'_> {
|
||||
Tui::bg(Black, Fixed::x(2, Map::east(1, ||meters.iter(), |value, _index|{
|
||||
Fill::y(RmsMeter(*value))
|
||||
})))
|
||||
|
|
@ -163,9 +166,9 @@ fn draw_list_item (sample: &Option<Arc<RwLock<Sample>>>) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
fn draw_viewer (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + use<'_> {
|
||||
fn draw_viewer (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<TuiOut> + Layout<TuiOut> + use<'_> {
|
||||
let min_db = -64.0;
|
||||
ThunkRender::new(move|to: &mut TuiOut|{
|
||||
Thunk::new(move|to: &mut TuiOut|{
|
||||
let [x, y, width, height] = to.area();
|
||||
let area = Rect { x, y, width, height };
|
||||
if let Some(sample) = &sample {
|
||||
|
|
@ -218,41 +221,41 @@ fn draw_viewer (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> +
|
|||
})
|
||||
}
|
||||
|
||||
fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + use<'_> {
|
||||
When(sample.is_some(), Thunk::new(move||{
|
||||
fn draw_info (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<TuiOut> + Layout<TuiOut> + use<'_> {
|
||||
When(sample.is_some(), Thunk::new(move|to: &mut TuiOut|{
|
||||
let sample = sample.unwrap().read().unwrap();
|
||||
let theme = sample.color;
|
||||
row!(
|
||||
to.place(&row!(
|
||||
FieldH(theme, "Name", format!("{:<10}", sample.name.clone())),
|
||||
FieldH(theme, "Length", format!("{:<8}", sample.channels[0].len())),
|
||||
FieldH(theme, "Start", format!("{:<8}", sample.start)),
|
||||
FieldH(theme, "End", format!("{:<8}", sample.end)),
|
||||
FieldH(theme, "Trans", "0"),
|
||||
FieldH(theme, "Gain", format!("{}", sample.gain)),
|
||||
)
|
||||
))
|
||||
}))
|
||||
}
|
||||
|
||||
fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> + use<'_> {
|
||||
Either(sample.is_some(), Thunk::new(move||{
|
||||
fn draw_info_v (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<TuiOut> + Layout<TuiOut> + use<'_> {
|
||||
Either::new(sample.is_some(), Thunk::new(move|to: &mut TuiOut|{
|
||||
let sample = sample.unwrap().read().unwrap();
|
||||
let theme = sample.color;
|
||||
Fixed::x(20, col!(
|
||||
to.place(&Fixed::x(20, col!(
|
||||
Fill::x(Align::w(FieldH(theme, "Name ", format!("{:<10}", sample.name.clone())))),
|
||||
Fill::x(Align::w(FieldH(theme, "Length", format!("{:<8}", sample.channels[0].len())))),
|
||||
Fill::x(Align::w(FieldH(theme, "Start ", format!("{:<8}", sample.start)))),
|
||||
Fill::x(Align::w(FieldH(theme, "End ", format!("{:<8}", sample.end)))),
|
||||
Fill::x(Align::w(FieldH(theme, "Trans ", "0"))),
|
||||
Fill::x(Align::w(FieldH(theme, "Gain ", format!("{}", sample.gain)))),
|
||||
))
|
||||
}), Thunk::new(move||Tui::fg(Red, col!(
|
||||
)))
|
||||
}), Thunk::new(|to: &mut TuiOut|to.place(&Tui::fg(Red, col!(
|
||||
Tui::bold(true, "× No sample."),
|
||||
"[r] record",
|
||||
"[Shift-F9] import",
|
||||
))))
|
||||
)))))
|
||||
}
|
||||
|
||||
fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Content<TuiOut> {
|
||||
fn draw_status (sample: Option<&Arc<RwLock<Sample>>>) -> impl Draw<TuiOut> + Layout<TuiOut> {
|
||||
Tui::bold(true, Tui::fg(Tui::g(224), sample
|
||||
.map(|sample|{
|
||||
let sample = sample.read().unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue