separate input handling for sampler

This commit is contained in:
🪞👃🪞 2025-04-25 20:50:32 +03:00
parent b58fbdfd30
commit b376d75396
11 changed files with 114 additions and 36 deletions

View file

@ -1,10 +1,20 @@
use crate::*;
provide!(Arc<str>: |self: Sampler| {});
provide!(Option<Arc<RwLock<Sample>>>: |self: Sampler| {});
provide!(PathBuf: |self: Sampler| {});
provide!(f32: |self: Sampler| {});
provide!(u7: |self: Sampler| {});
provide!(usize: |self: Sampler| {});
expose! {
[self: Sampler] {
[Arc<str>] => {}
[Option<Arc<RwLock<Sample>>>] => {}
[PathBuf] => {}
[f32] => {}
[u7] => {}
[usize] => {
":sample-up" => 0,
":sample-down" => 0,
":sample-left" => 0,
":sample-right" => 0,
}
}
}
defcom! { |self, state: Sampler|
@ -82,17 +92,13 @@ atom_command!(FileBrowserCommand: |state: Sampler| {
("select" [i: usize] Some(Self::Select(i.expect("no index"))))
("chdir" [p: PathBuf] Some(Self::Chdir(p.expect("no path"))))
("filter" [f: Arc<str>] Some(Self::Filter(f.expect("no filter")))) });
atom_command!(SamplerCommand: |state: Sampler| {
("select" [i: usize]
Some(Self::Select(i.expect("no index"))))
("import" [,..a]
FileBrowserCommand::try_from_expr(state, a).map(Self::Import))
("record/begin" [i: u7]
Some(Self::RecordBegin(i.expect("no index"))))
("record/cancel" []
Some(Self::RecordCancel))
("record/finish" []
Some(Self::RecordFinish))
("import" [,..a] FileBrowserCommand::try_from_expr(state, a).map(Self::Import))
("select" [i: usize] Some(Self::Select(i.expect("no index"))))
("record/begin" [i: u7] Some(Self::RecordBegin(i.expect("no index"))))
("record/cancel" [] Some(Self::RecordCancel))
("record/finish" [] Some(Self::RecordFinish))
("set/sample" [i: u7, s: Option<Arc<RwLock<Sample>>>]
Some(Self::SetSample(i.expect("no index"), s.expect("no sampler"))))
("set/start" [i: u7, s: usize]