wip: component playground; Align primitive

This commit is contained in:
🪞👃🪞 2024-09-07 20:54:49 +03:00
parent 4cca03352a
commit 5fc7da3aca
12 changed files with 181 additions and 42 deletions

View file

@ -28,27 +28,27 @@ impl Render<Tui> for AddSampleModal {
to.make_dim();
let area = center_box(
area,
64.max(area.width.saturating_sub(8)),
20.max(area.width.saturating_sub(8)),
64.max(area.w().saturating_sub(8)),
20.max(area.w().saturating_sub(8)),
);
to.fill_fg(area, Color::Reset);
to.fill_bg(area, Nord::bg_lo(true, true));
to.fill_char(area, ' ');
to.blit(&format!("{}", &self.dir.to_string_lossy()), area.x+2, area.y+1, Some(Style::default().bold()))?;
to.blit(&"Select sample:", area.x+2, area.y+2, Some(Style::default().bold()))?;
to.blit(&format!("{}", &self.dir.to_string_lossy()), area.x()+2, area.y()+1, Some(Style::default().bold()))?;
to.blit(&"Select sample:", area.x()+2, area.y()+2, Some(Style::default().bold()))?;
for (i, (is_dir, name)) in self.subdirs.iter()
.map(|path|(true, path))
.chain(self.files.iter().map(|path|(false, path)))
.enumerate()
.skip(self.offset)
{
if i >= area.height as usize - 4 {
if i >= area.h() as usize - 4 {
break
}
let t = if is_dir { "" } else { "" };
let line = format!("{t} {}", name.to_string_lossy());
let line = &line[..line.len().min(area.width as usize - 4)];
to.blit(&line, area.x + 2, area.y + 3 + i as u16, Some(if i == self.cursor {
let line = &line[..line.len().min(area.w() as usize - 4)];
to.blit(&line, area.x() + 2, area.y() + 3 + i as u16, Some(if i == self.cursor {
Style::default().green()
} else {
Style::default().white()