From 1fcf6730652d509e78de4b80888772083f5b124a Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Thu, 18 Jun 2026 22:04:51 +0800
Subject: [PATCH] Refine Quick Switch app hover visuals

---
 C3.tools/round1-app-shelf-fixture-qa.sh             |   46 ++++++++++++++---------
 C1.source/Sources/Aligner/QuickSwitchRootView.swift |   59 +++++++++++++++++++++--------
 C1.source/Resources/Aligner-Info.plist              |    4 +-
 3 files changed, 72 insertions(+), 37 deletions(-)

diff --git a/C1.source/Resources/Aligner-Info.plist b/C1.source/Resources/Aligner-Info.plist
index 1ef8019..55f8465 100644
--- a/C1.source/Resources/Aligner-Info.plist
+++ b/C1.source/Resources/Aligner-Info.plist
@@ -17,9 +17,9 @@
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
-    <string>0.0.70</string>
+    <string>0.0.71</string>
 	<key>CFBundleVersion</key>
-    <string>20260618.2044</string>
+    <string>20260618.2149</string>
 	<key>LSMinimumSystemVersion</key>
 	<string>26.0</string>
 	<key>NSHighResolutionCapable</key>
diff --git a/C1.source/Sources/Aligner/QuickSwitchRootView.swift b/C1.source/Sources/Aligner/QuickSwitchRootView.swift
index f127082..4797b32 100644
--- a/C1.source/Sources/Aligner/QuickSwitchRootView.swift
+++ b/C1.source/Sources/Aligner/QuickSwitchRootView.swift
@@ -300,10 +300,10 @@
         static let normalGap: CGFloat = 16
         static let minGap: CGFloat = 8
         static let maxRows = 2
