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

@ -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()
//}
//}