separate render/content macros; add has_jack

This commit is contained in:
🪞👃🪞 2025-01-14 12:41:27 +01:00
parent 08184f9906
commit e62e36d558
19 changed files with 183 additions and 226 deletions

View file

@ -1,17 +1,16 @@
use crate::*;
pub struct ClipSelected {
pub(crate) title: &'static str,
pub(crate) name: Arc<str>,
pub(crate) color: ItemPalette,
pub(crate) time: Arc<str>,
}
render!(TuiOut: (self: ClipSelected) =>
FieldV(self.color, self.title, format!("{} {}", self.time, self.name)));
content!(TuiOut: |self: ClipSelected|FieldV(
self.color,
self.title,
format!("{} {}", self.time, self.name)
));
impl ClipSelected {
/// Shows currently playing clip with beats elapsed
pub fn play_clip <T: HasPlayClip + HasClock> (state: &T) -> Self {
let (name, color) = if let Some((_, Some(clip))) = state.play_clip() {
@ -31,7 +30,6 @@ impl ClipSelected {
.unwrap_or_else(||String::from(" ")).into()
}
}
/// Shows next clip with beats remaining until switchover
pub fn next_clip <T: HasPlayClip> (state: &T) -> Self {
let mut time: Arc<str> = String::from("--.-.--").into();
@ -69,5 +67,4 @@ impl ClipSelected {
};
Self { title: "Next", time, name, color, }
}
}