From 6551a0b2ab6c831dd1d3646ecf55180339275e22 Mon Sep 17 00:00:00 2001 From: Bingus Date: Thu, 11 May 2023 09:12:06 -0700 Subject: Added support for gradients as background variants + other optimizations. --- style/src/button.rs | 3 +++ style/src/theme.rs | 3 +++ 2 files changed, 6 insertions(+) (limited to 'style/src') 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..1b47e2f9 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -217,6 +217,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, -- cgit From 4c1a082f0468a59099bbf8aa8991420a41234948 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 19 May 2023 03:32:21 +0200 Subject: Remove `Builder` abstractions for gradients --- style/src/theme.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'style/src') diff --git a/style/src/theme.rs b/style/src/theme.rs index 1b47e2f9..c9835ca3 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -371,7 +371,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, @@ -896,7 +896,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, @@ -923,7 +923,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, -- cgit From 96aa0379d58ff799493097e3bd0572f9a87da453 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 19 May 2023 03:43:11 +0200 Subject: Implement `custom` helper for `theme::Button` --- style/src/theme.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'style/src') diff --git a/style/src/theme.rs b/style/src/theme.rs index c9835ca3..477bd27b 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -139,6 +139,15 @@ pub enum Button { Custom(Box>), } +impl Button { + /// Creates a custom [`Button`] style variant. + pub fn custom( + style_sheet: impl button::StyleSheet