diff options
| author | 2022-07-08 20:07:33 +0200 | |
|---|---|---|
| committer | 2022-07-08 20:07:33 +0200 | |
| commit | bb07d017e8c8e43ac74f66bf649643bebdc5f71d (patch) | |
| tree | 6e780f78ef4eae7dbe590a82ceef11e47289d953 /style/src/theme.rs | |
| parent | fa55dff61db47197a961152285c6a6abfab0b217 (diff) | |
| download | iced-bb07d017e8c8e43ac74f66bf649643bebdc5f71d.tar.gz iced-bb07d017e8c8e43ac74f66bf649643bebdc5f71d.tar.bz2 iced-bb07d017e8c8e43ac74f66bf649643bebdc5f71d.zip | |
Add `Style` variant support to `application::StyleSheet`
Diffstat (limited to '')
| -rw-r--r-- | style/src/theme.rs | 26 | 
1 files changed, 20 insertions, 6 deletions
| diff --git a/style/src/theme.rs b/style/src/theme.rs index 0bae671e..70b32edf 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -48,17 +48,31 @@ impl Default for Theme {      }  } -impl application::StyleSheet for Theme { -    fn background_color(&self) -> Color { -        let palette = self.extended_palette(); +#[derive(Debug, Clone, Copy)] +pub enum Application { +    Default, +    Custom(fn(Theme) -> application::Appearance), +} -        palette.background.base.color +impl Default for Application { +    fn default() -> Self { +        Self::Default      } +} -    fn text_color(&self) -> Color { +impl application::StyleSheet for Theme { +    type Style = Application; + +    fn appearance(&self, style: Self::Style) -> application::Appearance {          let palette = self.extended_palette(); -        palette.background.base.text +        match style { +            Application::Default => application::Appearance { +                background_color: palette.background.base.color, +                text_color: palette.background.base.text, +            }, +            Application::Custom(f) => f(*self), +        }      }  } | 
