fix and test alignments

This commit is contained in:
🪞👃🪞 2025-01-01 21:04:39 +01:00
parent 9125e04e07
commit 3c14456566
8 changed files with 135 additions and 100 deletions

View file

@ -208,16 +208,18 @@ impl PoolModel {
pub struct PoolView<'a>(pub(crate) &'a PoolModel);
// TODO: Display phrases always in order of appearance
render!(Tui: (self: PoolView<'a>) => {
//let content = "...";
//let content = Tui::map(||["abc", "def", "ghi"].iter(), |item, index|Push::y(index as u16, item));
let PoolModel { phrases, mode, .. } = self.0;
let bg = TuiTheme::g(32);
let title_color = TuiTheme::ti1();
let upper_left = "Pool:";
let upper_right = format!("({})", phrases.len());
let color = self.0.phrase().read().unwrap().color;
let with_files = |x|Tui::either(self.0.file_picker().is_some(),
Thunk::new(||self.0.file_picker().unwrap()),
Thunk::new(x));
let content = with_files(||Tui::map(||phrases.iter(), |clip, i|{
//let bg = TuiTheme::g(32);
//let title_color = TuiTheme::ti1();
//let upper_left = "Pool:";
//let upper_right = format!("({})", phrases.len());
//let color = self.0.phrase().read().unwrap().color;
////let with_files = |x|Tui::either(self.0.file_picker().is_some(),
////Thunk::new(||self.0.file_picker().unwrap()),
////Thunk::new(x));
let content = Tui::map(||phrases.iter(), |clip, i|{
let MidiClip { ref name, color, length, .. } = *clip.read().unwrap();
//let mut length = PhraseLength::new(length, None);
//if let Some(PoolMode::Length(clip, new_length, focus)) = self.0.mode {
@ -226,8 +228,10 @@ render!(Tui: (self: PoolView<'a>) => {
//length.focus = Some(focus);
//}
//}
Push::y(1 + i as u16 * 2, Fill::x(Fixed::y(2, Tui::bg(color.base.rgb,
format!(" {i} {name} {length} ")))))/*,
Push::y(i as u16, format!(" {i} {name} {length} "))/*
//format!(" {i} {name} {length} ")[>
//Push::y(i as u16 * 2, Fixed::y(2, Tui::bg(color.base.rgb, Fill::x(
//format!(" {i} {name} {length} ")))))[>,
name.clone()))))Bsp::s(
Fill::x(Bsp::a(
Align::w(format!(" {i}")),
@ -243,8 +247,8 @@ render!(Tui: (self: PoolView<'a>) => {
row2
}),
))))//lay!(clip, Tui::when(i == self.0.clip_index(), CORNERS)))*/
}));
content
});
Tui::bg(Color::Red, content)
//let border = Outer(Style::default().fg(color.base.rgb).bg(color.dark.rgb));
//let enclose = |x|lay!(
//Fill::xy(border),

View file

@ -101,18 +101,18 @@ render!(Tui: (self: TransportView) => {
Tui::fg_bg(color.lightest.rgb, color.darkest.rgb, format!("{:>10}", value)),
Tui::fg_bg(color.darkest.rgb, color.base.rgb, ""),
);
Bsp::e(
Fixed::x(17, col!(
Fixed::x(40, Tui::bg(Color::Red, Bsp::e(
Tui::bg(Color::Green, Fixed::x(18, col!(
transport_field(" Beat", self.beat.clone()),
transport_field(" Time", format!("{:.1}s", self.current_second)),
transport_field(" BPM", self.bpm.clone()),
)),
Fixed::x(17, col!(
))),
Tui::bg(Color::Blue, Fixed::x(18, col!(
transport_field(" Rate", format!("{}", self.sr)),
transport_field(" Chunk", format!("{}", self.chunk)),
transport_field(" Lag", format!("{:.3}ms", self.latency)),
)),
)
))),
)))
});
impl HasFocus for TransportTui {
type Item = TransportFocus;