mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
wip: add overlay for help/menu modals
This commit is contained in:
parent
fa2e08e81c
commit
38fb348d19
10 changed files with 323 additions and 234 deletions
|
|
@ -30,45 +30,141 @@ expose!([self: Tek] {
|
|||
}
|
||||
}
|
||||
[Selection] => {
|
||||
":scene-next" => match self.selected {
|
||||
Selection::Mix => Selection::Scene(0),
|
||||
Selection::Track(t) => Selection::Clip(t, 0),
|
||||
Selection::Scene(s) if s + 1 < self.scenes.len() => Selection::Scene(s + 1),
|
||||
Selection::Scene(s) => Selection::Mix,
|
||||
Selection::Clip(t, s) if s + 1 < self.scenes.len() => Selection::Clip(t, s + 1),
|
||||
Selection::Clip(t, s) => Selection::Track(t),
|
||||
},
|
||||
":scene-prev" => match self.selected {
|
||||
Selection::Mix => Selection::Mix,
|
||||
Selection::Track(t) => Selection::Track(t),
|
||||
Selection::Scene(0) => Selection::Mix,
|
||||
Selection::Scene(s) => Selection::Scene(s - 1),
|
||||
Selection::Clip(t, 0) => Selection::Track(t),
|
||||
Selection::Clip(t, s) => Selection::Clip(t, s - 1),
|
||||
},
|
||||
":track-next" => match self.selected {
|
||||
Selection::Mix => Selection::Track(0),
|
||||
Selection::Track(t) if t + 1 < self.tracks.len() => Selection::Track(t + 1),
|
||||
Selection::Track(t) => Selection::Mix,
|
||||
Selection::Scene(s) => Selection::Clip(0, s),
|
||||
Selection::Clip(t, s) if t + 1 < self.tracks.len() => Selection::Clip(t + 1, s),
|
||||
Selection::Clip(t, s) => Selection::Scene(s),
|
||||
},
|
||||
":track-prev" => match self.selected {
|
||||
Selection::Mix => Selection::Mix,
|
||||
Selection::Scene(s) => Selection::Scene(s),
|
||||
Selection::Track(0) => Selection::Mix,
|
||||
Selection::Track(t) => Selection::Track(t - 1),
|
||||
Selection::Clip(0, s) => Selection::Scene(s),
|
||||
Selection::Clip(t, s) => Selection::Clip(t - 1, s),
|
||||
},
|
||||
":scene-next" => self.selected.scene_next(self.scenes.len()),
|
||||
":scene-prev" => self.selected.scene_prev(),
|
||||
":track-next" => self.selected.track_next(self.tracks.len()),
|
||||
":track-prev" => self.selected.track_prev(),
|
||||
}
|
||||
});
|
||||
|
||||
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<RwLock<MidiClip>>]
|
||||
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))
|
||||
//("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<Arc<RwLock<MidiClip>>>]
|
||||
Some(Self::Put(a.unwrap(), b.unwrap(), c.unwrap())))
|
||||
("enqueue" [a: usize, b: usize]
|
||||
Some(Self::Enqueue(a.unwrap(), b.unwrap())))
|
||||
("edit" [a: Option<Arc<RwLock<MidiClip>>>]
|
||||
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 => {
|
||||
("add" [] Some(Self::Add))
|
||||
}
|
||||
|
||||
OutputCommand => {
|
||||
("add" [] Some(Self::Add))
|
||||
}
|
||||
|
||||
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())))
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
defcom! { |self, app: Tek|
|
||||
|
||||
TekCommand {
|
||||
|
||||
ToggleHelp => {
|
||||
app.modal = Some(Modal::Help);
|
||||
None
|
||||
}
|
||||
|
||||
Sampler(cmd: SamplerCommand) => {
|
||||
println!("\n\rtodo: {cmd:?}");
|
||||
None
|
||||
|
|
@ -380,120 +476,3 @@ defcom! { |self, app: Tek|
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
impose!([app: Tek] {
|
||||
|
||||
TekCommand => {
|
||||
("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<RwLock<MidiClip>>]
|
||||
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))
|
||||
//("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<Arc<RwLock<MidiClip>>>]
|
||||
Some(Self::Put(a.unwrap(), b.unwrap(), c.unwrap())))
|
||||
("enqueue" [a: usize, b: usize]
|
||||
Some(Self::Enqueue(a.unwrap(), b.unwrap())))
|
||||
("edit" [a: Option<Arc<RwLock<MidiClip>>>]
|
||||
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 => {
|
||||
("add" [] Some(Self::Add))
|
||||
}
|
||||
|
||||
OutputCommand => {
|
||||
("add" [] Some(Self::Add))
|
||||
}
|
||||
|
||||
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())))
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue