diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool.swift index 31d67658..e0a6fd23 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/CandidatePool.swift @@ -11,6 +11,7 @@ import Shared /// 候選字窗會用到的資料池單位。 public class CandidatePool { + public let blankCell = CandidateCellData(key: " ", displayedText: " ", isSelected: false) public var currentRowNumber = 0 public var maximumLinesPerPage = 3 public private(set) var selectionKeys: String @@ -20,7 +21,6 @@ public class CandidatePool { public private(set) var candidateRows: [[CandidateCellData]] = [] public var isVerticalLayout: Bool { maxColumnCapacity == 1 } public var maxColumnWidth: Int { Int(Double(maxColumnCapacity + 3) * 2) * Int(ceil(CandidateCellData.unifiedSize)) } - public var maxWindowHeight: Double { ceil(maxWindowWidth * 0.4 / 2) } public var maxWindowWidth: Double { ceil(Double(maxColumnCapacity + 3) * 2.7 * ceil(CandidateCellData.unifiedSize) * 1.2) } @@ -29,6 +29,8 @@ public class CandidatePool { currentRowNumber.. { 0..<(maximumLinesPerPage - rangeForCurrentPage.count) } + public enum VerticalDirection { case up case down diff --git a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/VwrCandidateTDK.swift b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/VwrCandidateTDK.swift index e5bc40d9..414d156c 100644 --- a/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/VwrCandidateTDK.swift +++ b/Packages/vChewing_CandidateWindow/Sources/CandidateWindow/VwrCandidateTDK.swift @@ -68,9 +68,24 @@ public struct VwrCandidateTDK: View { ).id(columnIndex) Divider() } + if thePool.maximumLinesPerPage - thePool.rangeForCurrentPage.count > 0 { + ForEach(thePool.rangeForLastPageBlanked, id: \.self) { _ in + HStack(spacing: 0) { + thePool.blankCell.attributedStringForSwiftUI.fixedSize() + .frame(maxWidth: .infinity, alignment: .topLeading) + .contentShape(Rectangle()) + Spacer() + }.frame( + minWidth: 0, + maxWidth: .infinity, + alignment: .topLeading + ) + Divider() + } + } } } - .frame(minHeight: thePool.maxWindowHeight, maxHeight: thePool.maxWindowHeight).padding(5) + .fixedSize(horizontal: false, vertical: true).padding(5) .background(Color(nsColor: NSColor.controlBackgroundColor).ignoresSafeArea()) HStack(alignment: .bottom) { Text(hint).font(.system(size: max(CandidateCellData.unifiedSize * 0.7, 11), weight: .bold)).lineLimit(1)