Simplifying drop shadow

Also making example regeneration automatic in CI for the guide
This commit is contained in:
Jonathan Johnson 2024-05-12 06:57:41 -07:00
parent a3903463ea
commit 997cc9586f
No known key found for this signature in database
GPG key ID: A66D6A34D6620579
4 changed files with 10 additions and 8 deletions

View file

@ -48,6 +48,10 @@ jobs:
run: | run: |
cargo install mdbook-variables cargo install mdbook-variables
- name: Regenerate Example Images
run: |
CAPTURE=1 cargo test -p guide-examples --examples
- name: Build Guide - name: Build Guide
run: | run: |
./mdbook build guide ./mdbook build guide

View file

@ -72,7 +72,7 @@ impl BookExample {
name, name,
recorder: interface recorder: interface
.contain() .contain()
.shadow(ContainerShadow::drop(Px::new(16), Px::new(32))) .shadow(ContainerShadow::drop(Px::new(16)))
.width(Px::new(750)) .width(Px::new(750))
.build_recorder() .build_recorder()
.with_alpha() .with_alpha()

View file

@ -704,16 +704,14 @@ impl<Unit> ContainerShadow<Unit> {
} }
} }
/// Returns a drop shadow placed `distance` below with a combined /// Returns a drop shadow placed `distance` below.
/// blur/spread radius of `blur`. pub fn drop(distance: Unit) -> Self
pub fn drop(distance: Unit, blur: Unit) -> Self
where where
Unit: Zero + Div<i32, Output = Unit> + Default + Copy, Unit: Zero + Div<i32, Output = Unit> + Default + Copy,
{ {
let half_blur = blur / 2;
Self::new(Point::new(Unit::ZERO, distance)) Self::new(Point::new(Unit::ZERO, distance))
.blur_radius(half_blur) .blur_radius(distance)
.spread(half_blur) .spread(distance / 2)
} }
/// Sets the shadow color and returns self. /// Sets the shadow color and returns self.

View file

@ -870,7 +870,7 @@ impl WrapperWidget for Tooltipped {
.clone() .clone()
.contain() .contain()
.background_color(background_color) .background_color(background_color)
.shadow(ContainerShadow::drop(Lp::mm(1), Lp::mm(2))), .shadow(ContainerShadow::drop(Lp::mm(1))),
) )
.hide_on_unhover() .hide_on_unhover()
.near(my_id, data.direction) .near(my_id, data.direction)