CtlCandidateTDK // Use round candidate window.

This commit is contained in:
ShikiSuen 2022-10-08 19:37:45 +08:00
parent 4676c995ce
commit b5abb2db4e
5 changed files with 23 additions and 17 deletions

View File

@ -63,7 +63,6 @@ public class CtlCandidateTDK: CtlCandidate {
panel.hasShadow = true panel.hasShadow = true
panel.isOpaque = false panel.isOpaque = false
panel.backgroundColor = NSColor.clear panel.backgroundColor = NSColor.clear
contentRect.origin = NSPoint.zero contentRect.origin = NSPoint.zero
super.init(layout) super.init(layout)
@ -104,33 +103,34 @@ public class CtlCandidateTDK: CtlCandidate {
} }
override open func updateDisplay() { override open func updateDisplay() {
guard let window = window else { return }
switch currentLayout { switch currentLayout {
case .horizontal: case .horizontal:
DispatchQueue.main.async { [self] in DispatchQueue.main.async { [self] in
if #available(macOS 12, *) { if #available(macOS 12, *) {
let newView = NSHostingView(rootView: theViewHorizontal) let newView = NSHostingView(rootView: theViewHorizontal.edgesIgnoringSafeArea(.top))
let newSize = newView.fittingSize let newSize = newView.fittingSize
window?.contentView = newView window.contentView = newView
window?.setContentSize(newSize) window.setContentSize(newSize)
} else { } else {
let newView = NSHostingView(rootView: theViewHorizontalBackports) let newView = NSHostingView(rootView: theViewHorizontalBackports.edgesIgnoringSafeArea(.top))
let newSize = newView.fittingSize let newSize = newView.fittingSize
window?.contentView = newView window.contentView = newView
window?.setContentSize(newSize) window.setContentSize(newSize)
} }
} }
case .vertical: case .vertical:
DispatchQueue.main.async { [self] in DispatchQueue.main.async { [self] in
if #available(macOS 12, *) { if #available(macOS 12, *) {
let newView = NSHostingView(rootView: theViewVertical) let newView = NSHostingView(rootView: theViewVertical.edgesIgnoringSafeArea(.top))
let newSize = newView.fittingSize let newSize = newView.fittingSize
window?.contentView = newView window.contentView = newView
window?.setContentSize(newSize) window.setContentSize(newSize)
} else { } else {
let newView = NSHostingView(rootView: theViewVerticalBackports) let newView = NSHostingView(rootView: theViewVerticalBackports.edgesIgnoringSafeArea(.top))
let newSize = newView.fittingSize let newSize = newView.fittingSize
window?.contentView = newView window.contentView = newView
window?.setContentSize(newSize) window.setContentSize(newSize)
} }
} }
@unknown default: @unknown default:

View File

@ -100,11 +100,13 @@ public struct VwrCandidateHorizontal: View {
.lineLimit( .lineLimit(
1) 1)
} }
.padding(6).foregroundColor( .padding(7).foregroundColor(
.init(nsColor: tooltip.isEmpty ? .controlTextColor : .selectedMenuItemTextColor.withAlphaComponent(0.9)) .init(nsColor: tooltip.isEmpty ? .controlTextColor : .selectedMenuItemTextColor.withAlphaComponent(0.9))
) )
} }
.fixedSize(horizontal: false, vertical: true)
} }
.frame(minWidth: thePool.maxWindowWidth, maxWidth: thePool.maxWindowWidth) .frame(minWidth: thePool.maxWindowWidth, maxWidth: thePool.maxWindowWidth)
.cornerRadius(10)
} }
} }

View File

@ -105,10 +105,11 @@ public struct VwrCandidateVertical: View {
.lineLimit( .lineLimit(
1) 1)
} }
.padding(6).foregroundColor( .padding(7).foregroundColor(
.init(nsColor: tooltip.isEmpty ? .controlTextColor : .selectedMenuItemTextColor.withAlphaComponent(0.9)) .init(nsColor: tooltip.isEmpty ? .controlTextColor : .selectedMenuItemTextColor.withAlphaComponent(0.9))
) )
} }
} }
.cornerRadius(10)
} }
} }

View File

@ -105,11 +105,13 @@ public struct VwrCandidateHorizontalBackports: View {
.lineLimit( .lineLimit(
1) 1)
} }
.padding(6).foregroundColor( .padding(7).foregroundColor(
tooltip.isEmpty && colorScheme == .light ? Color(white: 0.1) : Color(white: 0.9) tooltip.isEmpty && colorScheme == .light ? Color(white: 0.1) : Color(white: 0.9)
) )
} }
.fixedSize(horizontal: false, vertical: true)
} }
.frame(minWidth: thePool.maxWindowWidth, maxWidth: thePool.maxWindowWidth) .frame(minWidth: thePool.maxWindowWidth, maxWidth: thePool.maxWindowWidth)
.cornerRadius(10)
} }
} }

View File

@ -110,10 +110,11 @@ public struct VwrCandidateVerticalBackports: View {
.lineLimit( .lineLimit(
1) 1)
} }
.padding(6).foregroundColor( .padding(7).foregroundColor(
tooltip.isEmpty && colorScheme == .light ? Color(white: 0.1) : Color(white: 0.9) tooltip.isEmpty && colorScheme == .light ? Color(white: 0.1) : Color(white: 0.9)
) )
} }
} }
.cornerRadius(10)
} }
} }