mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
toggle transport background
This commit is contained in:
parent
a91b539cd0
commit
74a07d0e75
3 changed files with 36 additions and 21 deletions
|
|
@ -119,7 +119,11 @@ render!(|self: ArrangerTui|{
|
|||
let arranger_focused = self.arranger_focused();
|
||||
let border = Lozenge(Style::default().bg(TuiTheme::border_bg()).fg(TuiTheme::border_fg(arranger_focused)));
|
||||
col!([
|
||||
TransportView::from(self),
|
||||
TransportView::from((self, if let ArrangerFocus::Transport(_) = self.focus.inner() {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
})),
|
||||
col!([
|
||||
Tui::fixed_y(self.splits[0], lay!([
|
||||
border.wrap(Tui::grow_y(1, Layers::new(move |add|{
|
||||
|
|
|
|||
|
|
@ -103,7 +103,11 @@ render!(|self: SequencerTui|{
|
|||
//col_up!([
|
||||
//Tui::max_y(2, SequencerStatusBar::from(self)),
|
||||
col!([
|
||||
TransportView::from(self),
|
||||
TransportView::from((self, if let SequencerFocus::Transport(_) = self.focus.inner() {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
})),
|
||||
row!([
|
||||
Tui::fixed_x(20, col!([
|
||||
PhraseSelector::play_phrase(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::*;
|
||||
use crate::api::ClockCommand::{SetBpm, SetQuant, SetSync};
|
||||
use crate::api::ClockCommand::{Play, Pause, SetBpm, SetQuant, SetSync};
|
||||
use TransportCommand::{Focus, Clock};
|
||||
use FocusCommand::{Next, Prev};
|
||||
use KeyCode::{Enter, Left, Right, Char};
|
||||
|
||||
/// Transport clock app.
|
||||
|
|
@ -54,9 +55,11 @@ impl Audio for TransportTui {
|
|||
}
|
||||
}
|
||||
|
||||
render!(|self: TransportTui|TransportView::from(self));
|
||||
render!(|self: TransportTui|TransportView::from((self, true)));
|
||||
|
||||
pub struct TransportView {
|
||||
focused: bool,
|
||||
|
||||
sr: String,
|
||||
bpm: String,
|
||||
ppq: String,
|
||||
|
|
@ -70,14 +73,15 @@ pub struct TransportView {
|
|||
current_second: String,
|
||||
}
|
||||
|
||||
impl<T: HasClock> From<&T> for TransportView {
|
||||
fn from (state: &T) -> Self {
|
||||
impl<T: HasClock> From<(&T, bool)> for TransportView {
|
||||
fn from ((state, focused): (&T, bool)) -> Self {
|
||||
let clock = state.clock();
|
||||
let sr = format!("{:.1}k", clock.timebase.sr.get() / 1000.0);
|
||||
let bpm = format!("{:.3}", clock.timebase.bpm.get());
|
||||
let ppq = format!("{:.0}", clock.timebase.ppq.get());
|
||||
if let Some(started) = clock.started.read().unwrap().as_ref() {
|
||||
Self {
|
||||
focused,
|
||||
sr,
|
||||
bpm,
|
||||
ppq,
|
||||
|
|
@ -89,6 +93,7 @@ impl<T: HasClock> From<&T> for TransportView {
|
|||
}
|
||||
} else {
|
||||
Self {
|
||||
focused,
|
||||
sr,
|
||||
bpm,
|
||||
ppq,
|
||||
|
|
@ -113,9 +118,11 @@ render!(|self: TransportField<'a>|{
|
|||
render!(|self: TransportView|{
|
||||
let bg = TuiTheme::border_bg();
|
||||
let border_style = Style::default().bg(bg).fg(TuiTheme::border_fg(false));
|
||||
lay!([
|
||||
Tui::fill_x(Lozenge(border_style)),
|
||||
Tui::outset_x(1, row!([
|
||||
lay!(move|add|{
|
||||
if self.focused {
|
||||
add(&Tui::fill_x(Lozenge(border_style)))?;
|
||||
}
|
||||
add(&Tui::outset_x(1, row!([
|
||||
row!([
|
||||
TransportField("SR ", self.sr.as_str()),
|
||||
" ",
|
||||
|
|
@ -138,8 +145,8 @@ render!(|self: TransportView|{
|
|||
add(&col!([Tui::fg(Color::Rgb(255, 128, 0), "⏹ STOPPED "), ""]))
|
||||
}
|
||||
}),
|
||||
]))
|
||||
])
|
||||
])))
|
||||
})
|
||||
});
|
||||
|
||||
/// Which item of the transport toolbar is focused
|
||||
|
|
@ -267,17 +274,17 @@ where
|
|||
T: TransportControl
|
||||
{
|
||||
Some(match input.event() {
|
||||
key!(Left) => Focus(FocusCommand::Prev),
|
||||
key!(Right) => Focus(FocusCommand::Next),
|
||||
key!(Left) => Focus(Prev),
|
||||
key!(Right) => Focus(Next),
|
||||
key!(Char(' ')) => Clock(if state.clock().is_stopped() {
|
||||
ClockCommand::Play(None)
|
||||
Play(None)
|
||||
} else {
|
||||
ClockCommand::Pause(None)
|
||||
Pause(None)
|
||||
}),
|
||||
key!(Shift-Char(' ')) => Clock(if state.clock().is_stopped() {
|
||||
ClockCommand::Play(Some(0))
|
||||
Play(Some(0))
|
||||
} else {
|
||||
ClockCommand::Pause(Some(0))
|
||||
Pause(Some(0))
|
||||
}),
|
||||
_ => match state.transport_focused().unwrap() {
|
||||
TransportFocus::Bpm => match input.event() {
|
||||
|
|
@ -311,16 +318,16 @@ where
|
|||
TransportFocus::PlayPause => match input.event() {
|
||||
key!(Enter) => Clock(
|
||||
if state.clock().is_stopped() {
|
||||
ClockCommand::Play(None)
|
||||
Play(None)
|
||||
} else {
|
||||
ClockCommand::Pause(None)
|
||||
Pause(None)
|
||||
}
|
||||
),
|
||||
key!(Shift-Enter) => Clock(
|
||||
if state.clock().is_stopped() {
|
||||
ClockCommand::Play(Some(0))
|
||||
Play(Some(0))
|
||||
} else {
|
||||
ClockCommand::Pause(Some(0))
|
||||
Pause(Some(0))
|
||||
}
|
||||
),
|
||||
_ => return None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue