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

92
src/device/looper.rs Normal file
View file

@ -0,0 +1,92 @@
use crate::prelude::*;
pub struct Looper {
exited: bool
}
pub const ACTIONS: [(&'static str, &'static str);1] = [
("Ins/Del", "Add/remove loop"),
];
impl Looper {
pub fn new () -> Result<Self, Box<dyn Error>> {
Ok(Self { exited: false })
}
}
impl Exitable for Looper {
fn exit (&mut self) {
self.exited = true
}
fn exited (&self) -> bool {
self.exited
}
}
impl WidgetRef for Looper {
fn render_ref (&self, area: Rect, buf: &mut Buffer) {
}
}
pub fn render (
state: &mut Looper,
stdout: &mut std::io::Stdout,
mut offset: (u16, u16),
) -> Result<(), Box<dyn Error>> {
let move_to = |col, row| MoveTo(offset.0 + col, offset.1 + row);
stdout
.queue(move_to(0, 0))?.queue(Print(" Name Input Length Route"))?
.queue(move_to(0, 1))?.queue(PrintStyledContent(" Metronome [ ] ████ Track 1".bold()))?
.queue(move_to(0, 2))?.queue(PrintStyledContent(" Loop 1 [ ] ████ Track 1".bold()))?
.queue(move_to(0, 3))?.queue(PrintStyledContent(" Loop 2 [ ] ████████ Track 2".bold()))?
.queue(move_to(0, 4))?.queue(PrintStyledContent(" Loop 3 [ ] ████████ Track 3".bold()))?;
Ok(())
}
impl HandleInput for Looper {
fn handle (&mut self, event: &Event) -> Result<(), Box<dyn Error>> {
handle(self, event)
}
}
pub fn handle (state: &mut Looper, event: &Event) -> Result<(), Box<dyn Error>> {
Ok(())
}
pub struct Notifications;
impl NotificationHandler for Notifications {
fn thread_init (&self, _: &Client) {
}
fn shutdown (&mut self, status: ClientStatus, reason: &str) {
}
fn freewheel (&mut self, _: &Client, is_enabled: bool) {
}
fn sample_rate (&mut self, _: &Client, _: Frames) -> Control {
Control::Quit
}
fn client_registration (&mut self, _: &Client, name: &str, is_reg: bool) {
}
fn port_registration (&mut self, _: &Client, port_id: PortId, is_reg: bool) {
}
fn port_rename (&mut self, _: &Client, id: PortId, old: &str, new: &str) -> Control {
Control::Continue
}
fn ports_connected (&mut self, _: &Client, id_a: PortId, id_b: PortId, are: bool) {
}
fn graph_reorder (&mut self, _: &Client) -> Control {
Control::Continue
}
fn xrun (&mut self, _: &Client) -> Control {
Control::Continue
}
}