fix 1-track centering!

This commit is contained in:
🪞👃🪞 2025-01-23 20:40:37 +01:00
parent ffe8893bed
commit 0fa8e5bf15
4 changed files with 50 additions and 44 deletions

View file

@ -13,7 +13,13 @@ cov:
export RUSTDOCFLAGS='-Cinstrument-coverage'
export LLVM_PROFILE_FILE='cov/cargo-test-%p-%m.profraw'
time cargo test --workspace --exclude jack --profile coverage
time grcov . --binary-path ./target/coverage/deps/ -s . -t html --branch --ignore-not-existing --ignore '../*' --ignore "/*" --ignore 'target/*' -o target/coverage/html
#export LLVM_PROFILE_FILE='cov/cargo-doctest-%p-%m.profraw'
#time cargo test --workspace --exclude jack --profile coverage --doc
time grcov . --llvm --threads 2 --binary-path ./target/coverage/deps/ -s . -t html --ignore-not-existing --ignore '../*' --ignore "/*" --ignore 'target/*' -o target/coverage/html
llcov:
time cargo llvm-cov --workspace --exclude jack --profile coverage --no-report
time cargo llvm-cov --workspace --exclude jack --profile coverage --no-report --doc
time cargo llvm-cov report --doctests --html #--output-path target/coverage/html
prof:
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -- arranger
status:

View file

