diff options
author | 2024-03-06 17:08:28 +0100 | |
---|---|---|
committer | 2024-03-06 17:08:57 +0100 | |
commit | 597a41cea73f078eda04eb3ff40cfda5d37d6135 (patch) | |
tree | 216779f151b68952fd5d668065dc900be08e3e99 /style/src/theme.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 '')
-rw-r--r-- | style/src/theme.rs | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/style/src/theme.rs b/style/src/theme.rs index cac52acd..fd93f776 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -5,13 +5,8 @@ pub use palette::Palette; use crate::application; use crate::core::widget::text; -use crate::menu; -use crate::pick_list; - -use crate::core::Border; use std::fmt; -use std::rc::Rc; use std::sync::Arc; /// A built-in theme. @@ -271,107 +266,4 @@ impl<T: Fn(&Theme) -> application::Appearance> application::StyleSheet for T { } } -/// The style of a menu. -#[derive(Clone, Default)] -pub enum Menu { - /// The default style. - #[default] - Default, - /// A custom style. - Custom(Rc<dyn menu::StyleSheet<Style = Theme>>), -} - -impl menu::StyleSheet for Theme { - type Style = Menu; - - fn appearance(&self, style: &Self::Style) -> menu::Appearance { - match style { - Menu::Default => { - let palette = self.extended_palette(); - - menu::Appearance { - text_color: palette.background.weak.text, - background: palette.background.weak.color.into(), - border: Border { - width: 1.0, - radius: 0.0.into(), - color: palette.background.strong.color, - }, - selected_text_color: palette.primary.strong.text, - selected_background: palette.primary.strong.color.into(), - } - } - Menu::Custom(custom) => custom.appearance(self), - } - } -} - -impl From<PickList> for Menu { - fn from(pick_list: PickList) -> Self { - match pick_list { - PickList::Default => Self::Default, - PickList::Custom(_, menu) => Self::Custom(menu), - } - } -} - -/// The style of a pick list. -#[derive(Clone, Default)] -pub enum PickList { - /// The default style. - #[default] - Default, - /// A custom style. - Custom( - Rc<dyn pick_list::StyleSheet<Style = Theme>>, - Rc<dyn menu::StyleSheet<Style = Theme>>, - ), -} - -impl pick_list::StyleSheet for Theme { - type Style = PickList; - - fn active(&self, style: &Self::Style) -> pick_list::Appearance { - match style { - PickList::Default => { - let palette = self.extended_palette(); - - pick_list::Appearance { - text_color: palette.background.weak.text, - background: palette.background.weak.color.into(), - placeholder_color: palette.background.strong.color, - handle_color: palette.background.weak.text, - border: Border { - radius: 2.0.into(), - width: 1.0, - color: palette.background.strong.color, - }, - } - } - PickList::Custom(custom, _) => custom.active(self), - } - } - - fn hovered(&self, style: &Self::Style) -> pick_list::Appearance { - match style { - PickList::Default => { - let palette = self.extended_palette(); - - pick_list::Appearance { - text_color: palette.background.weak.text, - background: palette.background.weak.color.into(), - placeholder_color: palette.background.strong.color, - handle_color: palette.background.weak.text, - border: Border { - radius: 2.0.into(), - width: 1.0, - color: palette.primary.strong.color, - }, - } - } - PickList::Custom(custom, _) => custom.hovered(self), - } - } -} - impl text::StyleSheet for Theme {} |