mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
57 lines
1.3 KiB
Rust
57 lines
1.3 KiB
Rust
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
|
|
}
|
|
}
|