-        static let indexFontSize: CGFloat = 15
-        static let compressedIndexFontSize: CGFloat = 13
-        static let indexWidth: CGFloat = 16
-        static let indexHeight: CGFloat = 18
+        static let indexFontSize: CGFloat = 16
+        static let compressedIndexFontSize: CGFloat = 14
+        static let indexWidth: CGFloat = 18
+        static let indexHeight: CGFloat = 24
     }
 
     private enum RootLayoutMetrics {
@@ -3525,11 +3525,11 @@
     }
 
     private var appShelfIndexColor: NSColor {
-        NSColor.labelColor.withAlphaComponent(0.34)
+        NSColor.labelColor.withAlphaComponent(0.48)
     }
 
     private var appShelfIndexHighlightedColor: NSColor {
-        NSColor.labelColor.withAlphaComponent(0.42)
+        NSColor.labelColor.withAlphaComponent(0.58)
     }
 
     private func appShelfIndexFont(size: CGFloat) -> NSFont {
@@ -3569,13 +3569,13 @@
         layer.font = appShelfIndexFont(size: fontSize)
         layer.fontSize = fontSize
         layer.foregroundColor = (highlighted ? appShelfIndexHighlightedColor : appShelfIndexColor).cgColor
-        layer.opacity = iconSize <= AppShelfMetrics.minIconSize + 1 ? 0.72 : 0.82
+        layer.opacity = 1
 
         let indexWidth = AppShelfMetrics.indexWidth
         let indexHeight = AppShelfMetrics.indexHeight
-        let preferredX = iconFrame.minX - indexWidth - 1
-        let clampedX = max(-6, min(itemBounds.width - indexWidth, preferredX))
-        let preferredY = iconFrame.maxY - indexHeight + 4
+        let preferredX = iconFrame.minX - indexWidth - 2
+        let clampedX = max(-7, min(itemBounds.width - indexWidth, preferredX))
+        let preferredY = iconFrame.maxY - indexHeight + 6
         let clampedY = max(0, min(itemBounds.height - indexHeight, preferredY))
         layer.frame = CGRect(
             x: clampedX,
@@ -3785,6 +3785,10 @@
         return item.item.windowCount > 1 ? "\(item.item.windowCount)" : ""
     }
 
+    private var waterfallAppHoverHeaderFillColor: NSColor {
+        NSColor.systemGray.withAlphaComponent(0.22)
+    }
+
     private var appShelfMaxScrollOffset: CGFloat {
         max(0, appShelfContentWidth - shelfLayer.bounds.width)
     }
@@ -3870,6 +3874,7 @@
             column.countLayer.isHidden = true
 
             for card in column.cards {
+                card.containerLayer.transform = CATransform3DIdentity
                 if let frame = layout.cardFramesByWindowID[card.item.window.id] {
                     card.containerLayer.frame = frame
                 } else {
@@ -4017,7 +4022,7 @@
             height: WaterfallMetrics.headerHeight
         )
         column.headerLayer.backgroundColor = (isHovered
-            ? viewModeToggleBlueColor
+            ? waterfallAppHoverHeaderFillColor
             : (isSpaceFocused
                 ? NSColor.systemFill.withAlphaComponent(0.10)
                 : NSColor.controlBackgroundColor.withAlphaComponent(0.52))
@@ -4028,14 +4033,14 @@
             width: max(1, bounds.width - WaterfallMetrics.columnHeaderTextInset * 2),
             height: 16
         )
-        column.appNameLayer.foregroundColor = (isHovered ? NSColor.white : NSColor.labelColor).cgColor
+        column.appNameLayer.foregroundColor = NSColor.labelColor.cgColor
         column.countLayer.frame = CGRect(
             x: bounds.width - 48,
             y: bounds.height - 24,
             width: 36,
             height: 16
         )
-        column.countLayer.foregroundColor = (isHovered ? NSColor.white : NSColor.secondaryLabelColor).cgColor
+        column.countLayer.foregroundColor = NSColor.secondaryLabelColor.cgColor
 
         let appGroupIndex = column.column.appGroupIndex
         let verticalOffset = clampedWaterfallColumnOffset(
@@ -4055,6 +4060,7 @@
             let y = firstCardTop
                 - WaterfallMetrics.cardHeight
                 - CGFloat(cardIndex) * (WaterfallMetrics.cardHeight + WaterfallMetrics.cardGap)
+            card.containerLayer.transform = CATransform3DIdentity
             card.containerLayer.frame = CGRect(
                 x: WaterfallMetrics.columnHorizontalPadding,
                 y: y,
@@ -4069,8 +4075,7 @@
         let bounds = card.containerLayer.bounds
         let isSelected = card.item.window.id == effectiveSelection?.windowID
         let isHovered = card.item.window.id == hoveredWindowID
-        let isAppLinked = isHorizontalMasonryMode
-            && card.item.appGroupIndex == appIconHoverLinkedAppGroupIndex
+        let isAppLinked = isWaterfallCardAppLinked(card)
         applyWaterfallCardVisualState(
             card,
             selected: shouldShowSelectedVisual(isSelected: isSelected, isHovered: isHovered),
@@ -4723,6 +4728,26 @@
         return card.item.primarySpaceID == activeSpaceFocusID
     }
 
+    private func isWaterfallCardAppLinked(_ card: WaterfallCardLayers) -> Bool {
+        guard card.item.appGroupIndex == appIconHoverLinkedAppGroupIndex else { return false }
+
+        if isHorizontalMasonryMode {
+            return true
+        }
+
+        return waterfallColumns
+            .first(where: { $0.column.appGroupIndex == card.item.appGroupIndex })?
+            .cards
+            .sorted { lhs, rhs in
+                if lhs.item.windowIndex != rhs.item.windowIndex {
+                    return lhs.item.windowIndex < rhs.item.windowIndex
+                }
+                return lhs.item.window.id < rhs.item.window.id
+            }
+            .first?
+            .item.window.id == card.item.window.id
+    }
+
     private func waterfallColumnWidth() -> CGFloat {
         guard waterfallColumns.count > 0 else { return WaterfallMetrics.columnWidth }
 
@@ -5181,6 +5206,7 @@
                 "indexFrame": dictionary(from: item.indexLayer.frame),
                 "indexVisible": !item.indexLayer.isHidden && item.indexLayer.opacity > 0,
                 "indexFontSize": Double(item.indexLayer.fontSize),
+                "indexOpacity": Double(item.indexLayer.opacity),
                 "indexColor": colorDictionary(from: item.indexLayer.foregroundColor),
                 "labelFrame": dictionary(from: item.labelLayer.frame),
                 "labelTruncationMode": "middle",
@@ -5457,8 +5483,7 @@
         var states: [String] = []
         let isSelected = card.item.window.id == effectiveSelection?.windowID
         let isHovered = card.item.window.id == hoveredWindowID
-        let isAppLinked = isHorizontalMasonryMode
-            && card.item.appGroupIndex == appIconHoverLinkedAppGroupIndex
+        let isAppLinked = isWaterfallCardAppLinked(card)
         if shouldShowSelectedVisual(isSelected: isSelected, isHovered: isHovered) {
             states.append("selected")
         } else if isSelected {
diff --git a/C3.tools/round1-app-shelf-fixture-qa.sh b/C3.tools/round1-app-shelf-fixture-qa.sh
index 586ee5f..2cb4cdb 100755
--- a/C3.tools/round1-app-shelf-fixture-qa.sh
+++ b/C3.tools/round1-app-shelf-fixture-qa.sh
@@ -147,29 +147,35 @@
 require(items[0].get("iconFrame", {}).get("width") == expected_icon_size, "non-hovered selected app icon must match normal fixture icon size")
 require(items[hover_index].get("iconFrame", {}).get("width") == 68, "hovered app icon must be 68pt")
 
-blue_reference = {"red": 135 / 255, "green": 200 / 255, "blue": 1.0, "alpha": 1.0}
+legacy_blue_reference = {"red": 135 / 255, "green": 200 / 255, "blue": 1.0, "alpha": 1.0}
 hovered_title_color = columns[hover_index].get("appNameColor", {})
 hovered_header_color = columns[hover_index].get("headerBackgroundColor", {})
 hovered_count_color = columns[hover_index].get("countColor", {})
-for channel in ("red", "green", "blue"):
-    require(
-        abs(hovered_header_color.get(channel, -1) - blue_reference.get(channel, -2)) <= 0.002,
-        f"hovered column header must use #87C8FF for {channel}"
-    )
-require(hovered_header_color.get("alpha", 0) >= 0.98, "hovered column header blue fill must be opaque")
-for color_name, color in (("title", hovered_title_color), ("count", hovered_count_color)):
-    for channel in ("red", "green", "blue", "alpha"):
-        require(abs(color.get(channel, -1) - 1.0) <= 0.002, f"hovered column {color_name} text must be pure white for {channel}")
+
+def is_legacy_blue(color):
+    return all(abs(color.get(channel, -1) - legacy_blue_reference[channel]) <= 0.01 for channel in ("red", "green", "blue"))
+
+hovered_header_channels = [hovered_header_color.get(channel, -1) for channel in ("red", "green", "blue")]
+require(not is_legacy_blue(hovered_header_color), "hovered column header must no longer use the previous blue fill")
+require(max(hovered_header_channels) - min(hovered_header_channels) <= 0.035, "hovered column header must use a neutral gray fill")
+require(0.16 <= hovered_header_color.get("alpha", 0) <= 0.30, "hovered column header gray fill must stay lightweight")
+require(hovered_title_color.get("alpha", 0) >= 0.8, "hovered column title must remain readable")
+require(hovered_count_color.get("alpha", 0) >= 0.45, "hovered column count must remain readable")
+hovered_cards = columns[hover_index].get("cards", [])
+require(hovered_cards, "hovered column must include at least one card")
+require("appLinked" in hovered_cards[0].get("visualStates", []), "hovered App column first card must expose appLinked visual state")
+require(hovered_cards[0].get("closeButtonVisible") is False, "App-linked first card must not show close button unless directly hovered")
+require(hovered_cards[0].get("shadowOpacity", 0) > 0, "App-linked first card must lift with a shadow")
+require(hovered_cards[0].get("titleBarBackgroundColor", {}).get("alpha", 0) > 0.10, "App-linked first card title bar must expose a visible highlight")
+require(all("appLinked" not in card.get("visualStates", []) for card in hovered_cards[1:]), "only the first vertical card in the hovered App column should expose appLinked")
 for index, column in enumerate(columns):
     if index == hover_index:
         continue
     require(column.get("isHovered") is False, "non-hovered columns must not be marked hovered")
     require("hover" not in column.get("visualStates", []), "non-hovered columns must not expose hover visual state")
     normal_header = column.get("headerBackgroundColor", {})
-    require(
-        any(abs(normal_header.get(channel, -1) - blue_reference[channel]) > 0.05 for channel in ("red", "green", "blue")),
-        "non-hovered column headers must not use the hover blue fill"
-    )
+    require(not is_legacy_blue(normal_header), "non-hovered column headers must not use the previous blue fill")
+    require(all("appLinked" not in card.get("visualStates", []) for card in column.get("cards", [])), "non-hovered columns must not expose appLinked cards")
 
 normal_items = [
     item for item in items
@@ -180,9 +186,11 @@
 require(all(item.get("labelTruncationMode") == "middle" for item in items), "all App Shelf labels must use middle truncation")
 require(all(item.get("indexVisible") is True for item in items), "all App Shelf items must expose a visible hand-written index marker")
 require(all(item.get("indexText") == expected_index_text(index) for index, item in enumerate(items)), "App Shelf index markers must follow 1234567890ABCDEFG order")
-require(all(item.get("indexFontSize", 0) >= 13 for item in items), "App Shelf index markers must keep readable font size")
-require(all(0 < item.get("indexColor", {}).get("alpha", 0) <= 0.5 for item in items), "App Shelf index markers must stay low-noise with light alpha")
-require(all(item.get("indexFrame", {}).get("width", 0) >= 14 for item in items), "App Shelf index markers must reserve enough width")
+require(all(item.get("indexFontSize", 0) >= 14 for item in items), "App Shelf index markers must keep readable font size")
+require(all(0.38 <= item.get("indexColor", {}).get("alpha", 0) <= 0.62 for item in items), "App Shelf index markers must stay low-noise but fully readable")
+require(all(item.get("indexOpacity", 0) == 1 for item in items), "App Shelf index markers must avoid double alpha fading")
+require(all(item.get("indexFrame", {}).get("width", 0) >= 16 for item in items), "App Shelf index markers must reserve enough width")
+require(all(item.get("indexFrame", {}).get("height", 0) >= 22 for item in items), "App Shelf index markers must reserve enough height to avoid bottom clipping")
 require(all(item.get("indexFrame", {}).get("x", 99) < item.get("iconFrame", {}).get("x", -99) for item in items), "App Shelf index markers must sit beside the icon, not over the icon center")
 
 row_y_values = {round(item.get("frame", {}).get("y", 0), 2) for item in items}
@@ -204,7 +212,9 @@
     "hoveredColumnHeaderColor": hovered_header_color,
     "hoveredColumnTitleColor": hovered_title_color,
     "hoveredColumnCountColor": hovered_count_color,
-    "blueReference": blue_reference,
+    "legacyBlueReference": legacy_blue_reference,
+    "hoveredFirstCardStates": hovered_cards[0].get("visualStates"),
+    "hoveredFirstCardTitleBarColor": hovered_cards[0].get("titleBarBackgroundColor"),
     "firstIndexes": [item.get("indexText") for item in items[:min(12, len(items))]],
     "selectedZ": selected_z,
     "hoverZ": hover_z,

--
Gitblit v1.9.3