use ribir_painter::Radius;
use wrap_render::WrapRender;
use super::*;
#[derive(Default, Clone)]
pub struct RadiusWidget {
pub radius: Radius,
}
impl Declare for RadiusWidget {
type Builder = FatObj<()>;
#[inline]
fn declarer() -> Self::Builder { FatObj::new(()) }
}
impl WrapRender for RadiusWidget {
fn paint(&self, host: &dyn Render, ctx: &mut PaintingCtx) {
let mut provider = Provider::new(self.radius);
provider.setup(ctx.as_mut());
host.paint(ctx);
provider.restore(ctx.as_mut());
}
#[inline]
fn wrapper_dirty_phase(&self) -> DirtyPhase { DirtyPhase::Paint }
#[cfg(feature = "debug")]
fn debug_type(&self) -> Option<&'static str> { Some("radius") }
#[cfg(feature = "debug")]
fn debug_properties(&self) -> Option<serde_json::Value> {
let r = self.radius;
Some(serde_json::json!({
"corners": {
"topLeft": r.top_left,
"topRight": r.top_right,
"bottomLeft": r.bottom_left,
"bottomRight": r.bottom_right
}
}))
}
}
impl_compose_child_for_wrap_render!(RadiusWidget);