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,6 +1,6 @@
use crate::*;
has_size!(<TuiOut>|self: MidiEditor|&self.size);
render!(TuiOut: (self: MidiEditor) => {
content!(TuiOut: |self: MidiEditor| {
self.autoscroll();
//self.autozoom();
self.size.of(&self.mode)
@ -17,7 +17,6 @@ impl MidiEditor {
FieldV(color, "Loop", looped.to_string())
)
}
pub fn edit_status (&self) -> impl Content<TuiOut> + '_ {
let (color, length) = if let Some(clip) = self.clip().as_ref().map(|p|p.read().unwrap()) {
(clip.color, clip.length)

View file

@ -1,6 +1,6 @@
use crate::*;
pub struct PoolView<'a>(pub bool, pub &'a MidiPool);
render!(TuiOut: (self: PoolView<'a>) => {
content!(TuiOut: |self: PoolView<'a>| {
let Self(compact, model) = self;
let MidiPool { clips, mode, .. } = self.1;
let color = self.1.clip().map(|c|c.read().unwrap().color).unwrap_or_else(||TuiTheme::g(32).into());
@ -24,7 +24,7 @@ render!(TuiOut: (self: PoolView<'a>) => {
))))
})))))
});
render!(TuiOut: (self: ClipLength) => {
content!(TuiOut: |self: ClipLength| {
let bars = ||self.bars_string();
let beats = ||self.beats_string();
let ticks = ||self.ticks_string();

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, }
}
}

View file

@ -40,7 +40,7 @@ impl PianoHorizontal {
pub(crate) fn note_y_iter (note_lo: usize, note_hi: usize, y0: u16) -> impl Iterator<Item=(usize, u16, usize)> {
(note_lo..=note_hi).rev().enumerate().map(move|(y, n)|(y, y0 + y as u16, n))
}
render!(TuiOut: (self: PianoHorizontal) => Tui::bg(TuiTheme::g(40), Bsp::s(
content!(TuiOut:|self: PianoHorizontal| Tui::bg(TuiTheme::g(40), Bsp::s(
Bsp::e(
Fixed::x(5, format!("{}x{}", self.size.w(), self.size.h())),
self.timeline()