mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
refactor: device abstraction, layout components
This commit is contained in:
parent
d330d31ce4
commit
788dc1ccde
21 changed files with 1144 additions and 1166 deletions
|
|
@ -1,58 +1,35 @@
|
|||
use crate::prelude::*;
|
||||
|
||||
pub struct Looper {
|
||||
exited: bool
|
||||
name: String
|
||||
}
|
||||
|
||||
impl Looper {
|
||||
pub fn new (name: &str) -> Result<DynamicDevice<Self>, Box<dyn Error>> {
|
||||
Ok(DynamicDevice::new(render, handle, |_|{}, Self {
|
||||
name: name.into(),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render (state: &Looper, buf: &mut Buffer, area: Rect) {
|
||||
//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()))?;
|
||||
}
|
||||
|
||||
pub fn handle (state: &mut Looper, event: &EngineEvent) -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue