Repository navigation
fix: draw a popup's own shadow without an outline around it - #185
Merged
Merged
Conversation
Since popups cast the window shadow (#170), macOS outlines a popup's window wherever what it draws passes about 5% alpha. A popup with a shadowColor drew that shadow in the same window, so the outline landed out in the shadow's fade instead of on the popup's edge: about 15 pt out with a shadowRadius of 14, and a doubled edge with the 2 pt shadows of the bundled themes. That shadow now goes in a shadowless window behind the popup, with the popup's shape cut out. It follows the popup's frame, reveal, fade and close. The popup's own window keeps the system shadow, which now hugs its edge. Popups without a shadowColor are unchanged. Fixes #180
|
🎉 This PR is included in version 0.6.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Popups with a
shadowColorshow a dark outline floating outside their edge. It sits about 15 pt out withshadowRadius: 14, and gives the bundled themes' 2 pt popup shadows a doubled edge. It's a regression from #170, so far only in betas. Fixes #180.Changes
Cause, measured on macOS 26.6. For a transparent borderless window with
hasShadow, the window server weights the soft shadow by the content's alpha. It also draws a crisp rim wherever the content passes about 13/255 (~5%) alpha. The popup drew its SwiftUI shadow in its own window, so the rim followed that alpha level out in the shadow's fade. #180 said the outline traces every pixel that isn't clear; the threshold corrects that.WidgetPopup.swift:hasShadowand no longer draws the popup's own shadow. The system shadow and rim now follow the popup's edge, as they already did for popups without ashadowColor.shadowColor, a second borderless window behind the popup draws that shadow (PopupShadowView). The popup's shape is cut out of it, so translucent and glass popups don't show it. This window has no window shadow and ignores clicks. It shares the popup's frame andPopupRevealView, and follows its reveal scale, fade, resizes and close.shadowColorget no extra window. Tooltips are unchanged: they never had the window shadow.No README change. The popup section already says "Popups cast the system's window shadow, under the
shadowColorshadow if one is set", which is now what happens.Alternatives ruled out:
Testing
popupDrawsItsOwnShadowInAWindowBehindItrenders the popup's window and checks that it's clear 4 pt beside the popup. It also checks that the shadow window draws there and is clear inside the popup, that it keeps the popup's frame through a resize, and that closing removes it. Without the change, the clear-beside check fails.swift test: 275 XCTest and 388 Swift Testing tests pass. The animated case ofpopupResizesWithItsContentAndKeepsItsWidthAndTopEdgefailed once locally on bothmainand this branch, then passed on reruns, as feat: fade popups in with a shadow and the system material #170 also noted.mainand on this branch:screencapture -l.shadowRadius: 14in dark and light, a Built-in-style 2 pt shadow, and noshadowColor.Merging
One commit, so any merge method keeps it.
Claude Opus 5.5 via Claude Code