device picker
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
🪞👃🪞 2025-05-04 16:23:50 +03:00
parent 55b6745d4d
commit a77536c234
6 changed files with 93 additions and 13 deletions

View file

@ -20,6 +20,7 @@ handle!(TuiIn: |self: Tek, input|Ok(if let Some(command) = self.config.keys.comm
expose!([self: Tek]
([bool]
(":mode-editor" self.is_editing())
(":mode-device-add" matches!(self.modal, Some(Modal::Device(..))))
(":mode-clip" !self.is_editing() && self.selected.is_clip())
(":mode-track" !self.is_editing() && self.selected.is_track())
(":mode-scene" !self.is_editing() && self.selected.is_scene())
@ -45,7 +46,22 @@ expose!([self: Tek]
(":w-sidebar" self.w_sidebar()))
([usize]
(":scene-last" self.scenes.len())
(":track-last" self.tracks.len()))
(":track-last" self.tracks.len())
(":device-kind" if let Some(Modal::Device(index)) = self.modal {
index
} else {
0
})
(":device-kind-prev" if let Some(Modal::Device(index)) = self.modal {
index.overflowing_sub(1).0.min(self.device_kinds().len().saturating_sub(1))
} else {
0
})
(":device-kind-next" if let Some(Modal::Device(index)) = self.modal {
(index + 1) % self.device_kinds().len()
} else {
0
}))
([Option<usize>]
(":scene" self.selected.scene())
(":track" self.selected.track()))
@ -120,6 +136,7 @@ impose!([app: Tek]
("input" [,..a] ns!(InputCommand, app, a, Self::Input))
("output" [,..a] ns!(OutputCommand, app, a, Self::Output))
("clip" [,..a] ns!(ClipCommand, app, a, Self::Clip))
("device" [,..a] ns!(DeviceCommand, app, a, Self::Device))
("pool" [,..a] app.pool.as_ref().map(|p|ns!(PoolCommand, p, a, Self::Pool)).flatten())
("editor" [,..a] app.editor().map(|e|ns!(MidiEditCommand, e, a, Self::Editor)).flatten())
("sampler" [,..a] app.sampler().map(|s|ns!(SamplerCommand, s, a, Self::Sampler)).flatten())
@ -144,6 +161,11 @@ impose!([app: Tek]
(OutputCommand:
("add" [] Some(Self::Add)))
(DeviceCommand:
("picker" [] Some(Self::Picker))
("pick" [index: usize] Some(Self::Pick(index.unwrap())))
("add" [index: usize] Some(Self::Add(index.unwrap()))))
(SceneCommand:
("add" [] Some(Self::Add))
("delete" [a: Option<usize>] Some(Self::Del(a.flatten().unwrap())))
@ -175,6 +197,7 @@ defcom!([self, app: Tek]
(Input [cmd: InputCommand] cmd.delegate(app, Self::Input)?)
(Clip [cmd: ClipCommand] cmd.delegate(app, Self::Clip)?)
(Clock [cmd: ClockCommand] cmd.delegate(app, Self::Clock)?)
(Device [cmd: DeviceCommand] cmd.delegate(app, Self::Device)?)
(Editor [cmd: MidiEditCommand] delegate_to_editor(app, cmd)?)
(Pool [cmd: PoolCommand] delegate_to_pool(app, cmd)?)
(ToggleHelp [] cmd!(app.toggle_modal(Some(Modal::Help))))
@ -189,10 +212,15 @@ defcom!([self, app: Tek]
(StopAll [] cmd!(app.stop_all())))
(InputCommand
(Add [] cmd!(app.add_midi_in()?)))
(Add [] cmd!(app.midi_in_add()?)))
(OutputCommand
(Add [] cmd!(app.add_midi_out()?)))
(Add [] cmd!(app.midi_out_add()?)))
(DeviceCommand
(Picker [] cmd!(app.device_picker_show()))
(Pick [i: usize] cmd!(app.device_pick(i)))
(Add [i: usize] cmd!(app.device_add(i))))
(TrackCommand
(TogglePlay [] Some(Self::TogglePlay))