mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +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]]
|
[[package]]
|
||||||
name = "tengri"
|
name = "tengri"
|
||||||
version = "0.11.0"
|
version = "0.12.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tengri_dsl",
|
"tengri_dsl",
|
||||||
"tengri_input",
|
"tengri_input",
|
||||||
|
|
@ -1610,7 +1610,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_dsl"
|
name = "tengri_dsl"
|
||||||
version = "0.11.0"
|
version = "0.12.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools 0.14.0",
|
"itertools 0.14.0",
|
||||||
"konst",
|
"konst",
|
||||||
|
|
@ -1619,21 +1619,21 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_input"
|
name = "tengri_input"
|
||||||
version = "0.11.0"
|
version = "0.12.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tengri_dsl",
|
"tengri_dsl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_output"
|
name = "tengri_output"
|
||||||
version = "0.11.0"
|
version = "0.12.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tengri_dsl",
|
"tengri_dsl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tengri_tui"
|
name = "tengri_tui"
|
||||||
version = "0.11.0"
|
version = "0.12.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomic_float",
|
"atomic_float",
|
||||||
"better-panic",
|
"better-panic",
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,6 @@ handle!(TuiIn: |self: Tek, input|if let Some(handler) = self.handler {
|
||||||
Ok(None)
|
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> {
|
pub fn handle_arranger (app: &mut Tek, input: &TuiIn) -> Perhaps<bool> {
|
||||||
Ok((app.is_editing() && app.editor.handle(input)? == Some(true) ||
|
Ok((app.is_editing() && app.editor.handle(input)? == Some(true) ||
|
||||||
layer(app, input, include_str!("../../../config/keys_global.edn"))? ||
|
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))
|
layer(app, input, include_str!("../../../config/keys_sampler.edn"))?).then_some(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO:
|
fn layer (app: &mut Tek, input: &TuiIn, keymap: &str) -> Usually<bool> {
|
||||||
//#[derive(Default)]
|
if let Some(command) = SourceIter(keymap).command::<_, TekCommand, _>(app, input) {
|
||||||
//struct Handler<T, U> {
|
if let Some(undo) = command.execute(app)? {
|
||||||
//layers: Vec<(Box<dyn Fn(&T)->bool>, &'static str)>,
|
app.history.push(undo);
|
||||||
//__: std::marker::PhantomData<U>
|
}
|
||||||
//}
|
return Ok(true)
|
||||||
|
}
|
||||||
//impl<T, U: AtomInput> Handler<T, U> {
|
return Ok(false)
|
||||||
//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)
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use crate::*;
|
||||||
pub struct MidiEditor {
|
pub struct MidiEditor {
|
||||||
pub mode: PianoHorizontal,
|
pub mode: PianoHorizontal,
|
||||||
pub size: Measure<TuiOut>,
|
pub size: Measure<TuiOut>,
|
||||||
pub keys: SourceIter<'static>
|
pub keys: InputMap<'static, Self, MidiEditCommand, TuiIn>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for MidiEditor {
|
impl std::fmt::Debug for MidiEditor {
|
||||||
|
|
@ -21,7 +21,8 @@ impl Default for MidiEditor {
|
||||||
Self {
|
Self {
|
||||||
mode: PianoHorizontal::new(None),
|
mode: PianoHorizontal::new(None),
|
||||||
size: Measure::new(),
|
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|{
|
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)?;
|
let _undo = command.execute(self)?;
|
||||||
Some(true)
|
Some(true)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
handle!(TuiIn: |self: MidiPool, input|{
|
handle!(TuiIn: |self: MidiPool, input|{
|
||||||
Ok(if let Some(command) = match self.mode() {
|
//Ok(if let Some(command) = match self.mode() {
|
||||||
Some(PoolMode::Rename(..)) => self.keys_rename,
|
//Some(PoolMode::Rename(..)) => self.keys_rename,
|
||||||
Some(PoolMode::Length(..)) => self.keys_length,
|
//Some(PoolMode::Length(..)) => self.keys_length,
|
||||||
Some(PoolMode::Import(..)) | Some(PoolMode::Export(..)) => self.keys_file,
|
//Some(PoolMode::Import(..)) | Some(PoolMode::Export(..)) => self.keys_file,
|
||||||
_ => self.keys
|
//_ => self.keys
|
||||||
}.command::<Self, PoolCommand, TuiIn>(self, input) {
|
//}.command::<Self, PoolCommand, TuiIn>(self, input) {
|
||||||
|
Ok(if let Some(command) = self.keys.command(self, input) {
|
||||||
let _undo = command.execute(self)?;
|
let _undo = command.execute(self)?;
|
||||||
Some(true)
|
Some(true)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
|
|
||||||
#[derive(Debug)]
|
//#[derive(Debug)]
|
||||||
pub struct MidiPool {
|
pub struct MidiPool {
|
||||||
pub visible: bool,
|
pub visible: bool,
|
||||||
/// Collection of clips
|
/// Collection of clips
|
||||||
|
|
@ -10,23 +10,30 @@ pub struct MidiPool {
|
||||||
/// Mode switch
|
/// Mode switch
|
||||||
pub mode: Option<PoolMode>,
|
pub mode: Option<PoolMode>,
|
||||||
|
|
||||||
pub keys: SourceIter<'static>,
|
pub keys: InputMap<'static, Self, PoolCommand, TuiIn>,
|
||||||
pub keys_rename: SourceIter<'static>,
|
//pub keys: SourceIter<'static>,
|
||||||
pub keys_length: SourceIter<'static>,
|
//pub keys_rename: SourceIter<'static>,
|
||||||
pub keys_file: SourceIter<'static>,
|
//pub keys_length: SourceIter<'static>,
|
||||||
|
//pub keys_file: SourceIter<'static>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MidiPool {
|
impl Default for MidiPool {
|
||||||
fn default () -> Self {
|
fn default () -> Self {
|
||||||
|
use PoolMode::*;
|
||||||
Self {
|
Self {
|
||||||
visible: true,
|
visible: true,
|
||||||
clips: Arc::from(RwLock::from(vec![])),
|
clips: Arc::from(RwLock::from(vec![])),
|
||||||
clip: 0.into(),
|
clip: 0.into(),
|
||||||
mode: None,
|
mode: None,
|
||||||
keys: SourceIter(include_str!("../../../../config/keys_pool.edn")),
|
keys: InputMap::new()
|
||||||
keys_file: SourceIter(include_str!("../../../../config/keys_pool_file.edn")),
|
.layer(
|
||||||
keys_rename: SourceIter(include_str!("../../../../config/keys_clip_rename.edn")),
|
SourceIter(include_str!("../../../../config/keys_edit.edn")))
|
||||||
keys_length: SourceIter(include_str!("../../../../config/keys_clip_length.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