group devices

This commit is contained in:
🪞👃🪞 2024-06-07 18:16:23 +03:00
parent 60627ac3e5
commit 5afed6f055
8 changed files with 147 additions and 267 deletions

44
src/device.rs Normal file
View file

@ -0,0 +1,44 @@
pub mod transport;
pub mod sequencer;
pub mod sampler;
pub mod mixer;
pub mod looper;
use crate::prelude::*;
use self::transport::*;
use self::sequencer::*;
use self::sampler::*;
use self::mixer::*;
use self::looper::*;
pub enum Device {
Transport(self::transport::Transport),
Sequencer(self::sequencer::Sequencer),
Sampler(self::sampler::Sampler),
Mixer(self::mixer::Mixer),
Looper(self::looper::Looper),
}
impl WidgetRef for Device {
fn render_ref (&self, area: Rect, buf: &mut Buffer) {
match self {
Self::Transport(device) => device.render(area, buf),
Self::Sequencer(device) => device.render(area, buf),
Self::Sampler(device) => device.render(area, buf),
Self::Mixer(device) => device.render(area, buf),
Self::Looper(device) => device.render(area, buf),
}
}
}
impl HandleInput for Device {
fn handle (&mut self, event: &crate::engine::Event) -> Result<(), Box<dyn Error>> {
match self {
Self::Transport(device) => device.handle(event),
Self::Sequencer(device) => device.handle(event),
Self::Sampler(device) => device.handle(event),
Self::Mixer(device) => device.handle(event),
Self::Looper(device) => device.handle(event),
}
}
}