summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/src/element.rs1
-rw-r--r--core/src/lib.rs2
-rw-r--r--core/src/renderer.rs5
-rw-r--r--core/src/shadow.rs15
-rw-r--r--examples/custom_quad/src/main.rs53
-rw-r--r--examples/custom_widget/src/main.rs1
-rw-r--r--examples/loading_spinners/src/linear.rs3
-rw-r--r--examples/modal/src/main.rs1
-rw-r--r--graphics/src/damage.rs25
-rw-r--r--graphics/src/primitive.rs6
-rw-r--r--graphics/src/renderer.rs3
-rw-r--r--src/lib.rs3
-rw-r--r--tiny_skia/src/backend.rs106
-rw-r--r--wgpu/src/layer.rs6
-rw-r--r--wgpu/src/quad.rs9
-rw-r--r--wgpu/src/quad/solid.rs6
-rw-r--r--wgpu/src/shader/quad.wgsl18
-rw-r--r--wgpu/src/shader/quad/solid.wgsl36
-rw-r--r--widget/src/button.rs2
-rw-r--r--widget/src/checkbox.rs1
-rw-r--r--widget/src/container.rs1
-rw-r--r--widget/src/overlay/menu.rs2
-rw-r--r--widget/src/pane_grid.rs3
-rw-r--r--widget/src/pick_list.rs1
-rw-r--r--widget/src/progress_bar.rs2
-rw-r--r--widget/src/radio.rs2
-rw-r--r--widget/src/rule.rs1
-rw-r--r--widget/src/scrollable.rs2
-rw-r--r--widget/src/slider.rs3
-rw-r--r--widget/src/text_editor.rs3
-rw-r--r--widget/src/text_input.rs3
-rw-r--r--widget/src/toggler.rs2
-rw-r--r--widget/src/vertical_slider.rs3
33 files changed, 305 insertions, 25 deletions
diff --git a/core/src/element.rs b/core/src/element.rs
index 8b510218..b264ad77 100644
--- a/core/src/element.rs
+++ b/core/src/element.rs
@@ -540,6 +540,7 @@ where
border_color: color,
border_width: 1.0,
border_radius: 0.0.into(),
+ shadow: Default::default()
},
Color::TRANSPARENT,
);
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 864df6e6..b326d0f3 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -27,6 +27,7 @@ pub mod layout;
pub mod mouse;
pub mod overlay;
pub mod renderer;
+pub mod shadow;
pub mod svg;
pub mod text;
pub mod time;
@@ -70,6 +71,7 @@ pub use pixels::Pixels;
pub use point::Point;
pub use rectangle::Rectangle;
pub use renderer::Renderer;
+pub use shadow::Shadow;
pub use shell::Shell;
pub use size::Size;
pub use text::Text;
diff --git a/core/src/renderer.rs b/core/src/renderer.rs
index 1b327e56..481048b0 100644
--- a/core/src/renderer.rs
+++ b/core/src/renderer.rs
@@ -5,7 +5,7 @@ mod null;
#[cfg(debug_assertions)]
pub use null::Null;
-use crate::{Background, BorderRadius, Color, Rectangle, Vector};
+use crate::{Background, BorderRadius, Color, Rectangle, Shadow, Vector};
/// A component that can be used by widgets to draw themselves on a screen.
pub trait Renderer: Sized {
@@ -45,6 +45,9 @@ pub struct Quad {
/// The border color of the [`Quad`].
pub border_color: Color,
+
+ /// The shadow of the [`Quad`].
+ pub shadow: Shadow,
}
/// The styling attributes of a [`Renderer`].
diff --git a/core/src/shadow.rs b/core/src/shadow.rs
new file mode 100644
index 00000000..238ea36a
--- /dev/null
+++ b/core/src/shadow.rs
@@ -0,0 +1,15 @@
+//! Shadow
+use crate::{Color, Vector};
+
+/// A shadow
+#[derive(Debug, Clone, Copy, PartialEq, Default)]
+pub struct Shadow {
+ /// The color of the shadow
+ pub color: Color,
+
+ /// The offset of the shadow
+ pub offset: Vector,
+
+ /// The blur_radius of the shadow
+ pub blur_radius: f32,
+}
diff --git a/examples/custom_quad/src/main.rs b/examples/custom_quad/src/main.rs
index cc9ad528..01f4aa10 100644
--- a/examples/custom_quad/src/main.rs
+++ b/examples/custom_quad/src/main.rs
@@ -3,21 +3,28 @@ mod quad {
use iced::advanced::layout::{self, Layout};
use iced::advanced::renderer;
use iced::advanced::widget::{self, Widget};
- use iced::mouse;
+ use iced::{mouse, Shadow};
use iced::{Color, Element, Length, Rectangle, Size};
pub struct CustomQuad {
size: f32,
radius: [f32; 4],
border_width: f32,
+ shadow: Shadow,
}
impl CustomQuad {
- pub fn new(size: f32, radius: [f32; 4], border_width: f32) -> Self {
+ pub fn new(
+ size: f32,
+ radius: [f32; 4],
+ border_width: f32,
+ shadow: Shadow,
+ ) -> Self {
Self {
size,
radius,
border_width,
+ shadow,
}
}
}
@@ -58,6 +65,7 @@ mod quad {
border_radius: self.radius.into(),
border_width: self.border_width,
border_color: Color::from_rgb(1.0, 0.0, 0.0),
+ shadow: self.shadow,
},
Color::BLACK,
);
@@ -75,7 +83,9 @@ mod quad {
}
use iced::widget::{column, container, slider, text};
-use iced::{Alignment, Element, Length, Sandbox, Settings};
+use iced::{
+ Alignment, Color, Element, Length, Sandbox, Settings, Shadow, Vector,
+};
pub fn main() -> iced::Result {
Example::run(Settings::default())
@@ -84,6 +94,7 @@ pub fn main() -> iced::Result {
struct Example {
radius: [f32; 4],
border_width: f32,
+ shadow: Shadow,
}
#[derive(Debug, Clone, Copy)]
@@ -94,6 +105,9 @@ enum Message {
RadiusBottomRightChanged(f32),
RadiusBottomLeftChanged(f32),
BorderWidthChanged(f32),
+ ShadowXOffsetChanged(f32),
+ ShadowYOffsetChanged(f32),
+ ShadowBlurRadiusChanged(f32),
}
impl Sandbox for Example {
@@ -103,6 +117,11 @@ impl Sandbox for Example {
Self {
radius: [50.0; 4],
border_width: 0.0,
+ shadow: Shadow {
+ color: Color::from_rgba(0.0, 0.0, 0.0, 0.8),
+ offset: Vector::new(0.0, 8.0),
+ blur_radius: 16.0,
+ },
}
}
@@ -128,14 +147,33 @@ impl Sandbox for Example {
Message::BorderWidthChanged(width) => {
self.border_width = width;
}
+ Message::ShadowXOffsetChanged(x) => {
+ self.shadow.offset.x = x;
+ }
+ Message::ShadowYOffsetChanged(y) => {
+ self.shadow.offset.y = y;
+ }
+ Message::ShadowBlurRadiusChanged(s) => {
+ self.shadow.blur_radius = s;
+ }
}
}
fn view(&self) -> Element<Message> {
let [tl, tr, br, bl] = self.radius;
+ let Shadow {
+ offset: Vector { x: sx, y: sy },
+ blur_radius: sr,
+ ..
+ } = self.shadow;
let content = column![
- quad::CustomQuad::new(200.0, self.radius, self.border_width),
+ quad::CustomQuad::new(
+ 200.0,
+ self.radius,
+ self.border_width,
+ self.shadow
+ ),
text(format!("Radius: {tl:.2}/{tr:.2}/{br:.2}/{bl:.2}")),
slider(1.0..=100.0, tl, Message::RadiusTopLeftChanged).step(0.01),
slider(1.0..=100.0, tr, Message::RadiusTopRightChanged).step(0.01),
@@ -145,6 +183,13 @@ impl Sandbox for Example {
.step(0.01),
slider(1.0..=10.0, self.border_width, Message::BorderWidthChanged)
.step(0.01),
+ text(format!("Shadow: {sx:.2}x{sy:.2}, {sr:.2}")),
+ slider(-100.0..=100.0, sx, Message::ShadowXOffsetChanged)
+ .step(0.01),
+ slider(-100.0..=100.0, sy, Message::ShadowYOffsetChanged)
+ .step(0.01),
+ slider(0.0..=100.0, sr, Message::ShadowBlurRadiusChanged)
+ .step(0.01),
]
.padding(20)
.spacing(20)
diff --git a/examples/custom_widget/src/main.rs b/examples/custom_widget/src/main.rs
index 7ffb4cd0..f5c34d6b 100644
--- a/examples/custom_widget/src/main.rs
+++ b/examples/custom_widget/src/main.rs
@@ -65,6 +65,7 @@ mod circle {
border_radius: self.radius.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
Color::BLACK,
);
diff --git a/examples/loading_spinners/src/linear.rs b/examples/loading_spinners/src/linear.rs
index 497e0834..86469681 100644
--- a/examples/loading_spinners/src/linear.rs
+++ b/examples/loading_spinners/src/linear.rs
@@ -228,6 +228,7 @@ where
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
Background::Color(custom_style.track_color),
);
@@ -244,6 +245,7 @@ where
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
Background::Color(custom_style.bar_color),
),
@@ -261,6 +263,7 @@ where
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
Background::Color(custom_style.bar_color),
),
diff --git a/examples/modal/src/main.rs b/examples/modal/src/main.rs
index 963c839e..531a19b5 100644
--- a/examples/modal/src/main.rs
+++ b/examples/modal/src/main.rs
@@ -477,6 +477,7 @@ mod modal {
border_radius: BorderRadius::default(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
Color {
a: 0.80,
diff --git a/graphics/src/damage.rs b/graphics/src/damage.rs
index 59e9f5b4..2aec9b25 100644
--- a/graphics/src/damage.rs
+++ b/graphics/src/damage.rs
@@ -78,9 +78,28 @@ impl<T: Damage> Damage for Primitive<T> {
// damage bounds (?)
raw.clip_bounds.expand(1.5)
}
- Self::Quad { bounds, .. }
- | Self::Image { bounds, .. }
- | Self::Svg { bounds, .. } => bounds.expand(1.0),
+ Self::Quad {
+ bounds,
+ shadow_offset,
+ shadow_blur_radius,
+ ..
+ } => {
+ let bounds_with_shadow = Rectangle {
+ x: bounds.x + shadow_offset.x.min(0.0) - shadow_blur_radius,
+ y: bounds.y + shadow_offset.y.min(0.0) - shadow_blur_radius,
+ width: bounds.width
+ + shadow_offset.x.abs()
+ + shadow_blur_radius * 2.0,
+ height: bounds.height
+ + shadow_offset.y.abs()
+ + shadow_blur_radius * 2.0,
+ };
+
+ bounds_with_shadow.expand(1.0)
+ }
+ Self::Image { bounds, .. } | Self::Svg { bounds, .. } => {
+ bounds.expand(1.0)
+ }
Self::Clip { bounds, .. } => bounds.expand(1.0),
Self::Group { primitives } => primitives
.iter()
diff --git a/graphics/src/primitive.rs b/graphics/src/primitive.rs
index 20affaaf..795d9609 100644
--- a/graphics/src/primitive.rs
+++ b/graphics/src/primitive.rs
@@ -71,6 +71,12 @@ pub enum Primitive<T> {
border_width: f32,
/// The border color of the quad
border_color: Color,
+ /// The shadow color of the quad
+ shadow_color: Color,
+ /// The shadow offset of the quad
+ shadow_offset: Vector,
+ /// The shadow blur radius of the quad
+ shadow_blur_radius: f32,
},
/// An image primitive
Image {
diff --git a/graphics/src/renderer.rs b/graphics/src/renderer.rs
index 1b0f5c5b..bd640097 100644
--- a/graphics/src/renderer.rs
+++ b/graphics/src/renderer.rs
@@ -127,6 +127,9 @@ impl<B: Backend, T> iced_core::Renderer for Renderer<B, T> {
border_radius: quad.border_radius.into(),
border_width: quad.border_width,
border_color: quad.border_color,
+ shadow_color: quad.shadow.color,
+ shadow_offset: quad.shadow.offset,
+ shadow_blur_radius: quad.shadow.blur_radius,
});
}
diff --git a/src/lib.rs b/src/lib.rs
index 446590ec..02bb227a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -191,7 +191,8 @@ pub use crate::core::alignment;
pub use crate::core::gradient;
pub use crate::core::{
color, Alignment, Background, BorderRadius, Color, ContentFit, Degrees,
- Gradient, Length, Padding, Pixels, Point, Radians, Rectangle, Size, Vector,
+ Gradient, Length, Padding, Pixels, Point, Radians, Rectangle, Shadow, Size,
+ Vector,
};
pub mod clipboard {
diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs
index d1393b4d..b62f20d5 100644
--- a/tiny_skia/src/backend.rs
+++ b/tiny_skia/src/backend.rs
@@ -1,3 +1,5 @@
+use tiny_skia::Size;
+
use crate::core::{Background, Color, Gradient, Rectangle, Vector};
use crate::graphics::backend;
use crate::graphics::text;
@@ -153,6 +155,9 @@ impl Backend {
border_radius,
border_width,
border_color,
+ shadow_color,
+ shadow_offset,
+ shadow_blur_radius,
} => {
let physical_bounds = (*bounds + translation) * scale_factor;
@@ -182,6 +187,107 @@ impl Backend {
}
let path = rounded_rectangle(*bounds, fill_border_radius);
+ if shadow_color.a > 0.0 {
+ fn smoothstep(a: f32, b: f32, x: f32) -> f32 {
+ let x = ((x - a) / (b - a)).clamp(0.0, 1.0);
+
+ x * x * (3.0 - 2.0 * x)
+ }
+
+ fn rounded_box_sdf(
+ to_center: Vector,
+ size: Size,
+ radii: &[f32],
+ ) -> f32 {
+ let radius =
+ match (to_center.x > 0.0, to_center.y > 0.0) {
+ (true, true) => radii[2],
+ (true, false) => radii[1],
+ (false, true) => radii[3],
+ (false, false) => radii[0],
+ };
+
+ let x = (to_center.x.abs() - size.width() + radius)
+ .max(0.0);
+ let y = (to_center.y.abs() - size.height() + radius)
+ .max(0.0);
+
+ (x.powf(2.0) + y.powf(2.0)).sqrt() - radius
+ }
+
+ let shadow_bounds = (Rectangle {
+ x: bounds.x + shadow_offset.x - shadow_blur_radius,
+ y: bounds.y + shadow_offset.y - shadow_blur_radius,
+ width: bounds.width + shadow_blur_radius * 2.0,
+ height: bounds.height + shadow_blur_radius * 2.0,
+ } + translation)
+ * scale_factor;
+
+ let radii = fill_border_radius
+ .into_iter()
+ .map(|radius| radius * scale_factor)
+ .collect::<Vec<_>>();
+ let (x, y, width, height) = (
+ shadow_bounds.x as u32,
+ shadow_bounds.y as u32,
+ shadow_bounds.width as u32,
+ shadow_bounds.height as u32,
+ );
+ let half_width = physical_bounds.width / 2.0;
+ let half_height = physical_bounds.height / 2.0;
+
+ let colors = (y..y + height)
+ .flat_map(|y| {
+ (x..x + width).map(move |x| (x as f32, y as f32))
+ })
+ .filter_map(|(x, y)| {
+ Size::from_wh(half_width, half_height).map(|size| {
+ let shadow_distance = rounded_box_sdf(
+ Vector::new(
+ x - physical_bounds.position().x
+ - (shadow_offset.x * scale_factor)
+ - half_width,
+ y - physical_bounds.position().y
+ - (shadow_offset.y * scale_factor)
+ - half_height,
+ ),
+ size,
+ &radii,
+ );
+ let shadow_alpha = 1.0
+ - smoothstep(
+ -shadow_blur_radius * scale_factor,
+ *shadow_blur_radius * scale_factor,
+ shadow_distance,
+ );
+
+ let mut color = into_color(*shadow_color);
+ color.apply_opacity(shadow_alpha);
+
+ color.to_color_u8().premultiply()
+ })
+ })
+ .collect();
+
+ if let Some(p) = tiny_skia::IntSize::from_wh(width, height)
+ .and_then(|size| {
+ tiny_skia::Pixmap::from_vec(
+ bytemuck::cast_vec(colors),
+ size,
+ )
+ })
+ {
+ pixels.draw_pixmap(
+ x as i32,
+ y as i32,
+ p.as_ref(),
+ &Default::default(),
+ Default::default(),
+ None,
+ )
+ }
+ }
+
pixels.fill_path(
&path,
&tiny_skia::Paint {
diff --git a/wgpu/src/layer.rs b/wgpu/src/layer.rs
index 4ad12a88..7b54601b 100644
--- a/wgpu/src/layer.rs
+++ b/wgpu/src/layer.rs
@@ -198,6 +198,9 @@ impl<'a> Layer<'a> {
border_radius,
border_width,
border_color,
+ shadow_color,
+ shadow_offset,
+ shadow_blur_radius,
} => {
let layer = &mut layers[current_layer];
@@ -210,6 +213,9 @@ impl<'a> Layer<'a> {
border_color: color::pack(*border_color),
border_radius: *border_radius,
border_width: *border_width,
+ shadow_color: shadow_color.into_linear(),
+ shadow_offset: (*shadow_offset).into(),
+ shadow_blur_radius: *shadow_blur_radius,
};
layer.quads.add(quad, background);
diff --git a/wgpu/src/quad.rs b/wgpu/src/quad.rs
index 4bcf9a66..cda1bec9 100644
--- a/wgpu/src/quad.rs
+++ b/wgpu/src/quad.rs
@@ -201,6 +201,15 @@ pub struct Quad {
/// The border width of the [`Quad`].
pub border_width: f32,
+
+ /// The shadow color of the [`Quad`].
+ pub shadow_color: [f32; 4],
+
+ /// The shadow offset of the [`Quad`].
+ pub shadow_offset: [f32; 2],
+
+ /// The shadow blur radius of the [`Quad`].
+ pub shadow_blur_radius: f32,
}
/// A group of [`Quad`]s rendered together.
diff --git a/wgpu/src/quad/solid.rs b/wgpu/src/quad/solid.rs
index 90e7f98e..771eee34 100644
--- a/wgpu/src/quad/solid.rs
+++ b/wgpu/src/quad/solid.rs
@@ -105,6 +105,12 @@ impl Pipeline {
4 => Float32x4,
// Border width
5 => Float32,
+ // Shadow color
+ 6 => Float32x4,
+ // Shadow offset
+ 7 => Float32x2,
+ // Shadow blur radius
+ 8 => Float32,
),
}],
},
diff --git a/wgpu/src/shader/quad.wgsl b/wgpu/src/shader/quad.wgsl
index f919cfe2..4de73362 100644
--- a/wgpu/src/shader/quad.wgsl
+++ b/wgpu/src/shader/quad.wgsl
@@ -11,19 +11,15 @@ fn distance_alg(
size: vec2<f32>,
radius: f32
) -> f32 {
- var inner_size: vec2<f32> = size - vec2<f32>(radius, radius) * 2.0;
+ var inner_half_size: vec2<f32> = (size - vec2<f32>(radius, radius) * 2.0) / 2.0;
var top_left: vec2<f32> = position + vec2<f32>(radius, radius);
- var bottom_right: vec2<f32> = top_left + inner_size;
-
- var top_left_distance: vec2<f32> = top_left - frag_coord;
- var bottom_right_distance: vec2<f32> = frag_coord - bottom_right;
-
- var dist: vec2<f32> = vec2<f32>(
- max(max(top_left_distance.x, bottom_right_distance.x), 0.0),
- max(max(top_left_distance.y, bottom_right_distance.y), 0.0)
- );
+ return rounded_box_sdf(frag_coord - top_left - inner_half_size, inner_half_size, 0.0);
+}
- return sqrt(dist.x * dist.x + dist.y * dist.y);
+// Given a vector from a point to the center of a rounded rectangle of the given `size` and
+// border `radius`, determines the point's distance from the nearest edge of the rounded rectangle
+fn rounded_box_sdf(to_center: vec2<f32>, size: vec2<f32>, radius: f32) -> f32 {
+ return length(max(abs(to_center) - size + vec2<f32>(radius, radius), vec2<f32>(0.0, 0.0))) - radius;
}
// Based on the fragement position and the center of the quad, select one of the 4 radi.
diff --git a/wgpu/src/shader/quad/solid.wgsl b/wgpu/src/shader/quad/solid.wgsl
index f84dd7ab..cb4a3816 100644
--- a/wgpu/src/shader/quad/solid.wgsl
+++ b/wgpu/src/shader/quad/solid.wgsl
@@ -6,6 +6,9 @@ struct SolidVertexInput {
@location(3) border_color: vec4<f32>,
@location(4) border_radius: vec4<f32>,
@location(5) border_width: f32,
+ @location(6) shadow_color: vec4<f32>,
+ @location(7) shadow_offset: vec2<f32>,
+ @location(8) shadow_blur_radius: f32,
}
struct SolidVertexOutput {
@@ -16,14 +19,19 @@ struct SolidVertexOutput {
@location(3) scale: vec2<f32>,
@location(4) border_radius: vec4<f32>,
@location(5) border_width: f32,
+ @location(6) shadow_color: vec4<f32>,
+ @location(7) shadow_offset: vec2<f32>,
+ @location(8) shadow_blur_radius: f32,
}
@vertex
fn solid_vs_main(input: SolidVertexInput) -> SolidVertexOutput {
var out: SolidVertexOutput;
- var pos: vec2<f32> = input.pos * globals.scale;
- var scale: vec2<f32> = input.scale * globals.scale;
+ var pos: vec2<f32> = (input.pos + min(input.shadow_offset, vec2<f32>(0.0, 0.0)) - input.shadow_blur_radius) * globals.scale;
+ var quad_pos: vec2<f32> = input.pos * globals.scale;
+ var scale: vec2<f32> = (input.scale + vec2<f32>(abs(input.shadow_offset.x), abs(input.shadow_offset.y)) + input.shadow_blur_radius * 2.0) * globals.scale;
+ var quad_scale: vec2<f32> = input.scale * globals.scale;
var min_border_radius = min(input.scale.x, input.scale.y) * 0.5;
var border_radius: vec4<f32> = vec4<f32>(
@@ -43,10 +51,13 @@ fn solid_vs_main(input: SolidVertexInput) -> SolidVertexOutput {
out.position = globals.transform * transform * vec4<f32>(vertex_position(input.vertex_index), 0.0, 1.0);
out.color = input.color;
out.border_color = input.border_color;
- out.pos = pos;
- out.scale = scale;
+ out.pos = quad_pos;
+ out.scale = quad_scale;
out.border_radius = border_radius * globals.scale;
out.border_width = input.border_width * globals.scale;
+ out.shadow_color = input.shadow_color;
+ out.shadow_offset = input.shadow_offset * globals.scale;
+ out.shadow_blur_radius = input.shadow_blur_radius * globals.scale;
return out;
}
@@ -95,5 +106,20 @@ fn solid_fs_main(
dist
);
- return vec4<f32>(mixed_color.x, mixed_color.y, mixed_color.z, mixed_color.w * radius_alpha);
+ let quad_color = vec4<f32>(mixed_color.x, mixed_color.y, mixed_color.z, mixed_color.w * radius_alpha);
+
+ if input.shadow_color.a > 0.0 {
+ let shadow_distance = rounded_box_sdf(input.position.xy - input.pos - input.shadow_offset - (input.scale / 2.0), input.scale / 2.0, border_radius);
+ let shadow_alpha = 1.0 - smoothstep(-input.shadow_blur_radius, input.shadow_blur_radius, shadow_distance);
+ let shadow_color = input.shadow_color;
+ let base_color = select(
+ vec4<f32>(shadow_color.x, shadow_color.y, shadow_color.z, 0.0),
+ quad_color,
+ quad_color.a > 0.0
+ );
+
+ return mix(base_color, shadow_color, (1.0 - radius_alpha) * shadow_alpha);
+ } else {
+ return quad_color;
+ }
}
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
diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs
index 0353b3ad..5cc79b08 100644
--- a/widget/src/checkbox.rs
+++ b/widget/src/checkbox.rs
@@ -287,6 +287,7 @@ where
border_radius: custom_style.border_radius,
border_width: custom_style.border_width,
border_color: custom_style.border_color,
+ shadow: Default::default(),
},
custom_style.background,
);
diff --git a/widget/src/container.rs b/widget/src/container.rs
index cffb0458..519d4f15 100644
--- a/widget/src/container.rs
+++ b/widget/src/container.rs
@@ -344,6 +344,7 @@ pub fn draw_background<Renderer>(
border_radius: appearance.border_radius,
border_width: appearance.border_width,
border_color: appearance.border_color,
+ shadow: Default::default(),
},
appearance
.background
diff --git a/widget/src/overlay/menu.rs b/widget/src/overlay/menu.rs
index f83eebea..03935e59 100644
--- a/widget/src/overlay/menu.rs
+++ b/widget/src/overlay/menu.rs
@@ -309,6 +309,7 @@ where
border_color: appearance.border_color,
border_width: appearance.border_width,
border_radius: appearance.border_radius,
+ shadow: Default::default(),
},
appearance.background,
);
@@ -519,6 +520,7 @@ where
border_color: Color::TRANSPARENT,
border_width: 0.0,
border_radius: appearance.border_radius,
+ shadow: Default::default(),
},
appearance.selected_background,
);
diff --git a/widget/src/pane_grid.rs b/widget/src/pane_grid.rs
index cf1f0455..fc30716d 100644
--- a/widget/src/pane_grid.rs
+++ b/widget/src/pane_grid.rs
@@ -921,6 +921,7 @@ pub fn draw<Renderer, T>(
.border_radius,
border_width: hovered_region_style.border_width,
border_color: hovered_region_style.border_color,
+ shadow: Default::default(),
},
theme.hovered_region(style).background,
);
@@ -950,6 +951,7 @@ pub fn draw<Renderer, T>(
border_radius: hovered_region_style.border_radius,
border_width: hovered_region_style.border_width,
border_color: hovered_region_style.border_color,
+ shadow: Default::default(),
},
theme.hovered_region(style).background,
);
@@ -1013,6 +1015,7 @@ pub fn draw<Renderer, T>(
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
highlight.color,
);
diff --git a/widget/src/pick_list.rs b/widget/src/pick_list.rs
index 2e3aab6f..8931aa99 100644
--- a/widget/src/pick_list.rs
+++ b/widget/src/pick_list.rs
@@ -656,6 +656,7 @@ pub fn draw<'a, T, Renderer>(
border_color: style.border_color,
border_width: style.border_width,
border_radius: style.border_radius,
+ shadow: Default::default(),
},
style.background,
);
diff --git a/widget/src/progress_bar.rs b/widget/src/progress_bar.rs
index 15f1277b..1e0f2a82 100644
--- a/widget/src/progress_bar.rs
+++ b/widget/src/progress_bar.rs
@@ -133,6 +133,7 @@ where
border_radius: style.border_radius,
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
style.background,
);
@@ -147,6 +148,7 @@ where
border_radius: style.border_radius,
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
style.bar,
);
diff --git a/widget/src/radio.rs b/widget/src/radio.rs
index f91b20b1..0a33825f 100644
--- a/widget/src/radio.rs
+++ b/widget/src/radio.rs
@@ -315,6 +315,7 @@ where
border_radius: (size / 2.0).into(),
border_width: custom_style.border_width,
border_color: custom_style.border_color,
+ shadow: Default::default(),
},
custom_style.background,
);
@@ -331,6 +332,7 @@ where
border_radius: (dot_size / 2.0).into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
custom_style.dot_color,
);
diff --git a/widget/src/rule.rs b/widget/src/rule.rs
index cded9cb1..4a83e9d1 100644
--- a/widget/src/rule.rs
+++ b/widget/src/rule.rs
@@ -127,6 +127,7 @@ where
border_radius: style.radius,
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
style.color,
);
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs
index 70db490a..82602a41 100644
--- a/widget/src/scrollable.rs
+++ b/widget/src/scrollable.rs
@@ -912,6 +912,7 @@ pub fn draw<Renderer>(
border_radius: style.border_radius,
border_width: style.border_width,
border_color: style.border_color,
+ shadow: Default::default(),
},
style
.background
@@ -932,6 +933,7 @@ pub fn draw<Renderer>(
border_radius: style.scroller.border_radius,
border_width: style.scroller.border_width,
border_color: style.scroller.border_color,
+ shadow: Default::default(),
},
style.scroller.color,
);
diff --git a/widget/src/slider.rs b/widget/src/slider.rs
index 1bc94661..d89f50e0 100644
--- a/widget/src/slider.rs
+++ b/widget/src/slider.rs
@@ -401,6 +401,7 @@ pub fn draw<T, R>(
border_radius: style.rail.border_radius,
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
style.rail.colors.0,
);
@@ -416,6 +417,7 @@ pub fn draw<T, R>(
border_radius: style.rail.border_radius,
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
style.rail.colors.1,
);
@@ -431,6 +433,7 @@ pub fn draw<T, R>(
border_radius: handle_border_radius,
border_width: style.handle.border_width,
border_color: style.handle.border_color,
+ shadow: Default::default(),
},
style.handle.color,
);
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs
index 09a0cac0..3f3ccf72 100644
--- a/widget/src/text_editor.rs
+++ b/widget/src/text_editor.rs
@@ -470,6 +470,7 @@ where
border_radius: appearance.border_radius,
border_width: appearance.border_width,
border_color: appearance.border_color,
+ shadow: Default::default(),
},
appearance.background,
);
@@ -511,6 +512,7 @@ where
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
theme.value_color(&self.style),
);
@@ -526,6 +528,7 @@ where
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
theme.selection_color(&self.style),
);
diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs
index c3dce8be..f8e6c7f8 100644
--- a/widget/src/text_input.rs
+++ b/widget/src/text_input.rs
@@ -1085,6 +1085,7 @@ pub fn draw<Renderer>(
border_radius: appearance.border_radius,
border_width: appearance.border_width,
border_color: appearance.border_color,
+ shadow: Default::default(),
},
appearance.background,
);
@@ -1134,6 +1135,7 @@ pub fn draw<Renderer>(
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
theme.value_color(style),
))
@@ -1175,6 +1177,7 @@ pub fn draw<Renderer>(
border_radius: 0.0.into(),
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
theme.selection_color(style),
)),
diff --git a/widget/src/toggler.rs b/widget/src/toggler.rs
index 941159ea..f7fb5d58 100644
--- a/widget/src/toggler.rs
+++ b/widget/src/toggler.rs
@@ -317,6 +317,7 @@ where
border_color: style
.background_border
.unwrap_or(style.background),
+ shadow: Default::default(),
},
style.background,
);
@@ -341,6 +342,7 @@ where
border_color: style
.foreground_border
.unwrap_or(style.foreground),
+ shadow: Default::default(),
},
style.foreground,
);
diff --git a/widget/src/vertical_slider.rs b/widget/src/vertical_slider.rs
index a3029d76..4fdad861 100644
--- a/widget/src/vertical_slider.rs
+++ b/widget/src/vertical_slider.rs
@@ -400,6 +400,7 @@ pub fn draw<T, R>(
border_radius: style.rail.border_radius,
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
style.rail.colors.1,
);
@@ -415,6 +416,7 @@ pub fn draw<T, R>(
border_radius: style.rail.border_radius,
border_width: 0.0,
border_color: Color::TRANSPARENT,
+ shadow: Default::default(),
},
style.rail.colors.0,
);
@@ -430,6 +432,7 @@ pub fn draw<T, R>(
border_radius: handle_border_radius,
border_width: style.handle.border_width,
border_color: style.handle.border_color,
+ shadow: Default::default(),
},
style.handle.color,
);