From 597a41cea73f078eda04eb3ff40cfda5d37d6135 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 6 Mar 2024 17:08:28 +0100 Subject: Simplify theming for `PickList`, `ComboBox`, and `Menu` widgets --- widget/src/container.rs | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'widget/src/container.rs') 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 { - ::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), - ..::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() } } -- cgit