TDKCandidates // Fix calculation mistakes in horizontal layout.
This commit is contained in:
parent
aa99475645
commit
ad1a96160b
|
@ -31,10 +31,9 @@ public struct CandidatePool {
|
||||||
|
|
||||||
// MARK: - 動態變數
|
// MARK: - 動態變數
|
||||||
|
|
||||||
public var maxRowWidth: Int { Int(Double(maxRowCapacity + 3) * 2) * Int(ceil(CandidateCellData.unifiedSize)) }
|
public var maxRowWidth: Int { Int(ceil((Double(maxRowCapacity + 3) * 2 - 0.5) * CandidateCellData.unifiedSize)) }
|
||||||
public var maxWindowWidth: Double {
|
public var maxWindowWidth: Double {
|
||||||
let testCell = CandidateCellData(key: "XX", displayedText: "XX", isSelected: false)
|
Double(maxRowCapacity) * (blankCell.minWidthToDrawInSwiftUI + ceil(CandidateCellData.unifiedSize * 0.5))
|
||||||
return Double(maxRowCapacity) * (testCell.minWidthToDrawInSwiftUI + ceil(CandidateCellData.unifiedSize * 0.5))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var currentLineNumber: Int {
|
public var currentLineNumber: Int {
|
||||||
|
|
|
@ -66,10 +66,7 @@ public struct VwrCandidateHorizontal: View {
|
||||||
ForEach(Array(thePool.candidateLines[rowIndex]), id: \.self) { currentCandidate in
|
ForEach(Array(thePool.candidateLines[rowIndex]), id: \.self) { currentCandidate in
|
||||||
currentCandidate.attributedStringForSwiftUI.fixedSize()
|
currentCandidate.attributedStringForSwiftUI.fixedSize()
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.frame(
|
.frame(alignment: .topLeading)
|
||||||
maxWidth: .infinity,
|
|
||||||
alignment: .topLeading
|
|
||||||
)
|
|
||||||
.onTapGesture { didSelectCandidateAt(currentCandidate.index) }
|
.onTapGesture { didSelectCandidateAt(currentCandidate.index) }
|
||||||
.contextMenu {
|
.contextMenu {
|
||||||
if controller?.delegate?.isCandidateContextMenuEnabled ?? false {
|
if controller?.delegate?.isCandidateContextMenuEnabled ?? false {
|
||||||
|
@ -91,7 +88,7 @@ public struct VwrCandidateHorizontal: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spacer(minLength: Double.infinity)
|
Spacer()
|
||||||
}.frame(
|
}.frame(
|
||||||
minWidth: 0,
|
minWidth: 0,
|
||||||
maxWidth: .infinity,
|
maxWidth: .infinity,
|
||||||
|
@ -104,7 +101,7 @@ public struct VwrCandidateHorizontal: View {
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
thePool.blankCell.attributedStringForSwiftUI
|
thePool.blankCell.attributedStringForSwiftUI
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.frame(maxWidth: .infinity, alignment: .topLeading)
|
.frame(alignment: .topLeading)
|
||||||
Spacer()
|
Spacer()
|
||||||
}.frame(
|
}.frame(
|
||||||
minWidth: 0,
|
minWidth: 0,
|
||||||
|
|
|
@ -67,10 +67,7 @@ public struct VwrCandidateHorizontalBackports: View {
|
||||||
ForEach(Array(thePool.candidateLines[rowIndex]), id: \.self) { currentCandidate in
|
ForEach(Array(thePool.candidateLines[rowIndex]), id: \.self) { currentCandidate in
|
||||||
currentCandidate.attributedStringForSwiftUIBackports.fixedSize()
|
currentCandidate.attributedStringForSwiftUIBackports.fixedSize()
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.frame(
|
.frame(alignment: .topLeading)
|
||||||
maxWidth: .infinity,
|
|
||||||
alignment: .topLeading
|
|
||||||
)
|
|
||||||
.onTapGesture { didSelectCandidateAt(currentCandidate.index) }
|
.onTapGesture { didSelectCandidateAt(currentCandidate.index) }
|
||||||
.contextMenu {
|
.contextMenu {
|
||||||
if controller?.delegate?.isCandidateContextMenuEnabled ?? false {
|
if controller?.delegate?.isCandidateContextMenuEnabled ?? false {
|
||||||
|
@ -92,7 +89,7 @@ public struct VwrCandidateHorizontalBackports: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Spacer(minLength: Double.infinity)
|
Spacer()
|
||||||
}.frame(
|
}.frame(
|
||||||
minWidth: 0,
|
minWidth: 0,
|
||||||
maxWidth: .infinity,
|
maxWidth: .infinity,
|
||||||
|
@ -105,7 +102,7 @@ public struct VwrCandidateHorizontalBackports: View {
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
thePool.blankCell.attributedStringForSwiftUIBackports
|
thePool.blankCell.attributedStringForSwiftUIBackports
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.frame(maxWidth: .infinity, alignment: .topLeading)
|
.frame(alignment: .topLeading)
|
||||||
Spacer()
|
Spacer()
|
||||||
}.frame(
|
}.frame(
|
||||||
minWidth: 0,
|
minWidth: 0,
|
||||||
|
|
Loading…
Reference in New Issue