From cc94b3485edfd3eca28e5a47a5909df12fe0c429 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Sat, 26 Apr 2025 18:02:11 +0300 Subject: [PATCH] enable menu modal --- crates/app/src/api.rs | 152 ++++++++++++++++-------------------------- 1 file changed, 58 insertions(+), 94 deletions(-) diff --git a/crates/app/src/api.rs b/crates/app/src/api.rs index 32c69b16..6142c754 100644 --- a/crates/app/src/api.rs +++ b/crates/app/src/api.rs @@ -40,70 +40,48 @@ expose!([self: Tek] { impose!([app: Tek] { TekCommand => { - ("help" [] - Some(Self::ToggleHelp)) - ("stop" [] - Some(Self::StopAll)) - ("undo" [d: usize] - Some(Self::History(-(d.unwrap_or(0)as isize)))) - ("redo" [d: usize] - Some(Self::History(d.unwrap_or(0) as isize))) - ("zoom" [z: usize] - Some(Self::Zoom(z))) - ("edit" [] - Some(Self::Edit(None))) - ("edit" [c: bool] - Some(Self::Edit(c))) - ("color" [] - Some(Self::Color(ItemPalette::random()))) - ("color" [c: Color] - Some(Self::Color(c.map(ItemPalette::from).expect("no color")))) - ("enqueue" [c: Arc>] - Some(Self::Enqueue(c))) - ("launch" [] - Some(Self::Launch)) - ("clip" [,..a] - ClipCommand::try_from_expr(app, a).map(Self::Clip)) - ("clock" [,..a] - ClockCommand::try_from_expr(app.clock(), a).map(Self::Clock)) - ("editor" [,..a] - MidiEditCommand::try_from_expr(app.editor.as_ref().expect("no editor"), a).map(Self::Editor)) - ("pool" [,..a] - PoolCommand::try_from_expr(app.pool.as_ref().expect("no pool"), a).map(Self::Pool)) + ("menu" [] Some(Self::ToggleMenu)) + ("help" [] Some(Self::ToggleHelp)) + ("stop" [] Some(Self::StopAll)) + ("undo" [d: usize] Some(Self::History(-(d.unwrap_or(0)as isize)))) + ("redo" [d: usize] Some(Self::History(d.unwrap_or(0) as isize))) + ("zoom" [z: usize] Some(Self::Zoom(z))) + ("edit" [] Some(Self::Edit(None))) + ("edit" [c: bool] Some(Self::Edit(c))) + ("color" [] Some(Self::Color(ItemPalette::random()))) + ("color" [c: Color] Some(Self::Color(c.map(ItemPalette::from).expect("no color")))) + ("enqueue" [c: Arc>] Some(Self::Enqueue(c))) + ("launch" [] Some(Self::Launch)) + ("scene" [,..a] SceneCommand::try_from_expr(app, a).map(Self::Scene)) + ("track" [,..a] TrackCommand::try_from_expr(app, a).map(Self::Track)) + ("input" [,..a] InputCommand::try_from_expr(app, a).map(Self::Input)) + ("output" [,..a] OutputCommand::try_from_expr(app, a).map(Self::Output)) + ("select" [t: Selection] Some(t.map(Self::Select).expect("no selection"))) + ("clip" [,..a] ClipCommand::try_from_expr(app, a) + .map(Self::Clip)) + ("clock" [,..a] ClockCommand::try_from_expr(app.clock(), a) + .map(Self::Clock)) + ("editor" [,..a] MidiEditCommand::try_from_expr(app.editor.as_ref().expect("no editor"), a) + .map(Self::Editor)) + ("pool" [,..a] PoolCommand::try_from_expr(app.pool.as_ref().expect("no pool"), a) + .map(Self::Pool)) + ("select" [t: usize, s: usize] Some(match (t.expect("no track"), s.expect("no scene")) { + (0, 0) => Self::Select(Selection::Mix), + (t, 0) => Self::Select(Selection::Track(t)), + (0, s) => Self::Select(Selection::Scene(s)), + (t, s) => Self::Select(Selection::Clip(t, s)), + })) //("sampler" [,..a] // Self::Sampler( //SamplerCommand::try_from_expr(app.sampler().as_ref().expect("no sampler"), a).expect("invalid command"))) - ("scene" [,..a] - SceneCommand::try_from_expr(app, a).map(Self::Scene)) - ("track" [,..a] - TrackCommand::try_from_expr(app, a).map(Self::Track)) - ("input" [,..a] - InputCommand::try_from_expr(app, a).map(Self::Input)) - ("output" [,..a] - OutputCommand::try_from_expr(app, a).map(Self::Output)) - ("select" [t: Selection] - Some(t.map(Self::Select).expect("no selection"))) - ("select" [t: usize, s: usize] - Some(match (t.expect("no track"), s.expect("no scene")) { - (0, 0) => Self::Select(Selection::Mix), - (t, 0) => Self::Select(Selection::Track(t)), - (0, s) => Self::Select(Selection::Scene(s)), - (t, s) => Self::Select(Selection::Clip(t, s)), - })) } ClipCommand => { - ("get" [a: usize, b: usize] - Some(Self::Get(a.unwrap(), b.unwrap()))) - ("put" [a: usize, b: usize, c: Option>>] - Some(Self::Put(a.unwrap(), b.unwrap(), c.unwrap()))) - ("enqueue" [a: usize, b: usize] - Some(Self::Enqueue(a.unwrap(), b.unwrap()))) - ("edit" [a: Option>>] - Some(Self::Edit(a.unwrap()))) - ("loop" [a: usize, b: usize, c: bool] - Some(Self::SetLoop(a.unwrap(), b.unwrap(), c.unwrap()))) - ("color" [a: usize, b: usize] - Some(Self::SetColor(a.unwrap(), b.unwrap(), ItemPalette::random()))) + ("get" [a: usize, b: usize] Some(Self::Get(a.unwrap(), b.unwrap()))) + ("put" [a: usize, b: usize, c: Option>>] Some(Self::Put(a.unwrap(), b.unwrap(), c.unwrap()))) + ("enqueue" [a: usize, b: usize] Some(Self::Enqueue(a.unwrap(), b.unwrap()))) + ("edit" [a: Option>>] Some(Self::Edit(a.unwrap()))) + ("loop" [a: usize, b: usize, c: bool] Some(Self::SetLoop(a.unwrap(), b.unwrap(), c.unwrap()))) + ("color" [a: usize, b: usize] Some(Self::SetColor(a.unwrap(), b.unwrap(), ItemPalette::random()))) } InputCommand => { @@ -115,43 +93,26 @@ impose!([app: Tek] { } SceneCommand => { - ("add" [] - Some(Self::Add)) - ("del" [a: usize] - Some(Self::Del(0))) - ("zoom" [a: usize] - Some(Self::SetZoom(a.unwrap()))) - ("color" [a: usize] - Some(Self::SetColor(a.unwrap(), ItemPalette::G[128]))) - ("enqueue" [a: usize] - Some(Self::Enqueue(a.unwrap()))) - ("swap" [a: usize, b: usize] - Some(Self::Swap(a.unwrap(), b.unwrap()))) + ("add" [] Some(Self::Add)) + ("del" [a: usize] Some(Self::Del(0))) + ("zoom" [a: usize] Some(Self::SetZoom(a.unwrap()))) + ("color" [a: usize] Some(Self::SetColor(a.unwrap(), ItemPalette::G[128]))) + ("enqueue" [a: usize] Some(Self::Enqueue(a.unwrap()))) + ("swap" [a: usize, b: usize] Some(Self::Swap(a.unwrap(), b.unwrap()))) } TrackCommand => { - ("add" [] - Some(Self::Add)) - ("size" [a: usize] - Some(Self::SetSize(a.unwrap()))) - ("zoom" [a: usize] - Some(Self::SetZoom(a.unwrap()))) - ("color" [a: usize] - Some(Self::SetColor(a.unwrap(), ItemPalette::random()))) - ("del" [a: usize] - Some(Self::Del(a.unwrap()))) - ("stop" [a: usize] - Some(Self::Stop(a.unwrap()))) - ("swap" [a: usize, b: usize] - Some(Self::Swap(a.unwrap(), b.unwrap()))) - ("play" [] - Some(Self::TogglePlay)) - ("solo" [] - Some(Self::ToggleSolo)) - ("rec" [] - Some(Self::ToggleRecord)) - ("mon" [] - Some(Self::ToggleMonitor)) + ("add" [] Some(Self::Add)) + ("size" [a: usize] Some(Self::SetSize(a.unwrap()))) + ("zoom" [a: usize] Some(Self::SetZoom(a.unwrap()))) + ("color" [a: usize] Some(Self::SetColor(a.unwrap(), ItemPalette::random()))) + ("del" [a: usize] Some(Self::Del(a.unwrap()))) + ("stop" [a: usize] Some(Self::Stop(a.unwrap()))) + ("swap" [a: usize, b: usize] Some(Self::Swap(a.unwrap(), b.unwrap()))) + ("play" [] Some(Self::TogglePlay)) + ("solo" [] Some(Self::ToggleSolo)) + ("rec" [] Some(Self::ToggleRecord)) + ("mon" [] Some(Self::ToggleMonitor)) } }); @@ -169,7 +130,10 @@ defcom! { |self, app: Tek| } ToggleMenu => { - app.modal = Some(Modal::Menu); + app.modal = match app.modal { + Some(Modal::Menu) => None, + _ => Some(Modal::Menu) + }; None }