From 0754f2706a79128e87b65867e1d33096d53687fa Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Fri, 12 Jun 2026 17:19:21 +0800
Subject: [PATCH] Use fixed height horizontal waterfall cards

---
 C3.tools/round1-horizontal-waterfall-fixture-qa.sh  |   33 +++++++++++++---
 C1.source/Sources/Aligner/QuickSwitchRootView.swift |   65 +++++---------------------------
 C1.source/Resources/Aligner-Info.plist              |    4 +-
 3 files changed, 40 insertions(+), 62 deletions(-)

diff --git a/C1.source/Resources/Aligner-Info.plist b/C1.source/Resources/Aligner-Info.plist
index bdf5cf0..cd0538d 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.59</string>
+    <string>0.0.60</string>
 	<key>CFBundleVersion</key>
-    <string>20260612.1439</string>
+    <string>20260612.1713</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 45ea62f..d7f02fc 100644
--- a/C1.source/Sources/Aligner/QuickSwitchRootView.swift
+++ b/C1.source/Sources/Aligner/QuickSwitchRootView.swift
@@ -327,13 +327,11 @@
     private enum HorizontalMasonryMetrics {
         static let horizontalPadding: CGFloat = 12
         static let verticalPadding: CGFloat = 0
-        static let cardGap: CGFloat = 16
+        static let horizontalGap: CGFloat = 16
+        static let verticalGap: CGFloat = WaterfallMetrics.cardGap
         static let cardMinWidth: CGFloat = 220
         static let cardMaxWidth: CGFloat = 320
-        static let titleBarHeight: CGFloat = 26
-        static let titleGap: CGFloat = 6
-        static let minThumbnailHeight: CGFloat = 92
-        static let maxThumbnailHeightFraction: CGFloat = 0.40
+        static let cardHeight: CGFloat = WaterfallMetrics.cardHeight
     }
 
     private enum WaterfallHorizontalIntent {
@@ -3506,14 +3504,14 @@
             1,
             Int(
                 floor(
-                    (availableWidth + HorizontalMasonryMetrics.cardGap)
-                        / (HorizontalMasonryMetrics.cardMinWidth + HorizontalMasonryMetrics.cardGap)
+                    (availableWidth + HorizontalMasonryMetrics.horizontalGap)
+                        / (HorizontalMasonryMetrics.cardMinWidth + HorizontalMasonryMetrics.horizontalGap)
                 )
             )
         )
         let laneCount = min(maximumLaneCount, max(1, cards.count))
         let fittingWidth = (
-            availableWidth - CGFloat(max(0, laneCount - 1)) * HorizontalMasonryMetrics.cardGap
+            availableWidth - CGFloat(max(0, laneCount - 1)) * HorizontalMasonryMetrics.horizontalGap
         ) / CGFloat(laneCount)
         let cardWidth = floor(
             min(
@@ -3522,7 +3520,7 @@
             )
         )
         let usedWidth = CGFloat(laneCount) * cardWidth
-            + CGFloat(max(0, laneCount - 1)) * HorizontalMasonryMetrics.cardGap
+            + CGFloat(max(0, laneCount - 1)) * HorizontalMasonryMetrics.horizontalGap
         let startX = max(
             HorizontalMasonryMetrics.horizontalPadding,
             (viewportWidth - usedWidth) / 2
@@ -3538,12 +3536,8 @@
                 }
                 return lhs.offset < rhs.offset
             }?.offset ?? 0
-            let cardHeight = horizontalMasonryCardHeight(
-                for: card,
-                width: cardWidth,
-                viewportHeight: waterfallLayer.bounds.height
-            )
-            let x = startX + CGFloat(laneIndex) * (cardWidth + HorizontalMasonryMetrics.cardGap)
+            let cardHeight = HorizontalMasonryMetrics.cardHeight
+            let x = startX + CGFloat(laneIndex) * (cardWidth + HorizontalMasonryMetrics.horizontalGap)
             let top = HorizontalMasonryMetrics.verticalPadding + laneHeights[laneIndex]
             plannedFrames.append((
                 windowID: card.item.window.id,
@@ -3552,11 +3546,11 @@
                 width: cardWidth,
                 height: cardHeight
             ))
