refactor layout

This commit is contained in:
🪞👃🪞 2025-04-03 23:40:22 +03:00
parent 48f651fc0f
commit 52102d771d

View file

@ -13,14 +13,27 @@ impl Taggart {
impl Content<TuiOut> for Taggart { impl Content<TuiOut> for Taggart {
fn content (&self) -> impl Render<TuiOut> { fn content (&self) -> impl Render<TuiOut> {
let size = format!("{}x{}", self.display.w(), self.display.h()); let w = self.display.w();
let h = self.display.h();
let sizer = Fill::xy(&self.display); let sizer = Fill::xy(&self.display);
let titlebar = status_bar( let value_bar = |x|Bsp::n(self.value_bar(), x);
let mode_bar = |x|Bsp::n(self.mode_bar(format!("{w}x{h}")), x);
let title_bar = |x|Bsp::s(self.title_bar(), x);
let sized = |x|Bsp::b(sizer, Fill::xy(x));
value_bar(mode_bar(title_bar(sized(TreeTable(self)))))
}
}
impl Taggart {
fn title_bar (&self) -> impl Content<TuiOut> {
status_bar(
Color::Rgb(0, 0, 0), Color::Rgb(0, 0, 0),
Color::Rgb(192, 192, 192), Color::Rgb(192, 192, 192),
Align::w(self.columns.header()) Align::w(self.columns.header())
); )
let value_bar = status_bar( }
fn value_bar (&self) -> impl Content<TuiOut> {
status_bar(
Color::Rgb(192, 192, 192), Color::Rgb(192, 192, 192),
Color::Rgb(0, 0, 0), Color::Rgb(0, 0, 0),
Fill::x( Fill::x(
@ -39,8 +52,10 @@ impl Content<TuiOut> for Taggart {
))) )))
) )
) )
); )
let mode_bar = status_bar( }
fn mode_bar (&self, size: String) -> impl Content<TuiOut> {
status_bar(
Color::Rgb(0, 0, 0), Color::Rgb(0, 0, 0),
Color::Rgb(192, 192, 192), Color::Rgb(192, 192, 192),
Fill::x(Bsp::a( Fill::x(Bsp::a(
@ -58,19 +73,6 @@ impl Content<TuiOut> for Taggart {
}))), }))),
Fill::x(Align::e(size)), Fill::x(Align::e(size)),
)) ))
);
Bsp::n(
value_bar,
Bsp::n(
mode_bar,
Bsp::s(
titlebar,
Bsp::b(
sizer,
Fill::xy(TreeTable(self))
)
)
)
) )
} }
} }