add HasJack; Arrangement

This commit is contained in:
🪞👃🪞 2025-01-12 00:42:53 +01:00
parent 744ce21e24
commit e73c31d494
12 changed files with 565 additions and 387 deletions

View file

@ -2,31 +2,31 @@ use crate::*;
use KeyCode::*;
use ClockCommand::{Play, Pause};
/// Transport clock app.
pub struct TransportTui {
pub struct ClockTui {
pub jack: Arc<RwLock<JackConnection>>,
pub clock: Clock,
}
handle!(TuiIn: |self: TransportTui, input|ClockCommand::execute_with_state(self, input.event()));
keymap!(TRANSPORT_KEYS = |state: TransportTui, input: Event| ClockCommand {
handle!(TuiIn: |self: ClockTui, input|ClockCommand::execute_with_state(self, input.event()));
keymap!(TRANSPORT_KEYS = |state: ClockTui, input: Event| ClockCommand {
key(Char(' ')) =>
if state.clock().is_stopped() { Play(None) } else { Pause(None) },
shift(key(Char(' '))) =>
if state.clock().is_stopped() { Play(Some(0)) } else { Pause(Some(0)) }
});
has_clock!(|self: TransportTui|&self.clock);
audio!(|self: TransportTui, client, scope|ClockAudio(self).process(client, scope));
render!(TuiOut: (self: TransportTui) => TransportView {
has_clock!(|self: ClockTui|&self.clock);
audio!(|self: ClockTui, client, scope|ClockAudio(self).process(client, scope));
render!(TuiOut: (self: ClockTui) => ClockView {
compact: false,
clock: &self.clock
});
pub struct TransportView<'a> { pub compact: bool, pub clock: &'a Clock }
impl<'a> TransportView<'a> {
pub struct ClockView<'a> { pub compact: bool, pub clock: &'a Clock }
impl<'a> ClockView<'a> {
pub fn new (compact: bool, clock: &'a Clock) -> Self {
Self { compact, clock }
}
}
render!(TuiOut: (self: TransportView<'a>) => Outer(
render!(TuiOut: (self: ClockView<'a>) => Outer(
Style::default().fg(TuiTheme::g(255))
).enclose(row!(
OutputStats::new(self.compact, self.clock),