diff options
author | 2024-03-05 03:48:08 +0100 | |
---|---|---|
committer | 2024-03-05 03:48:08 +0100 | |
commit | 29326215ccf13e1d1e25bf3bf5ada007856bff69 (patch) | |
tree | 9a286433affc511da2d8926d0f6862b664184b56 /style | |
parent | 1f0a0c235a7729cf2d5716efeecb9c4dc972fdfa (diff) | |
download | iced-29326215ccf13e1d1e25bf3bf5ada007856bff69.tar.gz iced-29326215ccf13e1d1e25bf3bf5ada007856bff69.tar.bz2 iced-29326215ccf13e1d1e25bf3bf5ada007856bff69.zip |
Simplify theming for `Container` widget
Diffstat (limited to 'style')
-rw-r--r-- | style/src/theme.rs | 55 |
1 files changed, 1 insertions, 54 deletions
diff --git a/style/src/theme.rs b/style/src/theme.rs index 81303e68..c3260427 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -20,7 +20,7 @@ use crate::text_editor; use crate::text_input; use crate::toggler; -use crate::core::{Background, Border, Color, Shadow}; +use crate::core::{Background, Border, Color}; use std::fmt; use std::rc::Rc; @@ -283,59 +283,6 @@ impl<T: Fn(&Theme) -> application::Appearance> application::StyleSheet for T { } } -/// The style of a container. -#[derive(Default)] -pub enum Container { - /// No style. - #[default] - Transparent, - /// A simple box. - Box, - /// A custom style. - Custom(Box<dyn container::StyleSheet<Style = Theme>>), -} - -impl From<container::Appearance> for Container { - fn from(appearance: container::Appearance) -> Self { - Self::Custom(Box::new(move |_: &_| appearance)) - } -} - -impl<T: Fn(&Theme) -> container::Appearance + 'static> From<T> for Container { - fn from(f: T) -> Self { - Self::Custom(Box::new(f)) - } -} - -impl container::StyleSheet for Theme { - type Style = Container; - - fn appearance(&self, style: &Self::Style) -> container::Appearance { - match style { - Container::Transparent => container::Appearance::default(), - Container::Box => { - let palette = self.extended_palette(); - - container::Appearance { - text_color: None, - background: Some(palette.background.weak.color.into()), - border: Border::with_radius(2), - shadow: Shadow::default(), - } - } - Container::Custom(custom) => custom.appearance(self), - } - } -} - -impl<T: Fn(&Theme) -> container::Appearance> container::StyleSheet for T { - type Style = Theme; - - fn appearance(&self, style: &Self::Style) -> container::Appearance { - (self)(style) - } -} - impl slider::StyleSheet for Theme { fn default() -> fn(&Self, slider::Status) -> slider::Appearance { slider |