mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
parent
c954965ae1
commit
4ff4ea8173
1 changed files with 74 additions and 10 deletions
|
|
@ -5,10 +5,10 @@ impl<T: Content<TuiOut>, U: Content<TuiOut>> Content<TuiOut> for FieldH<T, U> {
|
|||
fn content (&self) -> impl Render<TuiOut> {
|
||||
let Self(ItemTheme { darkest, dark, lighter, lightest, .. }, title, value) = self;
|
||||
row!(
|
||||
Tui::fg_bg(dark.rgb, darkest.rgb, "▐"),
|
||||
Tui::fg_bg(lighter.rgb, dark.rgb, Tui::bold(true, title)),
|
||||
Tui::fg_bg(dark.rgb, darkest.rgb, "▌"),
|
||||
Tui::fg_bg(lightest.rgb, darkest.rgb, value),
|
||||
Tui::fg_bg(dark.rgb, darkest.rgb, "▐"),
|
||||
Tui::fg_bg(lightest.rgb, dark.rgb, title),
|
||||
Tui::fg_bg(dark.rgb, darkest.rgb, "▌"),
|
||||
Tui::fg_bg(lightest.rgb, darkest.rgb, Tui::bold(true, value)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -17,13 +17,77 @@ pub struct FieldV<T, U>(pub ItemTheme, pub T, pub U);
|
|||
impl<T: Content<TuiOut>, U: Content<TuiOut>> Content<TuiOut> for FieldV<T, U> {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
let Self(ItemTheme { darkest, dark, lighter, lightest, .. }, title, value) = self;
|
||||
let sep1 = Tui::bg(darkest.rgb, Tui::fg(dark.rgb, "▐"));
|
||||
let sep2 = Tui::bg(darkest.rgb, Tui::fg(dark.rgb, "▌"));
|
||||
let title = Tui::bg(dark.rgb, Tui::fg(lighter.rgb, Tui::bold(true, title)));
|
||||
let value = Tui::bg(darkest.rgb, Tui::fg(lightest.rgb, value));
|
||||
Bsp::n(
|
||||
Align::w(value),
|
||||
Fill::x(Align::w(row!(sep1, title, sep2)))
|
||||
Align::w(Tui::bg(darkest.rgb, Tui::fg(lightest.rgb, Tui::bold(true, value)))),
|
||||
Fill::x(Align::w(row!(
|
||||
Tui::bg(darkest.rgb, Tui::fg(dark.rgb, "▐")),
|
||||
Tui::bg(dark.rgb, Tui::fg(lightest.rgb, title)),
|
||||
Tui::bg(darkest.rgb, Tui::fg(dark.rgb, "▌")),
|
||||
)))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO:
|
||||
pub struct Field<T, U> {
|
||||
pub direction: Direction,
|
||||
pub label: Option<T>,
|
||||
pub label_fg: Option<ItemColor>,
|
||||
pub label_bg: Option<ItemColor>,
|
||||
pub label_align: Option<Direction>,
|
||||
pub value: Option<U>,
|
||||
pub value_fg: Option<ItemColor>,
|
||||
pub value_bg: Option<ItemColor>,
|
||||
pub value_align: Option<Direction>,
|
||||
}
|
||||
impl<T: Content<TuiOut>, U: Content<TuiOut>> Content<TuiOut> for Field<T, U> {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
"TODO"
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, U> Field<T, U> {
|
||||
pub fn new (direction: Direction) -> Field<(), ()> {
|
||||
Field {
|
||||
direction,
|
||||
label: None,
|
||||
label_fg: None,
|
||||
label_bg: None,
|
||||
label_align: None,
|
||||
value: None,
|
||||
value_fg: None,
|
||||
value_bg: None,
|
||||
value_align: None,
|
||||
}
|
||||
}
|
||||
fn label <L> (
|
||||
self,
|
||||
label: Option<L>,
|
||||
align: Option<Direction>,
|
||||
fg: Option<ItemColor>,
|
||||
bg: Option<ItemColor>
|
||||
) -> Field<L, U> {
|
||||
Field {
|
||||
label,
|
||||
label_fg: fg,
|
||||
label_bg: bg,
|
||||
label_align: align,
|
||||
..self
|
||||
}
|
||||
}
|
||||
fn value <V> (
|
||||
self,
|
||||
value: Option<V>,
|
||||
align: Option<Direction>,
|
||||
fg: Option<ItemColor>,
|
||||
bg: Option<ItemColor>
|
||||
) -> Field<T, V> {
|
||||
Field {
|
||||
value,
|
||||
value_fg: fg,
|
||||
value_bg: bg,
|
||||
value_align: align,
|
||||
..self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue