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
+25 -11
View File
@@ -738,9 +738,17 @@ impl RenderOnce for Tabs {
let focus = gpui_native_utils::focus_handle(&self.id, window, cx); 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. // 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(); 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 let label = self
@@ -902,7 +910,7 @@ impl RenderOnce for Tabs {
|_, _, _, _| {}, |_, _, _, _| {},
) )
.absolute() .absolute()
.inset_0(); .inset(shadow_bleed);
let trigger_canvas = canvas( let trigger_canvas = canvas(
{ {
let key = measure_key; let key = measure_key;
@@ -929,6 +937,8 @@ impl RenderOnce for Tabs {
root.min_w_0() root.min_w_0()
.flex_grow(1.0) .flex_grow(1.0)
.overflow_hidden() .overflow_hidden()
.p(shadow_bleed)
.m(-shadow_bleed)
.child(container_canvas) .child(container_canvas)
.child( .child(
div() div()
@@ -940,14 +950,18 @@ impl RenderOnce for Tabs {
) )
.child(control.child(trigger_canvas)) .child(control.child(trigger_canvas))
} else if self.overflow_scroll { } else if self.overflow_scroll {
root.min_w_0().overflow_x_scroll().child( root.min_w_0()
div() .overflow_x_scroll()
.flex_none() .p(shadow_bleed)
.flex() .m(-shadow_bleed)
.gap_1() .child(
.when(self.variant == TabsVariant::Pill, |row| row.items_center()) div()
.children(strip), .flex_none()
) .flex()
.gap_1()
.when(self.variant == TabsVariant::Pill, |row| row.items_center())
.children(strip),
)
} else { } else {
root.children(strip) root.children(strip)
} }
+1
View File
@@ -70,6 +70,7 @@ fn island(panel: Div, cx: &App) -> Div {
.border_1() .border_1()
.border_color(colors.border) .border_color(colors.border)
.rounded(theme.radius.overlay) .rounded(theme.radius.overlay)
.overflow_hidden()
} }
/// The panel row drawn under the titlebar. /// 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. /// The gpui shadow list an overlay panel paints with.
pub fn shadows(self) -> Vec<gpui::BoxShadow> { pub fn shadows(self) -> Vec<gpui::BoxShadow> {
self.layers self.layers