use crate::widget::*;
#[derive(Debug, Default)]
pub struct Fill<W> {
content: W,
}
impl<W> Fill<W> {
pub fn new(widget: W) -> Self {
Fill { content: widget }
}
pub fn content(&self) -> &W {
&self.content
}
pub fn content_mut(&mut self) -> &mut W {
&mut self.content
}
}
impl<W> AnchorPlacementEnabled for Fill<W> {}
impl<W, M, A: AppEvent> Widget<M, A> for Fill<W>
where
W: Widget<M, A>,
{
fn update(
&mut self,
model: &mut M,
input: &Event<A>,
screen: &mut Screen,
painter: &Painter,
) -> Window {
if matches!(input, Event::Refresh(_)) {
painter.fill(screen);
}
self.content.update_asserted(model, input, screen, painter);
painter.scope()
}
}