tabs: pad scroll containers for shadow bleed

This commit is contained in:
2026-11-16 07:50:39 +07:00
parent de2980712f
commit 28674d6d6a
3 changed files with 41 additions and 11 deletions
+18 -4
View File
@@ -738,9 +738,17 @@ impl RenderOnce for Tabs {
let focus = gpui_native_utils::focus_handle(&self.id, window, cx);
// Theme reads end here, so the strip's group chips can take `cx` mutably.
let (medium_text_size, border_color) = {
let (medium_text_size, border_color, shadow_bleed) = {
let theme = cx.theme();
(theme.sizes.medium.text_size, theme.colors.border)
let shadow_bleed = match self.variant {
TabsVariant::Pill => theme.elevations.control.bleed(),
TabsVariant::Underline => Pixels::ZERO,
};
(
theme.sizes.medium.text_size,
theme.colors.border,
shadow_bleed,
)
};
let label = self
@@ -902,7 +910,7 @@ impl RenderOnce for Tabs {
|_, _, _, _| {},
)
.absolute()
.inset_0();
.inset(shadow_bleed);
let trigger_canvas = canvas(
{
let key = measure_key;
@@ -929,6 +937,8 @@ impl RenderOnce for Tabs {
root.min_w_0()
.flex_grow(1.0)
.overflow_hidden()
.p(shadow_bleed)
.m(-shadow_bleed)
.child(container_canvas)
.child(
div()
@@ -940,7 +950,11 @@ impl RenderOnce for Tabs {
)
.child(control.child(trigger_canvas))
} else if self.overflow_scroll {
root.min_w_0().overflow_x_scroll().child(
root.min_w_0()
.overflow_x_scroll()
.p(shadow_bleed)
.m(-shadow_bleed)
.child(
div()
.flex_none()
.flex()
+1
View File
@@ -70,6 +70,7 @@ fn island(panel: Div, cx: &App) -> Div {
.border_1()
.border_color(colors.border)
.rounded(theme.radius.overlay)
.overflow_hidden()
}
/// The panel row drawn under the titlebar.
+15
View File
@@ -377,6 +377,21 @@ impl Elevation {
}
}
/// How far the shadow layers paint past the element's bounds.
pub fn bleed(self) -> Pixels {
self.layers.iter().fold(px(0.), |bleed, layer| {
if layer.color.a > 0. {
bleed.max(
layer.offset_x.abs().max(layer.offset_y.abs())
+ layer.blur_radius
+ layer.spread_radius,
)
} else {
bleed
}
})
}
/// The gpui shadow list an overlay panel paints with.
pub fn shadows(self) -> Vec<gpui::BoxShadow> {
self.layers