diff --git a/src/draw/layout.rs b/src/draw/layout.rs index bb1cf9a..cf90cc5 100644 --- a/src/draw/layout.rs +++ b/src/draw/layout.rs @@ -164,9 +164,9 @@ pub( crate ) fn layout_and_draw( }; 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 diff --git a/src/widget/container.rs b/src/widget/container.rs index d376e6d..e9295c1 100644 --- a/src/widget/container.rs +++ b/src/widget/container.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: LGPL-2.1-only // Copyright (C) 2026 Liberux Labs, S. L. +use crate::theme::Paint; use crate::types::{ Color, Corners }; use crate::render::Canvas; use super::Element; @@ -50,7 +51,11 @@ use super::Element; pub struct Container { pub child: Box>, - pub background: Option, + /// Optional background paint — flat colour, linear or radial + /// gradient. Constructed via [`Container::background`], which + /// accepts anything `Into` (a plain [`Color`] gets + /// promoted to [`Paint::Solid`] via the trait impl). + pub background: Option, /// Slot id of a themed surface (resolved via /// [`crate::theme::resolve_surface`]). When set, takes precedence /// over `background` and paints the full Glass stack instead of a @@ -109,12 +114,15 @@ impl Container self } - /// Set the background fill color. Ignored at paint time if a + /// Set the background fill. Accepts anything convertible to + /// [`Paint`] — a plain [`Color`] (auto-wrapped in + /// [`Paint::Solid`]) or an explicit [`crate::theme::LinearGradient`] + /// / [`crate::theme::RadialGradient`]. Ignored at paint time if a /// themed [`surface`](Self::surface) is set and resolves against /// the active theme. - pub fn background( mut self, color: Color ) -> Self + pub fn background( mut self, paint: impl Into ) -> Self { - self.background = Some( color ); + self.background = Some( paint.into() ); self }