use crate::prelude::*;
pub struct Background<ID: WidgetId> {
widget_id: ID,
}
impl<ID: WidgetId> Background<ID> {
pub const fn new(widget_id: ID) -> Background<ID> {
Background { widget_id }
}
}
impl<DRAW: DrawTarget<Color = COL>, ID: WidgetId, COL: PixelColor> Widget<DRAW, COL>
for Background<ID>
{
fn draw(&mut self, ui: &mut Ui<DRAW, COL>) -> GuiResult<Response> {
let widget_state = ui.get_widget_state(self.widget_id)?;
if widget_state.compare_set(RenderStatus::Rendered) {
return Ok(Response::Idle);
}
ui.clear_background()?;
Ok(Response::Idle)
}
}