mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
tui: ItemPalette->ItemTheme
This commit is contained in:
parent
aa66760b8c
commit
7ba37f3f02
2 changed files with 9 additions and 9 deletions
|
|
@ -88,7 +88,7 @@ impl ItemColor {
|
|||
}
|
||||
|
||||
/// A color in OKHSL and RGB with lighter and darker variants.
|
||||
#[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct ItemPalette {
|
||||
#[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct ItemTheme {
|
||||
pub base: ItemColor,
|
||||
pub light: ItemColor,
|
||||
pub lighter: ItemColor,
|
||||
|
|
@ -98,7 +98,7 @@ impl ItemColor {
|
|||
pub darkest: ItemColor,
|
||||
}
|
||||
|
||||
impl ItemPalette {
|
||||
impl ItemTheme {
|
||||
pub const G: [Self;256] = {
|
||||
let mut builder = konst::array::ArrayBuilder::new();
|
||||
while !builder.is_full() {
|
||||
|
|
@ -109,7 +109,7 @@ impl ItemPalette {
|
|||
let dark = (index as f64 * 0.9) as u8;
|
||||
let darker = (index as f64 * 0.6) as u8;
|
||||
let darkest = (index as f64 * 0.3) as u8;
|
||||
builder.push(ItemPalette {
|
||||
builder.push(ItemTheme {
|
||||
base: ItemColor::from_rgb(Color::Rgb(index, index, index )),
|
||||
light: ItemColor::from_rgb(Color::Rgb(light, light, light, )),
|
||||
lighter: ItemColor::from_rgb(Color::Rgb(lighter, lighter, lighter, )),
|
||||
|
|
@ -171,5 +171,5 @@ impl ItemPalette {
|
|||
}
|
||||
}
|
||||
|
||||
from!(|base: Color| ItemPalette = Self::from_tui_color(base));
|
||||
from!(|base: ItemColor|ItemPalette = Self::from_item_color(base));
|
||||
from!(|base: Color| ItemTheme = Self::from_tui_color(base));
|
||||
from!(|base: ItemColor|ItemTheme = Self::from_item_color(base));
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use crate::*;
|
||||
|
||||
pub struct FieldH<T, U>(pub ItemPalette, pub T, pub U);
|
||||
pub struct FieldH<T, U>(pub ItemTheme, pub T, pub U);
|
||||
impl<T: Content<TuiOut>, U: Content<TuiOut>> Content<TuiOut> for FieldH<T, U> {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
let Self(ItemPalette { darkest, dark, lighter, lightest, .. }, title, value) = self;
|
||||
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)),
|
||||
|
|
@ -13,10 +13,10 @@ impl<T: Content<TuiOut>, U: Content<TuiOut>> Content<TuiOut> for FieldH<T, U> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct FieldV<T, U>(pub ItemPalette, pub T, pub U);
|
||||
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(ItemPalette { darkest, dark, lighter, lightest, .. }, title, value) = self;
|
||||
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)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue