transport is rolling

This commit is contained in:
🪞👃🪞 2024-05-31 23:43:12 +03:00
parent 1f928fba9d
commit 4fd208d53f
18 changed files with 540 additions and 498 deletions

57
src/transport/mod.rs Normal file
View file

@ -0,0 +1,57 @@
mod handle;
mod jack;
mod render;
pub use self::handle::*;
pub use self::jack::*;
pub use self::render::*;
use crate::prelude::*;
pub const ACTIONS: [(&'static str, &'static str);3] = [
("(Shift-)Tab", "Switch pane"),
("Arrows", "Navigate"),
("(Shift-)Space", "⯈ Play/pause"),
];
pub struct Transport {
exited: bool,
title: String,
transport: ::jack::Transport,
}
impl Transport {
pub fn new (client: &Client) -> Result<Self, Box<dyn Error>> {
Ok(Self {
exited: false,
title: String::from("Untitled project"),
transport: client.transport(),
})
}
pub fn play_from_start_or_stop_and_rewind (&mut self) {
}
pub fn play_or_pause (&mut self) -> Result<(), Box<dyn Error>> {
match self.transport.query_state()? {
TransportState::Stopped => self.play(),
TransportState::Rolling => self.stop(),
_ => Ok(())
}
}
pub fn play (&mut self) -> Result<(), Box<dyn Error>> {
Ok(self.transport.start()?)
}
pub fn stop (&mut self) -> Result<(), Box<dyn Error>> {
Ok(self.transport.stop()?)
}
}
impl Exitable for Transport {
fn exit (&mut self) {
self.exited = true
}
fn exited (&self) -> bool {
self.exited
}
}

View file

@ -7,7 +7,6 @@ pub fn render (
mut offset: (u16, u16)
) -> Result<(), Box<dyn Error>> {
let move_to = |col, row| MoveTo(offset.0 + col, offset.1 + row);
let position = state.transport.query();
stdout.queue(move_to( 1, 0))?.queue(
Print("Project: ")
)?.queue(move_to(10, 0))?.queue(