sampler_view: default empty grid

This commit is contained in:
🪞👃🪞 2025-04-25 19:34:32 +03:00
parent 8b0e484114
commit b58fbdfd30
2 changed files with 34 additions and 12 deletions

View file

@ -1,22 +1,44 @@
use crate::*; use crate::*;
impl Sampler { impl Sampler {
pub fn view_grid (&self) -> impl Content<TuiOut> { pub fn view_grid (&self) -> impl Content<TuiOut> + use<'_> {
let cells_x = 8u16; let cells_x = 8u16;
let cells_y = 8u16; let cells_y = 8u16;
let cell_width = 8u16; let cell_width = 10u16;
let cell_height = 2u16; let cell_height = 2u16;
let width = cells_x * cell_width; let width = cells_x * cell_width;
let height = cells_y * cell_height; let height = cells_y * cell_height;
let pos = |a|Align::c(Tui::bg(Color::Black, Fixed::xy(width, height, a))); let cols = Map::east(
let cell = move|y, _|Fixed::xy(cell_width, cell_height, "x"); cell_width,
let rows = move|x, _|Map::south(cell_height, move||0..cells_y, cell); move||0..cells_x,
let cols = Map::east(cell_width, move||0..cells_x, rows); move|x, _|Map::south(
pos(cols) cell_height,
//Fixed::xy(cell_width, 2, Bsp::s( move||0..cells_y,
//format!("{x}x{y}"), move|y, _|self.view_grid_cell("........", x, y, cell_width, cell_height)
//RepeatH(Phat::<()>::HI), )
//))))))))) );
cols
}
pub fn view_grid_cell <'a> (
&'a self, name: &'a str, x: u16, y: u16, w: u16, h: u16
) -> impl Content<TuiOut> + use<'a> {
let hi_fg = Color::Rgb(64, 64, 64);
let hi_bg = if y == 0 { Color::Reset } else { Color::Rgb(64, 64, 64) /*prev*/ };
let tx_fg = Color::Rgb(255, 255, 255);
let tx_bg = if x as usize == self.cursor.0 && y as usize == self.cursor.1 {
Color::Rgb(96, 96, 96)
} else {
Color::Rgb(64, 64, 64)
};
let lo_fg = Color::Rgb(64, 64, 64);
let lo_bg = if y == 7 { Color::Reset } else { tx_bg };
Fixed::xy(w, h, Bsp::s(
Fixed::y(1, Tui::fg_bg(hi_fg, hi_bg, RepeatH(Phat::<()>::LO))),
Bsp::n(
Fixed::y(1, Tui::fg_bg(lo_fg, lo_bg, RepeatH(Phat::<()>::HI))),
Fill::x(Fixed::y(1, Tui::fg_bg(tx_fg, tx_bg, name))),
),
))
} }
} }

2
deps/tengri vendored

@ -1 +1 @@
Subproject commit d84bfda8408d5a1906d4c9951f00e961d9c273ce Subproject commit e32bb541e02abcaa3e463c4bf7ebf642593b1853