@ -259,23 +259,21 @@ impl Tek {
let h = 1;
let header: ThunkBox<_> =
(move||Tui::bg(Tui::g(32), Fill::x(Align::w(self.view_track_add()))).boxed()).into();
let cells: ThunkBox<_> = per_track!(self.size.w();|self, track, t|{
let content: ThunkBox<_> = per_track!(self.size.w();|self, track, t|{
let active = self.selected().track() == Some(t+1);
let name = &track.name;
let fg = track.color.lightest.rgb;
let bg = if active { track.color.light.rgb } else { track.color.base.rgb };
let bg2 = if t > 0 { self.tracks()[t - 1].color.base.rgb } else { Reset };
let bfg = if active { Rgb(255,255,255) } else { Rgb(0,0,0) };
let bs = Style::default().fg(bfg).bg(bg);
let cell = Bsp::e(
let name = &track.name;
let fg = track.color.lightest.rgb;
let bg = if active { track.color.light.rgb } else { track.color.base.rgb };
let bg2 = if t > 0 { self.tracks()[t - 1].color.base.rgb } else { Reset };
let bfg = if active { Rgb(255,255,255) } else { Rgb(0,0,0) };
Outer(active, Style::default().fg(bfg).bg(bg)).enclose(Bsp::e(
Tui::fg_bg(bg, bg2, ""),
Bsp::w(
Tui::fg_bg(bg, Reset, ""),
Tui::fg_bg(fg, bg, Tui::bold(true, Fill::x(Align::nw(name)))),
));
Outer(active, bs).enclose(cell)
)))
});
self.view_row(self.w(), 1, header, cells)
self.view_row(self.w(), 1, header, content)
}
fn view_track_add (&self) -> impl Content<TuiOut> + use<'_> {
let data = (self.selected.track().unwrap_or(0), self.tracks().len());
@ -324,8 +322,8 @@ impl Tek {
map_south(y1 as u16, height, border(height, cell))
}).boxed()
};
let border = move|x|Outer(false, bstyle).enclose_bg(x);
let content: ThunkBox<_> = per_track!(size_w; |self, track, t|{
let border = move|x|Outer(true, bstyle).enclose_bg(x);
let content: ThunkBox<_> = per_track!(self.size.w(); |self, track, t|{
let last_color = self.fmtd.read().unwrap().last_color.clone();
let same_track = selected_track == Some(t+1);
border(Map::new(scenes, move|(_, scene, y1, y2), s|{
@ -376,13 +374,15 @@ impl Tek {
When::new(selected, Fill::y(Align::n(button(tab, "edit")))),
phat_sel_3(selected, Fill::xy(label()), Fill::xy(label()), top, mid, low)));
let cell = Either::new(active, editor, cell);
Either(y2 > size_h, (), map_south(y1 as u16, h, Push::y(1, Fixed::y(h, cell))))
Either(y2 > size_h,
(),
map_south(y1 as u16, h, Push::y(1, Fixed::y(h, cell))))
})
}))
});
let border = move|x|Outer(false, bstyle).enclose_bg(x);
border(self.view_row(
size_w as u16,
self.w(),
size_h as u16,
<_ as Into<ThunkBox<_>>>::into(header),
<_ as Into<ThunkBox<_>>>::into(content),

View file

@ -52,6 +52,6 @@ pub(crate) use std::ffi::OsString;
engine.read().unwrap().exited.store(true, std::sync::atomic::Ordering::Relaxed);
let state = TestComponent("hello world".into());
let state = std::sync::Arc::new(std::sync::RwLock::new(state));
engine.run(&state)?;
//engine.run(&state)?;
Ok(())
}

View file

@ -233,33 +233,6 @@ impl<R: Content<TuiOut>> Content<TuiOut> for Styled<R> {
}
}
//pub trait TuiStyle: Render<TuiOut> + Sized {
//fn fg (self, color: Color) -> impl Render<TuiOut> {
//Layers::new(move |add|{ add(&Foreground(color))?; add(&self) })
//}
//fn bg (self, color: Color) -> impl Render<TuiOut> {
//Layers::new(move |add|{ add(&Background(color))?; add(&self) })
//}
//fn bold (self, on: bool) -> impl Render<TuiOut> {
//Layers::new(move |add|{ add(&Bold(on))?; add(&self) })
//}
//fn border <S: BorderStyle> (self, style: S) -> impl Render<TuiOut> {
//Bordered(style, self)
//}
//}
//impl<R: Content<TuiOut>> TuiStyle for R {}
//impl<S: BorderStyle> Content<TuiOut> for Border<S> {
//}
//impl<S: BorderStyle, R: Content<TuiOut>> Content<TuiOut> for Bordered<S, R> {
//fn content (&self) -> impl Render<TuiOut> {
//let content: &dyn Content<TuiOut> = &self.1;
//lay! { content.padding_xy(1, 1), Border(self.0) }.fill_xy()
//}
//}
pub struct Bordered<S: BorderStyle, W: Content<TuiOut>>(pub bool, pub S, pub W);
content!(TuiOut: |self: Bordered<S: BorderStyle, W: Content<TuiOut>>|Fill::xy(
lay!(When::new(self.0, Border(self.0, self.1)), Padding::xy(1, 1, &self.2))
@ -511,3 +484,30 @@ border! {
fn style (&self) -> Option<Style> { Some(self.1) }
}
}
//pub trait TuiStyle: Render<TuiOut> + Sized {
//fn fg (self, color: Color) -> impl Render<TuiOut> {
//Layers::new(move |add|{ add(&Foreground(color))?; add(&self) })
//}
//fn bg (self, color: Color) -> impl Render<TuiOut> {
//Layers::new(move |add|{ add(&Background(color))?; add(&self) })
//}
//fn bold (self, on: bool) -> impl Render<TuiOut> {
//Layers::new(move |add|{ add(&Bold(on))?; add(&self) })
//}
//fn border <S: BorderStyle> (self, style: S) -> impl Render<TuiOut> {
//Bordered(style, self)
//}
//}
//impl<R: Content<TuiOut>> TuiStyle for R {}
//impl<S: BorderStyle> Content<TuiOut> for Border<S> {
//}
//impl<S: BorderStyle, R: Content<TuiOut>> Content<TuiOut> for Bordered<S, R> {
//fn content (&self) -> impl Render<TuiOut> {
//let content: &dyn Content<TuiOut> = &self.1;
//lay! { content.padding_xy(1, 1), Border(self.0) }.fill_xy()
//}
//}