diff options
author | 2024-03-06 17:08:28 +0100 | |
---|---|---|
committer | 2024-03-06 17:08:57 +0100 | |
commit | 597a41cea73f078eda04eb3ff40cfda5d37d6135 (patch) | |
tree | 216779f151b68952fd5d668065dc900be08e3e99 /widget/src/container.rs | |
parent | 9b2fd6416775cb27af69e34fb20063d28b4314eb (diff) | |
download | iced-597a41cea73f078eda04eb3ff40cfda5d37d6135.tar.gz iced-597a41cea73f078eda04eb3ff40cfda5d37d6135.tar.bz2 iced-597a41cea73f078eda04eb3ff40cfda5d37d6135.zip |
Simplify theming for `PickList`, `ComboBox`, and `Menu` widgets
Diffstat (limited to 'widget/src/container.rs')
-rw-r--r-- | widget/src/container.rs | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/widget/src/container.rs b/widget/src/container.rs index 66e80820..58a24339 100644 --- a/widget/src/container.rs +++ b/widget/src/container.rs @@ -61,7 +61,7 @@ where max_height: f32::INFINITY, horizontal_alignment: alignment::Horizontal::Left, vertical_alignment: alignment::Vertical::Top, - style: Theme::default(), + style: Theme::style(), clip: false, content, } @@ -540,24 +540,24 @@ pub enum Status { /// The style of a [`Container`] for a theme. pub trait Style { /// The default style of a [`Container`]. - fn default() -> fn(&Self, Status) -> Appearance; + fn style() -> fn(&Self, Status) -> Appearance; } impl Style for Theme { - fn default() -> fn(&Self, Status) -> Appearance { + fn style() -> fn(&Self, Status) -> Appearance { transparent } } impl Style for Appearance { - fn default() -> fn(&Self, Status) -> Appearance { + fn style() -> fn(&Self, Status) -> Appearance { |appearance, _status| *appearance } } /// A transparent [`Container`]. pub fn transparent(_theme: &Theme, _status: Status) -> Appearance { - <Appearance as Default>::default() + Appearance::default() } /// A rounded [`Container`] with a background. @@ -567,6 +567,21 @@ pub fn box_(theme: &Theme, _status: Status) -> Appearance { Appearance { background: Some(palette.background.weak.color.into()), border: Border::with_radius(2), - ..<Appearance as Default>::default() + ..Appearance::default() + } +} + +/// A bordered [`Container`] with a background. +pub fn bordered_box(theme: &Theme, _status: Status) -> Appearance { + let palette = theme.extended_palette(); + + Appearance { + background: Some(palette.background.weak.color.into()), + border: Border { + width: 1.0, + radius: 0.0.into(), + color: palette.background.strong.color, + }, + ..Appearance::default() } } |