Shiki: Voltaire // Horizontal Candidate View Cleanup

This commit is contained in:
ShikiSuen 2022-01-21 23:40:03 +08:00
parent 22bfbbad62
commit fdc92744e4
1 changed files with 2 additions and 4 deletions

View File

@ -36,8 +36,7 @@ fileprivate class HorizontalCandidateView: NSView {
if !elementWidths.isEmpty {
result.width = elementWidths.reduce(0, +)
result.width += CGFloat(elementWidths.count)
// result.height = keyLabelHeight + candidateTextHeight + 1.0
result.height = candidateTextHeight + cellPadding;
result.height = candidateTextHeight + cellPadding
}
return result
}
@ -47,14 +46,13 @@ fileprivate class HorizontalCandidateView: NSView {
let count = min(labels.count, candidates.count)
keyLabels = Array(labels[0..<count])
displayedCandidates = Array(candidates[0..<count])
// dispCandidatesWithLabels = keyLabels + displayedCandidates
dispCandidatesWithLabels = zip(keyLabels,displayedCandidates).map() {$0 + $1}
var newWidths = [CGFloat]()
let baseSize = NSSize(width: 10240.0, height: 10240.0)
for index in 0..<count {
let rctCandidate = (dispCandidatesWithLabels[index] as NSString).boundingRect(with: baseSize, options: .usesLineFragmentOrigin, attributes: candidateWithLabelAttrDict)
let cellWidth = rctCandidate.size.width + cellPadding;
let cellWidth = rctCandidate.size.width + cellPadding
newWidths.append(cellWidth)
}
elementWidths = newWidths