wip: use only Dsl trait
Some checks failed
/ build (push) Has been cancelled

This commit is contained in:
🪞👃🪞 2025-05-19 00:06:31 +03:00
parent 99d9da6ffd
commit fc038dbd97
10 changed files with 71 additions and 89 deletions

View file

@ -11,6 +11,13 @@ impl Arrangement {
}
}
dsl!(TrackCommand: |self: Arrangement, iter|self.take(iter));
dsl!(MidiInputCommand: |self: Arrangement, iter|self.take(iter));
dsl!(MidiOutputCommand: |self: Arrangement, iter|self.take(iter));
dsl!(DeviceCommand: |self: Arrangement, iter|self.take(iter));
dsl!(SceneCommand: |self: Arrangement, iter|self.take(iter));
dsl!(ClipCommand: |self: Arrangement, iter|self.take(iter));
#[tengri_proc::command(Arrangement)]
impl ArrangementCommand {
fn home (arranger: &mut Arrangement) -> Perhaps<Self> {
@ -243,39 +250,3 @@ impl ArrangementCommand {
todo!()
}
}
impl<'state> Context<'state, TrackCommand> for Arrangement {
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<TrackCommand> {
Context::get(&self, iter)
}
}
impl<'state> Context<'state, MidiInputCommand> for Arrangement {
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<MidiInputCommand> {
Context::get(&self, iter)
}
}
impl<'state> Context<'state, MidiOutputCommand> for Arrangement {
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<MidiOutputCommand> {
Context::get(&self, iter)
}
}
impl<'state> Context<'state, DeviceCommand> for Arrangement {
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<DeviceCommand> {
Context::get(&self, iter)
}
}
impl<'state> Context<'state, SceneCommand> for Arrangement {
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<SceneCommand> {
Context::get(&self, iter)
}
}
impl<'state> Context<'state, ClipCommand> for Arrangement {
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<ClipCommand> {
Context::get(&self, iter)
}
}

View file

@ -2,8 +2,47 @@ use crate::*;
#[tengri_proc::command(Option<Dialog>)]
impl DialogCommand {
fn dismiss (dialog: &mut Option<Dialog>) -> Perhaps<Self> {
fn open (dialog: &mut Option<Dialog>, new: Dialog) -> Perhaps<Self> {
*dialog = Some(new);
Ok(None)
}
fn close (dialog: &mut Option<Dialog>) -> Perhaps<Self> {
*dialog = None;
Ok(None)
}
}
//#[derive(Clone, Debug)]
//pub enum DialogCommand {
//Open { dialog: Dialog },
//Close
//}
//impl Command<Option<Dialog>> for DialogCommand {
//fn execute (self, state: &mut Option<Dialog>) -> Perhaps<Self> {
//match self {
//Self::Open { dialog } => {
//*state = Some(dialog);
//},
//Self::Close => {
//*state = None;
//}
//};
//Ok(None)
//}
//}
//dsl!(DialogCommand: |self: Dialog, iter|todo!());
//Dsl::take(&mut self.dialog, iter));
//#[tengri_proc::command(Option<Dialog>)]//Nope.
//impl DialogCommand {
//fn open (dialog: &mut Option<Dialog>, new: Dialog) -> Perhaps<Self> {
//*dialog = Some(new);
//Ok(None)
//}
//fn close (dialog: &mut Option<Dialog>) -> Perhaps<Self> {
//*dialog = None;
//Ok(None)
//}
//}

View file

@ -81,11 +81,8 @@ impl PoolCommand {
}
impl<'state> Context<'state, BrowserCommand> for Pool {
fn get <'source> (&'state self, iter: &mut TokenIter<'source>) -> Option<BrowserCommand> {
self.browser.as_ref().map(|p|Context::get(p, iter)).flatten()
}
}
dsl!(BrowserCommand: |self: Pool, iter|Ok(self.browser
.as_ref().map(|p|p.take(iter)).transpose()?.flatten()));
#[tengri_proc::command(Pool)]
impl PoolClipCommand {