mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: tui cleanup
This commit is contained in:
parent
df3dac183e
commit
14d619a10a
17 changed files with 345 additions and 306 deletions
|
|
@ -18,12 +18,12 @@ process!(Sampler = Sampler::process);
|
|||
|
||||
handle!(Sampler |self, event| handle_keymap(self, event, KEYMAP_SAMPLER));
|
||||
|
||||
impl<'a> Render<TuiOutput<'a>, Rect> for Sampler {
|
||||
fn render (&self, to: &mut TuiOutput<'a>) -> Perhaps<Rect> {
|
||||
let Rect { x, y, height, .. } = to.area;
|
||||
impl Render<Tui> for Sampler {
|
||||
fn render (&self, to: &mut Tui) -> Perhaps<Rect> {
|
||||
let Rect { x, y, height, .. } = to.area();
|
||||
let style = Style::default().gray();
|
||||
let title = format!(" {} ({})", self.name, self.voices.read().unwrap().len());
|
||||
title.blit(to.buffer, x+1, y, Some(style.white().bold().not_dim()))?;
|
||||
title.blit(to.buffer(), x+1, y, Some(style.white().bold().not_dim()))?;
|
||||
let mut width = title.len() + 2;
|
||||
let mut y1 = 1;
|
||||
let mut j = 0;
|
||||
|
|
@ -36,13 +36,13 @@ impl<'a> Render<TuiOutput<'a>, Rect> for Sampler {
|
|||
}
|
||||
let active = j == self.cursor.0;
|
||||
width = width.max(
|
||||
draw_sample(to.buffer, x, y + y1, note, &*sample.read().unwrap(), active)?
|
||||
draw_sample(to.buffer(), x, y + y1, note, &*sample.read().unwrap(), active)?
|
||||
);
|
||||
y1 = y1 + 1;
|
||||
j = j + 1;
|
||||
}
|
||||
let height = ((2 + y1) as u16).min(height);
|
||||
Ok(Some(Rect { x, y, width: (width as u16).min(to.area.width), height }))
|
||||
Ok(Some(Rect { x, y, width: (width as u16).min(to.area().width), height }))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ pub const KEYMAP_SAMPLER: &'static [KeyBinding<Sampler>] = keymap!(Sampler {
|
|||
});
|
||||
|
||||
impl Sampler {
|
||||
pub fn from_edn <'e, T, U> (args: &[Edn<'e>]) -> Usually<JackDevice<T, U>> {
|
||||
pub fn from_edn <'e, E> (args: &[Edn<'e>]) -> Usually<JackDevice<E>> {
|
||||
let mut name = String::new();
|
||||
let mut dir = String::new();
|
||||
let mut samples = BTreeMap::new();
|
||||
|
|
@ -134,9 +134,9 @@ impl Sampler {
|
|||
Self::new(&name, Some(samples))
|
||||
}
|
||||
|
||||
pub fn new <T, U> (
|
||||
pub fn new <E> (
|
||||
name: &str, mapped: Option<BTreeMap<u7, Arc<RwLock<Sample>>>>
|
||||
) -> Usually<JackDevice<T, U>> {
|
||||
) -> Usually<JackDevice<E>> {
|
||||
Jack::new(name)?
|
||||
.midi_in("midi")
|
||||
.audio_in("recL")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue