wip: reworking phat cell overlap

This commit is contained in:
🪞👃🪞 2025-01-24 23:07:43 +01:00
parent 854f198e36
commit 77809ca289
2 changed files with 57 additions and 64 deletions

View file

@ -110,13 +110,15 @@ impl Content<TuiOut> for RepeatH<'_> {
/// A cell that takes up 3 rows on its own,
/// but stacks, giving (N+1)*2 rows per N cells.
pub struct Phat<T: Content<T>> {
pub width: u16,
pub height: u16,
pub content: T,
pub top: Option<Color>,
pub mid: Option<Color>,
pub low: Option<Color>,
pub struct Phat<T> {
pub width: u16,
pub height: u16,
pub content: T,
pub fg: Color,
pub top: Option<Color>,
pub mid: Color,
pub low: Option<Color>,
pub selected: bool
}
impl<T> Phat<T> {
/// A phat line
@ -128,32 +130,15 @@ impl<T> Phat<T> {
Fixed::y(1, Tui::fg_bg(fg, bg, RepeatH(&"")))
}
}
impl<T: Content<T>> for Phat<T> {
fn content () -> impl Render<T> {
Bsp::s(Self::lo(color.base.rgb, last.base.rgb),
Bsp::n(Self::hi(color.base.rgb, last.base.rgb),
Fixed::y(1, Fill::x(Tui::fg_bg(color.lightest.rgb, color.base.rgb, field))),
)
)
impl<T: Content<TuiOut>> Content<TuiOut> for Phat<T> {
fn content (&self) -> impl Render<TuiOut> {
let top = self.top.map(|top|Self::lo(self.mid, top));
let low = self.low.map(|low|Self::hi(self.mid, low));
let content = Tui::fg_bg(self.fg, self.mid, &self.content);
let phat = Bsp::s(top, Bsp::n(low, Fill::xy(content)));
Min::xy(self.width, self.height, phat)
}
}
pub fn phat_sel_3 <T: Content<TuiOut>> (
selected: bool, field_1: T, field_2: T,
top: Option<Color>,
mid: Color,
low: Option<Color>,
) -> impl Content<TuiOut> {
let border = Style::default().fg(Color::Rgb(255,255,255)).bg(mid);
let top = top.map(|top|phat_lo(mid, top));
let low = low.map(|low|phat_hi(mid, low));
let a = Tui::bg(mid, Outer(true, border).enclose(Align::w(Bsp::s("", Bsp::n("", Fill::y(field_1))))));
let b = Bsp::s(Fixed::y(1, top), Bsp::n(Fixed::y(1, low), Fill::xy(Tui::bg(mid, field_2))));
Either::new(selected, a, b)
}
pub struct PhatOverlapIterator<T: Content<T>, I: Iterator<Item=T>> {
items: I,
color: Color
}
pub trait TuiStyle {
fn fg <R: Content<TuiOut>> (color: Color, w: R) -> Foreground<R> {
@ -423,7 +408,7 @@ border! {
const S0: &'static str = "";
fn style (&self) -> Option<Style> { Some(self.1) }
},
Phat {
Thick {
"" "" ""
"" ""
"" "" ""