-            laneHeights[laneIndex] += cardHeight + HorizontalMasonryMetrics.cardGap
+            laneHeights[laneIndex] += cardHeight + HorizontalMasonryMetrics.verticalGap
         }
 
         let tallestLane = laneHeights.max().map {
-            max(0, $0 - HorizontalMasonryMetrics.cardGap)
+            max(0, $0 - HorizontalMasonryMetrics.verticalGap)
         } ?? 0
         let contentHeight = max(
             waterfallLayer.bounds.height,
@@ -3577,43 +3571,6 @@
         )
 
         return HorizontalMasonryLayout(contentHeight: contentHeight, cardFramesByWindowID: frames)
-    }
-
-    private func horizontalMasonryCardHeight(
-        for card: WaterfallCardLayers,
-        width: CGFloat,
-        viewportHeight: CGFloat
-    ) -> CGFloat {
-        let thumbnailHeight = min(
-            max(
-                HorizontalMasonryMetrics.minThumbnailHeight,
-                width / horizontalMasonryThumbnailAspectRatio(for: card)
-            ),
-            max(1, viewportHeight * HorizontalMasonryMetrics.maxThumbnailHeightFraction)
-        )
-        return HorizontalMasonryMetrics.titleBarHeight
-            + HorizontalMasonryMetrics.titleGap
-            + thumbnailHeight
-    }
-
-    private func horizontalMasonryThumbnailAspectRatio(for card: WaterfallCardLayers) -> CGFloat {
-        if card.item.window.isFullscreen {
-            return 16.0 / 9.0
-        }
-        if card.item.window.isMinimized {
-            return 4.0 / 3.0
-        }
-
-        switch Int(card.item.window.id % 4) {
-        case 0:
-            return 16.0 / 9.0
-        case 1:
-            return 3.0 / 2.0
-        case 2:
-            return 4.0 / 3.0
-        default:
-            return 5.0 / 4.0
-        }
     }
 
     private func horizontalMasonryContentFrame() -> CGRect {
diff --git a/C3.tools/round1-horizontal-waterfall-fixture-qa.sh b/C3.tools/round1-horizontal-waterfall-fixture-qa.sh
index 712b8af..a441016 100755
--- a/C3.tools/round1-horizontal-waterfall-fixture-qa.sh
+++ b/C3.tools/round1-horizontal-waterfall-fixture-qa.sh
@@ -1,7 +1,7 @@
 #!/bin/bash
 # Round01.1 horizontal Waterfall fixture QA. It verifies the P1 masonry view:
-# no horizontal scroll, centered equal-width cards, variable heights, thumbnail
-# 40% max-height, App Shelf anchoring, and horizontal-mode Tab navigation.
+# no horizontal scroll, centered equal-width fixed-height cards, 150pt vertical
+# placement steps, App Shelf anchoring, and horizontal-mode Tab navigation.
 
 set -euo pipefail
 
@@ -14,7 +14,7 @@
 KEYBOARD_REPORT="$BUILD_REPORT_ROOT/round01-horizontal-waterfall-keyboard-report.json"
 FILTER_REPORT="$BUILD_REPORT_ROOT/round01-horizontal-waterfall-filter-report.json"
 FIXTURE_APP_COUNT="${ALIGNER_ROUND1_HORIZONTAL_WATERFALL_FIXTURE_APP_COUNT:-8}"
-FIXTURE_WINDOWS_PER_APP="${ALIGNER_ROUND1_HORIZONTAL_WATERFALL_FIXTURE_WINDOWS_PER_APP:-4}"
+FIXTURE_WINDOWS_PER_APP="${ALIGNER_ROUND1_HORIZONTAL_WATERFALL_FIXTURE_WINDOWS_PER_APP:-6}"
 HOVER_APP_INDEX="${ALIGNER_ROUND1_HORIZONTAL_WATERFALL_HOVER_APP_INDEX:-7}"
 KEY_SEQUENCE="${ALIGNER_ROUND1_HORIZONTAL_WATERFALL_KEY_SEQUENCE:-tab}"
 REPORT_WAIT="${ALIGNER_ROUND1_HORIZONTAL_WATERFALL_REPORT_WAIT:-6.0}"
@@ -127,11 +127,28 @@
 widths = [round(card.get("frame", {}).get("width", 0), 1) for card in cards]
 require(len(set(widths)) == 1, "horizontal masonry cards must be equal width")
 heights = [round(card.get("frame", {}).get("height", 0), 1) for card in cards]
-require(len(set(heights)) >= 2, "horizontal masonry cards must expose variable heights")
+expected_card_height = 138.0
+expected_thumbnail_height = 106.0
+expected_card_step = 150.0
+require(len(set(heights)) == 1, "horizontal masonry cards must use one fixed height")
+require(abs(heights[0] - expected_card_height) <= 1.0, "horizontal masonry card height must match vertical Waterfall 138pt height")
 require(all(card.get("frame", {}).get("x", -1) >= -1 for card in cards), "cards must not overflow left")
 require(all(card.get("frame", {}).get("x", 0) + card.get("frame", {}).get("width", 0) <= waterfall_width + 1 for card in cards), "cards must not overflow right")
-require(all(card.get("thumbnailFrame", {}).get("height", 0) <= waterfall_height * 0.40 + 1.0 for card in cards), "thumbnail height must be capped to 40% of Waterfall height")
+thumbnail_heights = [round(card.get("thumbnailFrame", {}).get("height", 0), 1) for card in cards]
+require(all(abs(height - expected_thumbnail_height) <= 1.0 for height in thumbnail_heights), "horizontal masonry thumbnails must use the same fixed card template height as vertical cards")
 require(all(card.get("titleBarFrame", {}).get("y", 0) >= card.get("thumbnailFrame", {}).get("y", 0) + card.get("thumbnailFrame", {}).get("height", 0) for card in cards), "title bars must remain above thumbnails")
+
+cards_by_lane = {}
+for card in cards:
+    lane_x = round(card.get("frame", {}).get("x", 0), 1)
+    cards_by_lane.setdefault(lane_x, []).append(card)
+lane_steps = []
+for lane_cards in cards_by_lane.values():
+    ordered = sorted(lane_cards, key=lambda card: card.get("frame", {}).get("y", 0), reverse=True)
+    for upper, lower in zip(ordered, ordered[1:]):
+        lane_steps.append(round(upper.get("frame", {}).get("y", 0) - lower.get("frame", {}).get("y", 0), 1))
+require(lane_steps, "fixture must place multiple cards in at least one horizontal masonry lane")
+require(all(abs(step - expected_card_step) <= 1.0 for step in lane_steps), "horizontal masonry vertical placement step must be 150pt")
 
 for expected_index, column in enumerate(columns):
     require(column.get("appGroupIndex") == expected_index, "appGroupIndex must remain sequential")
@@ -150,7 +167,9 @@
     "appCount": report.get("appCount"),
     "windowCount": report.get("windowCount"),
     "cardWidth": widths[0],
-    "distinctHeights": sorted(set(heights))[:6],
+    "cardHeight": heights[0],
+    "thumbnailHeight": thumbnail_heights[0],
+    "cardStep": expected_card_step,
     "horizontalMasonryScrollOffset": root.get("horizontalMasonryScrollOffset"),
     "horizontalMasonryMaxScrollOffset": root.get("horizontalMasonryMaxScrollOffset")
 }, indent=2, ensure_ascii=False))
@@ -229,6 +248,8 @@
 
 widths = [round(card.get("frame", {}).get("width", 0), 1) for card in cards]
 require(len(set(widths)) == 1, "filtered horizontal cards must remain equal width")
+heights = [round(card.get("frame", {}).get("height", 0), 1) for card in cards]
+require(len(set(heights)) == 1 and abs(heights[0] - 138.0) <= 1.0, "filtered horizontal cards must keep the fixed 138pt height")
 visible_width = root.get("waterfallVisibleWidth", 0)
 require(all(card.get("frame", {}).get("x", -1) >= -1 for card in cards), "filtered cards must not overflow left")
 require(all(card.get("frame", {}).get("x", 0) + card.get("frame", {}).get("width", 0) <= visible_width + 1 for card in cards), "filtered cards must not overflow right")

--
Gitblit v1.9.3