use crate::*; /// A three-column layout. pub struct Tryptich { pub top: bool, pub h: u16, pub left: (u16, A), pub middle: (u16, B), pub right: (u16, C), } impl Tryptich<(), (), ()> { pub fn center (h: u16) -> Self { Self { h, top: false, left: (0, ()), middle: (0, ()), right: (0, ()) } } pub fn top (h: u16) -> Self { Self { h, top: true, left: (0, ()), middle: (0, ()), right: (0, ()) } } } impl Tryptich { pub fn left (self, w: u16, content: D) -> Tryptich { Tryptich { left: (w, content), ..self } } pub fn middle (self, w: u16, content: D) -> Tryptich { Tryptich { middle: (w, content), ..self } } pub fn right (self, w: u16, content: D) -> Tryptich { Tryptich { right: (w, content), ..self } } } impl Content for Tryptich where A: Content, B: Content, C: Content { fn content (&self) -> impl Render { let Self { top, h, left: (w_a, ref a), middle: (w_b, ref b), right: (w_c, ref c) } = *self; Fixed::y(h, if top { Bsp::a( Fill::x(Align::n(Fixed::x(w_b, Align::x(Tui::bg(Color::Reset, b))))), Bsp::a( Fill::x(Align::nw(Fixed::x(w_a, Tui::bg(Color::Reset, a)))), Fill::x(Align::ne(Fixed::x(w_c, Tui::bg(Color::Reset, c)))), ), ) } else { Bsp::a( Fill::xy(Align::c(Fixed::x(w_b, Align::x(Tui::bg(Color::Reset, b))))), Bsp::a( Fill::xy(Align::w(Fixed::x(w_a, Tui::bg(Color::Reset, a)))), Fill::xy(Align::e(Fixed::x(w_c, Tui::bg(Color::Reset, c)))), ), ) }) } }