mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
This commit is contained in:
parent
3561867640
commit
5696cbbebb
6 changed files with 45 additions and 68 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
|
@ -1600,7 +1600,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tengri"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
dependencies = [
|
||||
"tengri_dsl",
|
||||
"tengri_input",
|
||||
|
|
@ -1610,7 +1610,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tengri_dsl"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
dependencies = [
|
||||
"itertools 0.14.0",
|
||||
"konst",
|
||||
|
|
@ -1619,21 +1619,21 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tengri_input"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
dependencies = [
|
||||
"tengri_dsl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tengri_output"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
dependencies = [
|
||||
"tengri_dsl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tengri_tui"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
dependencies = [
|
||||
"atomic_float",
|
||||
"better-panic",
|
||||
|
|
|
|||
|
|
@ -6,16 +6,6 @@ handle!(TuiIn: |self: Tek, input|if let Some(handler) = self.handler {
|
|||
Ok(None)
|
||||
});
|
||||
|
||||
fn layer (app: &mut Tek, input: &TuiIn, keymap: &str) -> Usually<bool> {
|
||||
if let Some(command) = SourceIter(keymap).command::<_, TekCommand, _>(app, input) {
|
||||
if let Some(undo) = command.execute(app)? {
|
||||
app.history.push(undo);
|
||||
}
|
||||
return Ok(true)
|
||||
}
|
||||
return Ok(false)
|
||||
}
|
||||
|
||||
pub fn handle_arranger (app: &mut Tek, input: &TuiIn) -> Perhaps<bool> {
|
||||
Ok((app.is_editing() && app.editor.handle(input)? == Some(true) ||
|
||||
layer(app, input, include_str!("../../../config/keys_global.edn"))? ||
|
||||
|
|
@ -43,34 +33,12 @@ pub fn handle_sampler (app: &mut Tek, input: &TuiIn) -> Perhaps<bool> {
|
|||
layer(app, input, include_str!("../../../config/keys_sampler.edn"))?).then_some(true))
|
||||
}
|
||||
|
||||
// TODO:
|
||||
//#[derive(Default)]
|
||||
//struct Handler<T, U> {
|
||||
//layers: Vec<(Box<dyn Fn(&T)->bool>, &'static str)>,
|
||||
//__: std::marker::PhantomData<U>
|
||||
//}
|
||||
|
||||
//impl<T, U: AtomInput> Handler<T, U> {
|
||||
//fn layer (mut self, condition: impl Fn(&T)->bool + 'static, keymap: &'static str) -> Self {
|
||||
//self.layers.push((Box::new(condition), keymap));
|
||||
//self
|
||||
//}
|
||||
//fn layer_if (mut self, keymap: &'static str) -> Self {
|
||||
//self.layers.push((Box::new(|_|true), keymap));
|
||||
//self
|
||||
//}
|
||||
//fn handle <'a, C: Command<T> + TryFromAtom<'a, T>> (&self, state: &mut T, input: &U) -> Perhaps<bool> {
|
||||
//for layer in self.layers.iter() {
|
||||
//if !(layer.0)(state) {
|
||||
//continue
|
||||
//}
|
||||
//if let Some(command) = SourceIter(layer.1).command::<_, C, _>(state, input) {
|
||||
//if let Some(undo) = command.execute(state)? {
|
||||
////app.history.push(undo);
|
||||
//}
|
||||
//return Ok(Some(true))
|
||||
//}
|
||||
//}
|
||||
//Ok(None)
|
||||
//}
|
||||
//}
|
||||
fn layer (app: &mut Tek, input: &TuiIn, keymap: &str) -> Usually<bool> {
|
||||
if let Some(command) = SourceIter(keymap).command::<_, TekCommand, _>(app, input) {
|
||||
if let Some(undo) = command.execute(app)? {
|
||||
app.history.push(undo);
|
||||
}
|
||||
return Ok(true)
|
||||
}
|
||||
return Ok(false)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use crate::*;
|
|||
pub struct MidiEditor {
|
||||
pub mode: PianoHorizontal,
|
||||
pub size: Measure<TuiOut>,
|
||||
pub keys: SourceIter<'static>
|
||||
pub keys: InputMap<'static, Self, MidiEditCommand, TuiIn>
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for MidiEditor {
|
||||
|
|
@ -21,7 +21,8 @@ impl Default for MidiEditor {
|
|||
Self {
|
||||
mode: PianoHorizontal::new(None),
|
||||
size: Measure::new(),
|
||||
keys: SourceIter(include_str!("../../../../config/keys_edit.edn")),
|
||||
keys: InputMap::new()
|
||||
.layer(SourceIter(include_str!("../../../../config/keys_edit.edn"))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -206,7 +207,7 @@ atom_command!(MidiEditCommand: |state: MidiEditor| {
|
|||
}
|
||||
|
||||
handle!(TuiIn: |self: MidiEditor, input|{
|
||||
Ok(if let Some(command) = self.keys.command::<_, MidiEditCommand, _>(self, input) {
|
||||
Ok(if let Some(command) = self.keys.command(self, input) {
|
||||
let _undo = command.execute(self)?;
|
||||
Some(true)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
use crate::*;
|
||||
|
||||
handle!(TuiIn: |self: MidiPool, input|{
|
||||
Ok(if let Some(command) = match self.mode() {
|
||||
Some(PoolMode::Rename(..)) => self.keys_rename,
|
||||
Some(PoolMode::Length(..)) => self.keys_length,
|
||||
Some(PoolMode::Import(..)) | Some(PoolMode::Export(..)) => self.keys_file,
|
||||
_ => self.keys
|
||||
}.command::<Self, PoolCommand, TuiIn>(self, input) {
|
||||
//Ok(if let Some(command) = match self.mode() {
|
||||
//Some(PoolMode::Rename(..)) => self.keys_rename,
|
||||
//Some(PoolMode::Length(..)) => self.keys_length,
|
||||
//Some(PoolMode::Import(..)) | Some(PoolMode::Export(..)) => self.keys_file,
|
||||
//_ => self.keys
|
||||
//}.command::<Self, PoolCommand, TuiIn>(self, input) {
|
||||
Ok(if let Some(command) = self.keys.command(self, input) {
|
||||
let _undo = command.execute(self)?;
|
||||
Some(true)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
//#[derive(Debug)]
|
||||
pub struct MidiPool {
|
||||
pub visible: bool,
|
||||
/// Collection of clips
|
||||
|
|
@ -10,23 +10,30 @@ pub struct MidiPool {
|
|||
/// Mode switch
|
||||
pub mode: Option<PoolMode>,
|
||||
|
||||
pub keys: SourceIter<'static>,
|
||||
pub keys_rename: SourceIter<'static>,
|
||||
pub keys_length: SourceIter<'static>,
|
||||
pub keys_file: SourceIter<'static>,
|
||||
pub keys: InputMap<'static, Self, PoolCommand, TuiIn>,
|
||||
//pub keys: SourceIter<'static>,
|
||||
//pub keys_rename: SourceIter<'static>,
|
||||
//pub keys_length: SourceIter<'static>,
|
||||
//pub keys_file: SourceIter<'static>,
|
||||
}
|
||||
|
||||
impl Default for MidiPool {
|
||||
fn default () -> Self {
|
||||
use PoolMode::*;
|
||||
Self {
|
||||
visible: true,
|
||||
clips: Arc::from(RwLock::from(vec![])),
|
||||
clip: 0.into(),
|
||||
mode: None,
|
||||
keys: SourceIter(include_str!("../../../../config/keys_pool.edn")),
|
||||
keys_file: SourceIter(include_str!("../../../../config/keys_pool_file.edn")),
|
||||
keys_rename: SourceIter(include_str!("../../../../config/keys_clip_rename.edn")),
|
||||
keys_length: SourceIter(include_str!("../../../../config/keys_clip_length.edn")),
|
||||
clips: Arc::from(RwLock::from(vec![])),
|
||||
clip: 0.into(),
|
||||
mode: None,
|
||||
keys: InputMap::new()
|
||||
.layer(
|
||||
SourceIter(include_str!("../../../../config/keys_edit.edn")))
|
||||
.layer_if(|pool: &Self|matches!(pool.mode, Some(Import(..))|Some(Export(..))),
|
||||
SourceIter(include_str!("../../../../config/keys_pool_file.edn")))
|
||||
.layer_if(|pool: &Self|matches!(pool.mode, Some(Rename(..))),
|
||||
SourceIter(include_str!("../../../../config/keys_clip_rename.edn")))
|
||||
.layer_if(|pool: &Self|matches!(pool.mode, Some(Length(..))),
|
||||
SourceIter(include_str!("../../../../config/keys_clip_length.edn")))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
deps/tengri
vendored
2
deps/tengri
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 95149b79c4b0d013dcba1eda80e1d14a01087fea
|
||||
Subproject commit 35ad37120554611197c1e30bbed657f310d332c3
|
||||
Loading…
Add table
Add a link
Reference in a new issue