diff options
author | 2023-05-19 04:37:58 +0200 | |
---|---|---|
committer | 2023-05-19 04:37:58 +0200 | |
commit | cc5d11f1a6fca90ea57e3fb3a69587c65281b6b9 (patch) | |
tree | 349d98171b467b7738874a5ef99ce536512c10eb /style | |
parent | 8e8b1e1eacc4e2c19c9878625f423c8e09e2d3b9 (diff) | |
parent | f7ed645eddd96f7964268367e24abcb5bb78a979 (diff) | |
download | iced-cc5d11f1a6fca90ea57e3fb3a69587c65281b6b9.tar.gz iced-cc5d11f1a6fca90ea57e3fb3a69587c65281b6b9.tar.bz2 iced-cc5d11f1a6fca90ea57e3fb3a69587c65281b6b9.zip |
Merge pull request #1846 from bungoboingo/feat/background-gradients
[Feature] Gradients for Backgrounds
Diffstat (limited to '')
-rw-r--r-- | style/src/button.rs | 3 | ||||
-rw-r--r-- | style/src/theme.rs | 18 |
2 files changed, 18 insertions, 3 deletions
diff --git a/style/src/button.rs b/style/src/button.rs index a564a2b7..32ec28b7 100644 --- a/style/src/button.rs +++ b/style/src/button.rs @@ -68,6 +68,9 @@ pub trait StyleSheet { a: color.a * 0.5, ..color }), + Background::Gradient(gradient) => { + Background::Gradient(gradient.mul_alpha(0.5)) + } }), text_color: Color { a: active.text_color.a * 0.5, diff --git a/style/src/theme.rs b/style/src/theme.rs index d9893bcf..477bd27b 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -139,6 +139,15 @@ pub enum Button { Custom(Box<dyn button::StyleSheet<Style = Theme>>), } +impl Button { + /// Creates a custom [`Button`] style variant. + pub fn custom( + style_sheet: impl button::StyleSheet<Style = Theme> + 'static, + ) -> Self { + Self::Custom(Box::new(style_sheet)) + } +} + impl button::StyleSheet for Theme { type Style = Button; @@ -217,6 +226,9 @@ impl button::StyleSheet for Theme { a: color.a * 0.5, ..color }), + Background::Gradient(gradient) => { + Background::Gradient(gradient.mul_alpha(0.5)) + } }), text_color: Color { a: active.text_color.a * 0.5, @@ -368,7 +380,7 @@ impl container::StyleSheet for Theme { container::Appearance { text_color: None, - background: palette.background.weak.color.into(), + background: Some(palette.background.weak.color.into()), border_radius: 2.0, border_width: 0.0, border_color: Color::TRANSPARENT, @@ -893,7 +905,7 @@ impl scrollable::StyleSheet for Theme { let palette = self.extended_palette(); scrollable::Scrollbar { - background: palette.background.weak.color.into(), + background: Some(palette.background.weak.color.into()), border_radius: 2.0, border_width: 0.0, border_color: Color::TRANSPARENT, @@ -920,7 +932,7 @@ impl scrollable::StyleSheet for Theme { let palette = self.extended_palette(); scrollable::Scrollbar { - background: palette.background.weak.color.into(), + background: Some(palette.background.weak.color.into()), border_radius: 2.0, border_width: 0.0, border_color: Color::TRANSPARENT, |