From 82c6f07121afe2e1614b33dfb0d4d2ecb70d12cc Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Wed, 9 Mar 2022 16:29:24 +0800 Subject: [PATCH] Voltaire // Differentiate highlight background colors between NSAppearances. --- Source/UI/CandidateUI/HorizontalCandidateController.swift | 5 +++-- Source/UI/CandidateUI/VerticalCandidateController.swift | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/UI/CandidateUI/HorizontalCandidateController.swift b/Source/UI/CandidateUI/HorizontalCandidateController.swift index bab60327..5a67a587 100644 --- a/Source/UI/CandidateUI/HorizontalCandidateController.swift +++ b/Source/UI/CandidateUI/HorizontalCandidateController.swift @@ -118,12 +118,13 @@ fileprivate class HorizontalCandidateView: NSView { var activeCandidateIndexAttr = keyLabelAttrDict var activeCandidateAttr = candidateAttrDict if index == highlightedIndex { + let colorBlendAmount: CGFloat = IME.isDarkMode() ? 0.25 : 0 // The background color of the highlightened candidate switch ctlInputMethod.currentKeyHandler.inputMode { case InputMode.imeModeCHS: - NSColor.systemRed.withAlphaComponent(0.75).setFill() + NSColor.systemRed.blended(withFraction: colorBlendAmount, of: NSColor.controlBackgroundColor)!.setFill() case InputMode.imeModeCHT: - NSColor.systemBlue.withAlphaComponent(0.75).setFill() + NSColor.systemBlue.blended(withFraction: colorBlendAmount, of: NSColor.controlBackgroundColor)!.setFill() default: NSColor.alternateSelectedControlColor.setFill() } diff --git a/Source/UI/CandidateUI/VerticalCandidateController.swift b/Source/UI/CandidateUI/VerticalCandidateController.swift index da384088..386aa2a7 100644 --- a/Source/UI/CandidateUI/VerticalCandidateController.swift +++ b/Source/UI/CandidateUI/VerticalCandidateController.swift @@ -124,12 +124,13 @@ fileprivate class VerticalCandidateView: NSView { var activeCandidateIndexAttr = keyLabelAttrDict var activeCandidateAttr = candidateAttrDict if index == highlightedIndex { + let colorBlendAmount: CGFloat = IME.isDarkMode() ? 0.25 : 0 // The background color of the highlightened candidate switch ctlInputMethod.currentKeyHandler.inputMode { case InputMode.imeModeCHS: - NSColor.systemRed.withAlphaComponent(0.75).setFill() + NSColor.systemRed.blended(withFraction: colorBlendAmount, of: NSColor.controlBackgroundColor)!.setFill() case InputMode.imeModeCHT: - NSColor.systemBlue.withAlphaComponent(0.75).setFill() + NSColor.systemBlue.blended(withFraction: colorBlendAmount, of: NSColor.controlBackgroundColor)!.setFill() default: NSColor.alternateSelectedControlColor.setFill() }