fix(themes): card shadow no longer cut off at child-window edges

Cards are drawn inside clipping child windows, so the shadow (which extends past
the card edge) was cut at the child boundary — most visibly a hard line on the
sidebar's inner edge, which also made the shadow look non-uniform. Widen the
shadow's clip horizontally (card + spread, clamped to the viewport) so the side
shadows reach into the gaps between panels, while keeping the vertical clip at the
child bounds so a card scrolled to a child's top/bottom edge can't bleed its
shadow into the header/footer. Verified: sidebar + settings cards now show an
even shadow on all four sides.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-10 20:42:08 -05:00
parent c50125523c
commit cff958c21e

View File

@@ -570,6 +570,18 @@ inline void DrawCardDropShadow(ImDrawList* dl, const ImVec2& pMin, const ImVec2&
const float dp = Layout::dpiScale();
const int kRings = 12;
const float spread = 14.0f * dp; // how far the shadow reaches beyond the card edge (all sides)
// Cards live inside clipping child windows, so the shadow (which extends past the card edge) is
// otherwise cut off at the child boundary — most visibly on the sidebar's inner edge. Widen the
// clip HORIZONTALLY (to the card + spread, clamped to the viewport) so the side shadows reach into
// the gaps; keep the VERTICAL clip at the child bounds so a card scrolled to a child's top/bottom
// edge can't bleed its shadow into the header/footer above or below the scroll area.
ImGuiViewport* vp = ImGui::GetMainViewport();
const ImVec2 cur0 = dl->GetClipRectMin();
const ImVec2 cur1 = dl->GetClipRectMax();
const float x0 = std::max(vp->Pos.x, std::min(cur0.x, pMin.x - spread));
const float x1 = std::min(vp->Pos.x + vp->Size.x, std::max(cur1.x, pMax.x + spread));
dl->PushClipRect(ImVec2(x0, cur0.y), ImVec2(x1, cur1.y), false);
for (int i = kRings; i >= 1; --i) {
float t = (float)i / (float)kRings; // 1 (outer) .. near 0 (by the card)
float e = spread * t; // expansion at this ring
@@ -579,6 +591,7 @@ inline void DrawCardDropShadow(ImDrawList* dl, const ImVec2& pMin, const ImVec2&
ImVec2 smx(pMax.x + e, pMax.y + e);
dl->AddRect(smn, smx, IM_COL32(0, 0, 0, a), rounding + e, 0, 2.0f * dp);
}
dl->PopClipRect();
}
inline void DrawGlassPanel(ImDrawList* dl, const ImVec2& pMin,