TDKCandidates // Refactor highlightedColor().
This commit is contained in:
parent
f46cfda6f5
commit
951f41461a
|
@ -17,26 +17,24 @@ open class CtlCandidate: NSWindowController, CtlCandidateProtocol {
|
||||||
open var reverseLookupResult: [String] = []
|
open var reverseLookupResult: [String] = []
|
||||||
|
|
||||||
open func highlightedColor() -> NSColor {
|
open func highlightedColor() -> NSColor {
|
||||||
var result = NSColor.controlAccentColor
|
var result = NSColor.clear
|
||||||
var colorBlendAmount: Double = NSApplication.isDarkMode ? 0.3 : 0.0
|
if #available(macOS 10.14, *) {
|
||||||
if #available(macOS 10.14, *), !NSApplication.isDarkMode, locale == "zh-Hant" {
|
result = .controlAccentColor
|
||||||
colorBlendAmount = 0.15
|
} else {
|
||||||
|
result = .alternateSelectedControlTextColor
|
||||||
}
|
}
|
||||||
|
let colorBlendAmount = 0.3
|
||||||
// 設定當前高亮候選字的背景顏色。
|
// 設定當前高亮候選字的背景顏色。
|
||||||
switch locale {
|
switch locale {
|
||||||
case "zh-Hans":
|
case "zh-Hans":
|
||||||
result = NSColor.systemRed
|
result = NSColor.red
|
||||||
case "zh-Hant":
|
case "zh-Hant":
|
||||||
result = NSColor.systemBlue
|
result = NSColor.blue
|
||||||
case "ja":
|
case "ja":
|
||||||
result = NSColor.systemBrown
|
result = NSColor.brown
|
||||||
default: break
|
default: break
|
||||||
}
|
}
|
||||||
var blendingAgainstTarget: NSColor = NSApplication.isDarkMode ? NSColor.black : NSColor.white
|
let blendingAgainstTarget: NSColor = NSApplication.isDarkMode ? NSColor.black : NSColor.white
|
||||||
if #unavailable(macOS 10.14) {
|
|
||||||
colorBlendAmount = 0.3
|
|
||||||
blendingAgainstTarget = NSColor.white
|
|
||||||
}
|
|
||||||
return result.blended(withFraction: colorBlendAmount, of: blendingAgainstTarget)!
|
return result.blended(withFraction: colorBlendAmount, of: blendingAgainstTarget)!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue