Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion crates/gpui/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4931,12 +4931,37 @@ impl Window {
continue;
}
let shadow_bounds = (bounds + shadow.offset).dilate(shadow.spread_radius);
// The spread grows the rounded corners with the box, as CSS does, so a ring drawn
// with a spread keeps one width around the corners. A square corner stays square,
// and a corner rounded less than the spread grows by less, so it does not jump to
// the full spread.
let spread = |radius: Pixels| {
let reach = shadow.spread_radius;
if radius <= Pixels::ZERO {
return radius;
}
if reach <= Pixels::ZERO {
return (radius + reach).max(Pixels::ZERO);
}
let ratio = radius / reach;
let grow = match ratio < 1. {
true => reach * (1. + (ratio - 1.).powi(3)),
false => reach,
};
radius + grow
};
let shadow_corner_radii = Corners {
top_left: spread(corner_radii.top_left),
top_right: spread(corner_radii.top_right),
bottom_right: spread(corner_radii.bottom_right),
bottom_left: spread(corner_radii.bottom_left),
};
self.next_frame.scene.insert_primitive(Shadow {
order: 0,
blur_radius: shadow.blur_radius.scale(scale_factor),
bounds: self.cover_bounds(shadow_bounds),
content_mask,
corner_radii: corner_radii.scale(scale_factor),
corner_radii: shadow_corner_radii.scale(scale_factor),
color: shadow.color.opacity(opacity),
element_bounds,
element_corner_radii,
Expand Down
Loading