use async_trait::async_trait; use crossterm::style::ContentStyle; use toss::frame::{Frame, Pos, Size}; use super::Widget; pub struct Background { inner: Box, style: ContentStyle, } impl Background { pub fn new(inner: W, style: ContentStyle) -> Self { Self { inner: Box::new(inner), style, } } } #[async_trait] impl Widget for Background { fn size(&self, frame: &mut Frame, max_width: Option, max_height: Option) -> Size { self.inner.size(frame, max_width, max_height) } async fn render(self: Box, frame: &mut Frame) { let size = frame.size(); for dy in 0..size.height { for dx in 0..size.width { frame.write(Pos::new(dx.into(), dy.into()), (" ", self.style)); } } self.inner.render(frame).await; } }