src/pro/ui/ProBadgeViewSegmentSpecs.md
Line coverage:
ProBadgeView.swift50% · refreshed 2026-05-27 by/coverage-explore(an AppKit view; the draw/layoutpaths a unit test can reach are covered, the rest is rendering glue).
ProBadgeView overlays a small "Pro" badge onto a segment of a Settings NSSegmentedControl (the
Appearance style/size segments that are Pro-gated). It must blend in with AppKit's native segment
rendering — same widths, same system-resolved colors across appearance/selection/key-window states — and
stay correct when built lazily off-window. The suite pins the layout, color-provider, icon-templating,
and selection-sync behavior, with explicit regression coverage for two real bugs.
colorProvider closure so AppKit
re-resolves the system color token every draw — selected+key → .alternateSelectedControlTextColor,
otherwise .controlTextColor (which AppKit fades for inactive/disabled/dark automatically). No
NSColor(red:green:blue:) tuples.isTemplate = true strips SF Symbols' intrinsic multicolor so the glyph
respects our tint (matching AppKit's monochrome segment rendering).layout() sizes the three gradient sublayers + sets borderMask.path /
textMask.frame — if suppressed, the badge renders as the "faded" 10%-alpha fill; (2)
viewDidMoveToWindow calls updateColors() so a badge created off-window (lazy Appearance pane while
Settings is already key) resyncs instead of staying stuck in its init-time not-key colors.Mirrors ProBadgeViewSegmentTests.swift 1:1.
colorProvider closure..alternateSelectedControlTextColor..controlTextColor..controlTextColor.layout() sizes the gradient sublayers + masks (guards the "faded badge" bug).updateColors() (guards the "faded badge in a lazily-built pane" bug).