mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
This commit is contained in:
parent
57102d7e6b
commit
b0ef0cfd21
6 changed files with 197 additions and 188 deletions
|
|
@ -1,5 +1,6 @@
|
|||
mod clock_api; pub use self::clock_api::*;
|
||||
mod clock_model; pub use self::clock_model::*;
|
||||
mod clock_view; pub use self::clock_view::*;
|
||||
|
||||
pub trait HasClock: Send + Sync {
|
||||
fn clock (&self) -> &Clock;
|
||||
|
|
|
|||
51
crates/device/src/clock/clock_view.rs
Normal file
51
crates/device/src/clock/clock_view.rs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
use crate::*;
|
||||
|
||||
pub fn view_transport (
|
||||
play: bool,
|
||||
bpm: Arc<RwLock<String>>,
|
||||
beat: Arc<RwLock<String>>,
|
||||
time: Arc<RwLock<String>>,
|
||||
) -> impl Content<TuiOut> {
|
||||
let theme = ItemTheme::G[96];
|
||||
Tui::bg(Black, row!(Bsp::a(
|
||||
Fill::xy(Align::w(button_play_pause(play))),
|
||||
Fill::xy(Align::e(row!(
|
||||
FieldH(theme, "BPM", bpm),
|
||||
FieldH(theme, "Beat", beat),
|
||||
FieldH(theme, "Time", time),
|
||||
)))
|
||||
)))
|
||||
}
|
||||
|
||||
pub fn view_status (
|
||||
sel: Arc<str>,
|
||||
sr: Arc<RwLock<String>>,
|
||||
buf: Arc<RwLock<String>>,
|
||||
lat: Arc<RwLock<String>>,
|
||||
) -> impl Content<TuiOut> {
|
||||
let theme = ItemTheme::G[96];
|
||||
Tui::bg(Black, row!(Bsp::a(
|
||||
Fill::xy(Align::w(FieldH(theme, "Selected", sel))),
|
||||
Fill::xy(Align::e(row!(
|
||||
FieldH(theme, "SR", sr),
|
||||
FieldH(theme, "Buf", buf),
|
||||
FieldH(theme, "Lat", lat),
|
||||
)))
|
||||
)))
|
||||
}
|
||||
|
||||
pub(crate) fn button_play_pause (playing: bool) -> impl Content<TuiOut> {
|
||||
let compact = true;//self.is_editing();
|
||||
Tui::bg(if playing { Rgb(0, 128, 0) } else { Rgb(128, 64, 0) },
|
||||
Either::new(compact,
|
||||
Thunk::new(move||Fixed::x(9, Either::new(playing,
|
||||
Tui::fg(Rgb(0, 255, 0), " PLAYING "),
|
||||
Tui::fg(Rgb(255, 128, 0), " STOPPED ")))
|
||||
),
|
||||
Thunk::new(move||Fixed::x(5, Either::new(playing,
|
||||
Tui::fg(Rgb(0, 255, 0), Bsp::s(" 🭍🭑🬽 ", " 🭞🭜🭘 ",)),
|
||||
Tui::fg(Rgb(255, 128, 0), Bsp::s(" ▗▄▖ ", " ▝▀▘ ",))))
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -52,3 +52,30 @@ pub fn to_rms (samples: &[f32]) -> f32 {
|
|||
.unwrap_or(0.0);
|
||||
(sum / samples.len() as f32).sqrt()
|
||||
}
|
||||
|
||||
pub (crate) fn view_meter <'a> (label: &'a str, value: f32) -> impl Content<TuiOut> + 'a {
|
||||
col!(
|
||||
FieldH(ItemTheme::G[128], label, format!("{:>+9.3}", value)),
|
||||
Fixed::xy(if value >= 0.0 { 13 }
|
||||
else if value >= -1.0 { 12 }
|
||||
else if value >= -2.0 { 11 }
|
||||
else if value >= -3.0 { 10 }
|
||||
else if value >= -4.0 { 9 }
|
||||
else if value >= -6.0 { 8 }
|
||||
else if value >= -9.0 { 7 }
|
||||
else if value >= -12.0 { 6 }
|
||||
else if value >= -15.0 { 5 }
|
||||
else if value >= -20.0 { 4 }
|
||||
else if value >= -25.0 { 3 }
|
||||
else if value >= -30.0 { 2 }
|
||||
else if value >= -40.0 { 1 }
|
||||
else { 0 }, 1, Tui::bg(if value >= 0.0 { Red }
|
||||
else if value >= -3.0 { Yellow }
|
||||
else { Green }, ())))
|
||||
}
|
||||
|
||||
pub(crate) fn view_meters (values: &[f32;2]) -> impl Content<TuiOut> + use<'_> {
|
||||
let left = format!("L/{:>+9.3}", values[0]);
|
||||
let right = format!("R/{:>+9.3}", values[1]);
|
||||
Bsp::s(left, right)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue