Skip to main content

Module rect_widget

Module rect_widget 

Source
Expand description

RectWidget — a leaf widget that paints a filled and/or stroked rounded rectangle.

RectWidget has no intrinsic content: it fills whatever space its parent proposes (or reports 0×0 when unconstrained) and draws a fill (solid color or gradient), an optional border (a uniform stroke positioned inside / center / outside, or per-side edge fills for an underline), and an optional corner radius. It is the low-level building block for card backgrounds, focus rings, dividers, underlined fields, and highlight overlays.

The fill accepts impl Into<PaintProp> — anything Into<ColorProp> (a raw Color, a theme role such as SurfaceRole::Hover, or a Signal<Color>) for a solid, plus PaintProp::Linear / Radial for a gradient. Border color accepts impl Into<ColorProp>, so reactive interaction-driven colors require no extra wiring.

// A pill-shaped accent badge background:
let _w = RectWidget::new()
    .background(Color::from_rgba(0.2, 0.5, 1.0, 1.0))
    .corner_radius(CornerRadius::uniform(12.0));

Structs§

RectWidget
A leaf widget that paints a filled and/or stroked rounded rectangle.