down to 28e, sane ones

This commit is contained in:
🪞👃🪞 2024-12-31 15:50:53 +01:00
parent 46609855eb
commit 16e6a0397c
15 changed files with 91 additions and 87 deletions

View file

@ -89,23 +89,29 @@ impl TransportView {
}
render!(Tui: (self: TransportView) => {
let color = self.color;
let transport_field = move|label, value|row!(
Tui::fg_bg(color.lightest.rgb, color.base.rgb, Tui::bold(true, label)),
Tui::fg_bg(color.base.rgb, color.darkest.rgb, ""),
Tui::fg_bg(color.lightest.rgb, color.darkest.rgb, format!("{:>10}", value)),
Tui::fg_bg(color.darkest.rgb, color.base.rgb, ""),
);
Fixed::y(3, Tui::bg(color.base.rgb, Fill::x(row!(
col!(
TransportField(" Beat", self.beat.as_str(), &color),
TransportField(" Time", format!("{:.1}s", self.current_second).as_str(), &color),
TransportField(" BPM", self.bpm.as_str(), &color),
),
col!(
TransportField(" Rate", format!("{}", self.sr).as_str(), &color),
TransportField(" Chunk", format!("{}", self.chunk).as_str(), &color),
TransportField(" Lag", format!("{:.3}ms", self.latency).as_str(), &color),
),
Thunk::new(move||col!(
transport_field(" Beat", self.beat.as_str()),
transport_field(" Time", format!("{:.1}s", self.current_second).as_str()),
transport_field(" BPM", self.bpm.as_str()),
)),
Thunk::new(move||col!(
transport_field(" Rate", format!("{}", self.sr).as_str()),
transport_field(" Chunk", format!("{}", self.chunk).as_str()),
transport_field(" Lag", format!("{:.3}ms", self.latency).as_str()),
)),
col!(
//Field(" CPU%", format!("{:.1}ms", self.perf).as_str(), &color),
),
))))
});
struct TransportField<'a>(&'a str, &'a str, &'a ItemPalette);
struct TransportField<'a>(&'a str, &'a str, ItemPalette);
render!(Tui: (self: TransportField<'a>) => row!(
Tui::fg_bg(self.2.lightest.rgb, self.2.base.rgb, Tui::bold(true, self.0)),
Tui::fg_bg(self.2.base.rgb, self.2.darkest.rgb, ""),
@ -115,17 +121,13 @@ render!(Tui: (self: TransportField<'a>) => row!(
pub struct PlayPause(pub bool);
render!(Tui: (self: PlayPause) => Tui::bg(
if self.0{Color::Rgb(0,128,0)}else{Color::Rgb(128,64,0)},
Fixed::x(5, col!(|add|if self.0 {
add(&Tui::fg(Color::Rgb(0, 255, 0), col!(
" 🭍🭑🬽 ",
" 🭞🭜🭘 ",
)))
} else {
add(&Tui::fg(Color::Rgb(255, 128, 0), col!(
" ▗▄▖ ",
" ▝▀▘ ",
)))
}))
Fixed::x(5, Cond::either(self.0, Tui::fg(Color::Rgb(0, 255, 0), col!(
" 🭍🭑🬽 ",
" 🭞🭜🭘 ",
)), Tui::fg(Color::Rgb(255, 128, 0), col!(
" ▗▄▖ ",
" ▝▀▘ ",
))))
));
impl HasFocus for TransportTui {
type Item = TransportFocus;
@ -152,7 +154,7 @@ impl FocusWrap<TransportFocus> for TransportFocus {
let focused = focus == self;
let corners = focused.then_some(CORNERS);
//let highlight = focused.then_some(Tui::bg(Color::Rgb(60, 70, 50)));
lay!(corners, /*highlight,*/ *content)
lay!(corners, /*highlight,*/ content)
}
}
impl FocusWrap<TransportFocus> for Option<TransportFocus> {
@ -162,7 +164,7 @@ impl FocusWrap<TransportFocus> for Option<TransportFocus> {
let focused = Some(focus) == self;
let corners = focused.then_some(CORNERS);
//let highlight = focused.then_some(Background(Color::Rgb(60, 70, 50)));
lay!(corners, /*highlight,*/ *content)
lay!(corners, /*highlight,*/ content)
}
}
pub trait TransportControl<T>: HasClock + {