diff options
author | 2024-09-02 12:11:29 +0200 | |
---|---|---|
committer | 2024-09-02 12:11:29 +0200 | |
commit | 9957481d416f948f6af228013caa221a877c4db4 (patch) | |
tree | ae80560b5275ca70aa929c9df73ebfcd74d34ab1 /widget | |
parent | cb94e40b60d385f28e13476756c11651e5c141d6 (diff) | |
parent | 9d7aa116238465cdc23ff7de868e7ff3b77db6a5 (diff) | |
download | iced-9957481d416f948f6af228013caa221a877c4db4.tar.gz iced-9957481d416f948f6af228013caa221a877c4db4.tar.bz2 iced-9957481d416f948f6af228013caa221a877c4db4.zip |
Merge pull request #2261 from wiiznokes/container-style-colored
Add a colored variant for Container style
Diffstat (limited to 'widget')
-rw-r--r-- | widget/src/container.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/widget/src/container.rs b/widget/src/container.rs index ba315741..c3a66360 100644 --- a/widget/src/container.rs +++ b/widget/src/container.rs @@ -612,6 +612,12 @@ pub trait Catalog { /// A styling function for a [`Container`]. pub type StyleFn<'a, Theme> = Box<dyn Fn(&Theme) -> Style + 'a>; +impl<'a, Theme> From<Style> for StyleFn<'a, Theme> { + fn from(style: Style) -> Self { + Box::new(move |_theme| style) + } +} + impl Catalog for Theme { type Class<'a> = StyleFn<'a, Self>; @@ -629,6 +635,11 @@ pub fn transparent<Theme>(_theme: &Theme) -> Style { Style::default() } +/// A [`Container`] with the given [`Background`]. +pub fn background(background: impl Into<Background>) -> Style { + Style::default().background(background) +} + /// A rounded [`Container`] with a background. pub fn rounded_box(theme: &Theme) -> Style { let palette = theme.extended_palette(); |