mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
wip: borrow checker battles
This commit is contained in:
parent
1d4db3c629
commit
7fbb40fad6
38 changed files with 778 additions and 708 deletions
|
|
@ -19,11 +19,11 @@ 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>) -> Usually<Rect> {
|
||||
let Rect { x, y, height, .. } = area;
|
||||
fn render (&self, to: &mut TuiOutput<'a>) -> 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(buf, 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;
|
||||
|
|
@ -35,12 +35,14 @@ impl<'a> Render<TuiOutput<'a>, Rect> for Sampler {
|
|||
break
|
||||
}
|
||||
let active = j == self.cursor.0;
|
||||
width = width.max(draw_sample(buf, x, y + y1, note, &*sample.read().unwrap(), active)?);
|
||||
width = width.max(
|
||||
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(Rect { x, y, width: (width as u16).min(area.width), height })
|
||||
Ok(Some(Rect { x, y, width: (width as u16).min(to.area.width), height }))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +105,7 @@ pub const KEYMAP_SAMPLER: &'static [KeyBinding<Sampler>] = keymap!(Sampler {
|
|||
});
|
||||
|
||||
impl Sampler {
|
||||
pub fn from_edn <'e> (args: &[Edn<'e>]) -> Usually<JackDevice> {
|
||||
pub fn from_edn <'e, T, U> (args: &[Edn<'e>]) -> Usually<JackDevice<T, U>> {
|
||||
let mut name = String::new();
|
||||
let mut dir = String::new();
|
||||
let mut samples = BTreeMap::new();
|
||||
|
|
@ -132,7 +134,9 @@ impl Sampler {
|
|||
Self::new(&name, Some(samples))
|
||||
}
|
||||
|
||||
pub fn new (name: &str, mapped: Option<BTreeMap<u7, Arc<RwLock<Sample>>>>) -> Usually<JackDevice> {
|
||||
pub fn new <T, U> (
|
||||
name: &str, mapped: Option<BTreeMap<u7, Arc<RwLock<Sample>>>>
|
||||
) -> Usually<JackDevice<T, U>> {
|
||||
Jack::new(name)?
|
||||
.midi_in("midi")
|
||||
.audio_in("recL")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue