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: |
cargo install mdbook-variables
- name: Regenerate Example Images
run: |
CAPTURE=1 cargo test -p guide-examples --examples
- name: Build Guide
run: |
./mdbook build guide

View file

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

View file

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

View file

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