From cc906c83cdf896d94b7ccf91258466714be631f6 Mon Sep 17 00:00:00 2001 From: Nick Senger Date: Wed, 8 Nov 2023 19:12:53 -0800 Subject: feat: quad shadows --- widget/src/button.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'widget/src/button.rs') diff --git a/widget/src/button.rs b/widget/src/button.rs index 0ebb8dcc..44628a6a 100644 --- a/widget/src/button.rs +++ b/widget/src/button.rs @@ -404,6 +404,7 @@ where border_radius: styling.border_radius, border_width: 0.0, border_color: Color::TRANSPARENT, + shadow: Default::default(), }, Background::Color([0.0, 0.0, 0.0, 0.5].into()), ); @@ -415,6 +416,7 @@ where border_radius: styling.border_radius, border_width: styling.border_width, border_color: styling.border_color, + shadow: Default::default(), }, styling .background -- cgit From 370b2f6df799c948188d3949e34112258b2a8498 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 20 Jan 2024 12:25:07 +0100 Subject: Use `Default` implementation of `renderer::Quad` --- widget/src/button.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'widget/src/button.rs') diff --git a/widget/src/button.rs b/widget/src/button.rs index 44628a6a..f9e59f23 100644 --- a/widget/src/button.rs +++ b/widget/src/button.rs @@ -402,9 +402,7 @@ where ..bounds }, border_radius: styling.border_radius, - border_width: 0.0, - border_color: Color::TRANSPARENT, - shadow: Default::default(), + ..renderer::Quad::default() }, Background::Color([0.0, 0.0, 0.0, 0.5].into()), ); @@ -416,7 +414,7 @@ where border_radius: styling.border_radius, border_width: styling.border_width, border_color: styling.border_color, - shadow: Default::default(), + ..renderer::Quad::default() }, styling .background -- cgit From 25f182f933ea6b7c112c8f9a450a98dc9b9eebdd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 20 Jan 2024 13:29:25 +0100 Subject: Introduce `Border` struct analogous to `Shadow` --- widget/src/button.rs | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'widget/src/button.rs') diff --git a/widget/src/button.rs b/widget/src/button.rs index f9e59f23..f052ebab 100644 --- a/widget/src/button.rs +++ b/widget/src/button.rs @@ -11,7 +11,7 @@ use crate::core::widget::tree::{self, Tree}; use crate::core::widget::Operation; use crate::core::{ Background, Clipboard, Color, Element, Layout, Length, Padding, Rectangle, - Shell, Size, Vector, Widget, + Shell, Size, Widget, }; pub use iced_style::button::{Appearance, StyleSheet}; @@ -391,29 +391,11 @@ where style_sheet.active(style) }; - if styling.background.is_some() || styling.border_width > 0.0 { - if styling.shadow_offset != Vector::default() { - // TODO: Implement proper shadow support - renderer.fill_quad( - renderer::Quad { - bounds: Rectangle { - x: bounds.x + styling.shadow_offset.x, - y: bounds.y + styling.shadow_offset.y, - ..bounds - }, - border_radius: styling.border_radius, - ..renderer::Quad::default() - }, - Background::Color([0.0, 0.0, 0.0, 0.5].into()), - ); - } - + if styling.background.is_some() || styling.border.width > 0.0 { renderer.fill_quad( renderer::Quad { bounds, - border_radius: styling.border_radius, - border_width: styling.border_width, - border_color: styling.border_color, + border: styling.border, ..renderer::Quad::default() }, styling -- cgit From e736038d5ff9adb9c011326879d4c772338d12d9 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 20 Jan 2024 13:32:19 +0100 Subject: Add `Shadow` to `button::Appearance` --- widget/src/button.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'widget/src/button.rs') diff --git a/widget/src/button.rs b/widget/src/button.rs index f052ebab..cd141169 100644 --- a/widget/src/button.rs +++ b/widget/src/button.rs @@ -391,11 +391,15 @@ where style_sheet.active(style) }; - if styling.background.is_some() || styling.border.width > 0.0 { + if styling.background.is_some() + || styling.shadow.color.a > 0.0 + || styling.border.width > 0.0 + { renderer.fill_quad( renderer::Quad { bounds, border: styling.border, + shadow: styling.shadow, ..renderer::Quad::default() }, styling -- cgit From bf375587aa52808cdabf4191571f20784315ea99 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 20 Jan 2024 13:34:07 +0100 Subject: Add `Shadow` to `container::Appearance` --- widget/src/button.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'widget/src/button.rs') diff --git a/widget/src/button.rs b/widget/src/button.rs index cd141169..14626dd3 100644 --- a/widget/src/button.rs +++ b/widget/src/button.rs @@ -392,15 +392,14 @@ where }; if styling.background.is_some() - || styling.shadow.color.a > 0.0 || styling.border.width > 0.0 + || styling.shadow.color.a > 0.0 { renderer.fill_quad( renderer::Quad { bounds, border: styling.border, shadow: styling.shadow, - ..renderer::Quad::default() }, styling .background -- cgit