mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
wip: modularize tek_mixer
This commit is contained in:
parent
bc679ef8bd
commit
11e6529465
11 changed files with 396 additions and 390 deletions
|
|
@ -104,49 +104,6 @@ impl<E: Engine> Sampler<E> {
|
|||
}
|
||||
}
|
||||
}
|
||||
impl Handle<Tui> for Sampler<Tui> {
|
||||
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
||||
match from.event() {
|
||||
key!(KeyCode::Up) => {
|
||||
self.cursor.0 = if self.cursor.0 == 0 {
|
||||
self.mapped.len() + self.unmapped.len() - 1
|
||||
} else {
|
||||
self.cursor.0 - 1
|
||||
};
|
||||
Ok(Some(true))
|
||||
},
|
||||
key!(KeyCode::Down) => {
|
||||
self.cursor.0 = (self.cursor.0 + 1) % (self.mapped.len() + self.unmapped.len());
|
||||
Ok(Some(true))
|
||||
},
|
||||
key!(KeyCode::Char('p')) => {
|
||||
if let Some(sample) = self.sample() {
|
||||
self.voices.write().unwrap().push(Sample::play(sample, 0, &100.into()));
|
||||
}
|
||||
Ok(Some(true))
|
||||
},
|
||||
key!(KeyCode::Char('a')) => {
|
||||
let sample = Arc::new(RwLock::new(Sample::new("", 0, 0, vec![])));
|
||||
*self.modal.lock().unwrap() = Some(Exit::boxed(AddSampleModal::new(&sample, &self.voices)?));
|
||||
self.unmapped.push(sample);
|
||||
Ok(Some(true))
|
||||
},
|
||||
key!(KeyCode::Char('r')) => {
|
||||
if let Some(sample) = self.sample() {
|
||||
*self.modal.lock().unwrap() = Some(Exit::boxed(AddSampleModal::new(&sample, &self.voices)?));
|
||||
}
|
||||
Ok(Some(true))
|
||||
},
|
||||
key!(KeyCode::Enter) => {
|
||||
if let Some(sample) = self.sample() {
|
||||
self.editing = Some(sample.clone());
|
||||
}
|
||||
Ok(Some(true))
|
||||
}
|
||||
_ => Ok(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for Sampler<Tui> {
|
||||
type Engine = Tui;
|
||||
|
|
@ -326,14 +283,6 @@ impl Widget for AddSampleModal {
|
|||
}
|
||||
}
|
||||
|
||||
impl Handle<Tui> for AddSampleModal {
|
||||
fn handle (&mut self, from: &TuiInput) -> Perhaps<bool> {
|
||||
if from.handle_keymap(self, KEYMAP_ADD_SAMPLE)? {
|
||||
return Ok(Some(true))
|
||||
}
|
||||
Ok(Some(true))
|
||||
}
|
||||
}
|
||||
|
||||
impl AddSampleModal {
|
||||
pub fn new (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue