container: generalise background from Color to Paint

`Container::background` now stores `Option<Paint>` instead of `Option<Color>`, and the builder accepts `impl Into<Paint>` so callers can pass a plain `Color` (auto-wrapped in `Paint::Solid` via the trait impl) or an explicit `LinearGradient` / `RadialGradient`. `layout_and_draw` switches from `canvas.fill_rect( rect, bg, corners )` to `canvas.fill_paint_rect( rect, &bg, corners )` to consume the wider type.
No behaviour change for existing call sites — solid-colour containers keep working unchanged thanks to the `Into<Paint>` for `Color`.
This commit is contained in:
2026-05-11 12:20:28 +02:00
parent 703a1ed228
commit 39fbafec24
2 changed files with 14 additions and 6 deletions

View File

@@ -164,9 +164,9 @@ pub( crate ) fn layout_and_draw<Msg: Clone>(
};
if !painted
{
if let Some( bg ) = c.background
if let Some( ref bg ) = c.background
{
canvas.fill_rect( rect, bg, c.corners );
canvas.fill_paint_rect( rect, bg, c.corners );
}
}
if let Some( ( color, width ) ) = c.border