From 3d8d37306e39db5c8eb41fafd95a13112d573f62 Mon Sep 17 00:00:00 2001
From: Ariver <shanghai3168@gmail.com>
Date: Thu, 11 Jun 2026 22:24:39 +0800
Subject: [PATCH] Center filtered Waterfall columns
---
C1.source/Sources/Aligner/QuickSwitchRootView.swift | 28 +++++++++++++++++++++++++---
1 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/C1.source/Sources/Aligner/QuickSwitchRootView.swift b/C1.source/Sources/Aligner/QuickSwitchRootView.swift
index 0b4e062..4f8f371 100644
--- a/C1.source/Sources/Aligner/QuickSwitchRootView.swift
+++ b/C1.source/Sources/Aligner/QuickSwitchRootView.swift
@@ -1668,6 +1668,11 @@
return
}
+ if waterfallShouldKeepFilteredColumnsCentered {
+ ensureWaterfallCardVisibleVertically(selection)
+ return
+ }
+
switch horizontalIntent {
case .reveal:
ensureWaterfallColumnVisible(column)
@@ -1751,6 +1756,10 @@
}
private var waterfallAlignmentScrollRange: ClosedRange<CGFloat> {
+ if waterfallShouldKeepFilteredColumnsCentered {
+ return 0...0
+ }
+
var minimumOffset: CGFloat = 0
var maximumOffset = waterfallMaxScrollOffset
@@ -1775,6 +1784,10 @@
private func clampedWaterfallAlignmentOffset(_ offset: CGFloat) -> CGFloat {
let range = waterfallAlignmentScrollRange
return min(max(range.lowerBound, offset), range.upperBound)
+ }
+
+ private var waterfallShouldKeepFilteredColumnsCentered: Bool {
+ currentViewModel?.lockedSpaceID != nil && waterfallMaxScrollOffset <= 0.5
}
private func setWaterfallScrollOffset(_ offset: CGFloat, animated: Bool) {
@@ -3019,9 +3032,9 @@
}
let columnWidth = waterfallColumnWidth()
- let totalWidth = WaterfallMetrics.contentHorizontalPadding * 2
- + CGFloat(waterfallColumns.count) * columnWidth
+ let columnsWidth = CGFloat(waterfallColumns.count) * columnWidth
+ CGFloat(max(0, waterfallColumns.count - 1)) * WaterfallMetrics.gap
+ let totalWidth = WaterfallMetrics.contentHorizontalPadding * 2 + columnsWidth
waterfallContentWidth = max(waterfallLayer.bounds.width, totalWidth)
waterfallScrollOffset = clampedWaterfallAlignmentOffset(waterfallScrollOffset)
waterfallContentLayer.frame = CGRect(
@@ -3031,7 +3044,7 @@
height: waterfallLayer.bounds.height
)
- var x = WaterfallMetrics.contentHorizontalPadding
+ var x = waterfallColumnStartX(columnsWidth: columnsWidth)
for column in waterfallColumns {
column.containerLayer.frame = CGRect(
x: x,
@@ -3044,6 +3057,15 @@
}
}
+ private func waterfallColumnStartX(columnsWidth: CGFloat) -> CGFloat {
+ guard currentViewModel?.lockedSpaceID != nil else {
+ return WaterfallMetrics.contentHorizontalPadding
+ }
+
+ let centeredStart = (waterfallContentWidth - columnsWidth) / 2
+ return max(WaterfallMetrics.contentHorizontalPadding, centeredStart)
+ }
+
private func layoutWaterfallColumn(_ column: WaterfallColumnLayers) {
let bounds = column.containerLayer.bounds
let isSpaceFocused = spaceFocusWindowCount(for: column.column.appGroupIndex) > 0
--
Gitblit v1.9.3