mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
groovebox: reenable sample list
This commit is contained in:
parent
7af98b7008
commit
d88f4e33eb
6 changed files with 94 additions and 78 deletions
|
|
@ -103,3 +103,47 @@
|
|||
//gain: 1.0
|
||||
//}))))
|
||||
//});
|
||||
|
||||
//content!(TuiOut: |self: Sampler| {
|
||||
//let keys_width = 5;
|
||||
//let keys = move||"";//SamplerKeys(self);
|
||||
//let fg = self.color.base.rgb;
|
||||
//let bg = self.color.darkest.rgb;
|
||||
//let border = Fill::xy(Outer(true, Style::default().fg(fg).bg(bg)));
|
||||
//let with_border = |x|lay!(border, Fill::xy(x));
|
||||
//let with_size = |x|lay!(self.size.clone(), x);
|
||||
//Tui::bg(bg, Fill::xy(with_border(Bsp::s(
|
||||
//Tui::fg(self.color.light.rgb, Tui::bold(true, &"Sampler")),
|
||||
//with_size(Shrink::y(1, Bsp::e(
|
||||
//Fixed::x(keys_width, keys()),
|
||||
//Fill::xy(SamplesTui {
|
||||
//color: self.color,
|
||||
//note_hi: self.note_hi(),
|
||||
//note_pt: self.note_pos(),
|
||||
//height: self.size.h(),
|
||||
//}),
|
||||
//))),
|
||||
//))))
|
||||
//});
|
||||
|
||||
//struct SamplesTui {
|
||||
//color: ItemPalette,
|
||||
//note_hi: usize,
|
||||
//note_pt: usize,
|
||||
//height: usize,
|
||||
//}
|
||||
|
||||
//render!(TuiOut: |self: SamplesTui, to| {
|
||||
//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);
|
||||
//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));
|
||||
//to.blit(&" (no sample) ", x, to.area.y() + y as u16, style);
|
||||
//}
|
||||
//});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::*;
|
||||
|
||||
impl Sampler {
|
||||
|
||||
pub fn view_grid (&self) -> impl Content<TuiOut> + use<'_> {
|
||||
let cells_x = 8u16;
|
||||
let cells_y = 8u16;
|
||||
|
|
@ -19,6 +20,7 @@ impl Sampler {
|
|||
);
|
||||
cols
|
||||
}
|
||||
|
||||
pub fn view_grid_cell <'a> (
|
||||
&'a self, name: &'a str, x: u16, y: u16, w: u16, h: u16
|
||||
) -> impl Content<TuiOut> + use<'a> {
|
||||
|
|
@ -48,58 +50,18 @@ impl Sampler {
|
|||
),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
content!(TuiOut: |self: Sampler| {
|
||||
let keys_width = 5;
|
||||
let keys = move||"";//SamplerKeys(self);
|
||||
let fg = self.color.base.rgb;
|
||||
let bg = self.color.darkest.rgb;
|
||||
let border = Fill::xy(Outer(true, Style::default().fg(fg).bg(bg)));
|
||||
let with_border = |x|lay!(border, Fill::xy(x));
|
||||
let with_size = |x|lay!(self.size.clone(), x);
|
||||
Tui::bg(bg, Fill::xy(with_border(Bsp::s(
|
||||
Tui::fg(self.color.light.rgb, Tui::bold(true, &"Sampler")),
|
||||
with_size(Shrink::y(1, Bsp::e(
|
||||
Fixed::x(keys_width, keys()),
|
||||
Fill::xy(SamplesTui {
|
||||
color: self.color,
|
||||
note_hi: self.note_hi(),
|
||||
note_pt: self.note_pos(),
|
||||
height: self.size.h(),
|
||||
}),
|
||||
))),
|
||||
))))
|
||||
});
|
||||
|
||||
struct SamplesTui {
|
||||
color: ItemPalette,
|
||||
note_hi: usize,
|
||||
note_pt: usize,
|
||||
height: usize,
|
||||
}
|
||||
|
||||
render!(TuiOut: |self: SamplesTui, to| {
|
||||
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);
|
||||
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));
|
||||
to.blit(&" (no sample) ", x, to.area.y() + y as u16, style);
|
||||
}
|
||||
});
|
||||
|
||||
impl Sampler {
|
||||
const _EMPTY: &[(f64, f64)] = &[(0., 0.), (1., 1.), (2., 2.), (0., 2.), (2., 0.)];
|
||||
pub fn list <'a> (&'a self, compact: bool, editor: &MidiEditor) -> impl Content<TuiOut> + 'a {
|
||||
|
||||
pub fn view_list <'a> (
|
||||
&'a self,
|
||||
compact: bool,
|
||||
editor: &MidiEditor
|
||||
) -> impl Content<TuiOut> + 'a {
|
||||
let note_lo = editor.note_lo().load(Relaxed);
|
||||
let note_pt = editor.note_pos();
|
||||
let note_hi = editor.note_hi();
|
||||
Outer(true, Style::default().fg(Tui::g(96))).enclose(Map::new(
|
||||
Fixed::x(16, Map::new(
|
||||
move||(note_lo..=note_hi).rev(),
|
||||
move|note, i| {
|
||||
let offset = |a|Push::y(i as u16, Align::n(Fixed::y(1, Fill::x(a))));
|
||||
|
|
@ -116,10 +78,10 @@ impl Sampler {
|
|||
fg = Color::Rgb(224,64,32)
|
||||
}
|
||||
}
|
||||
offset(Tui::fg_bg(fg, bg, format!("{note:3} {}", self.list_item(note, compact))))
|
||||
offset(Tui::fg_bg(fg, bg, format!("{note:3} {}", self.view_list_item(note, compact))))
|
||||
}))
|
||||
}
|
||||
pub fn list_item (&self, note: usize, compact: bool) -> String {
|
||||
pub fn view_list_item (&self, note: usize, compact: bool) -> String {
|
||||
if compact {
|
||||
String::default()
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue