From b58fbdfd306090a0d6cace1d92cbd2fab33dffe5 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Fri, 25 Apr 2025 19:34:32 +0300 Subject: [PATCH] sampler_view: default empty grid --- crates/sampler/src/sampler_view.rs | 44 ++++++++++++++++++++++-------- deps/tengri | 2 +- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/crates/sampler/src/sampler_view.rs b/crates/sampler/src/sampler_view.rs index e50c925d..926e1a13 100644 --- a/crates/sampler/src/sampler_view.rs +++ b/crates/sampler/src/sampler_view.rs @@ -1,22 +1,44 @@ use crate::*; impl Sampler { - pub fn view_grid (&self) -> impl Content { + pub fn view_grid (&self) -> impl Content + use<'_> { let cells_x = 8u16; let cells_y = 8u16; - let cell_width = 8u16; + let cell_width = 10u16; let cell_height = 2u16; let width = cells_x * cell_width; let height = cells_y * cell_height; - let pos = |a|Align::c(Tui::bg(Color::Black, Fixed::xy(width, height, a))); - let cell = move|y, _|Fixed::xy(cell_width, cell_height, "x"); - let rows = move|x, _|Map::south(cell_height, move||0..cells_y, cell); - let cols = Map::east(cell_width, move||0..cells_x, rows); - pos(cols) - //Fixed::xy(cell_width, 2, Bsp::s( - //format!("{x}x{y}"), - //RepeatH(Phat::<()>::HI), - //))))))))) + let cols = Map::east( + cell_width, + move||0..cells_x, + move|x, _|Map::south( + cell_height, + move||0..cells_y, + move|y, _|self.view_grid_cell("........", x, y, cell_width, cell_height) + ) + ); + cols + } + pub fn view_grid_cell <'a> ( + &'a self, name: &'a str, x: u16, y: u16, w: u16, h: u16 + ) -> impl Content + 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))), + ), + )) } } diff --git a/deps/tengri b/deps/tengri index d84bfda8..e32bb541 160000 --- a/deps/tengri +++ b/deps/tengri @@ -1 +1 @@ -Subproject commit d84bfda8408d5a1906d4c9951f00e961d9c273ce +Subproject commit e32bb541e02abcaa3e463c4bf7ebf642593b1853