fix: reload tint colors while running
This commit is contained in:
@@ -58,9 +58,21 @@ private final class AlignmentGuideView: NSView {
|
||||
var snapsHorizontally = false
|
||||
var snapsVertically = false
|
||||
private static let dash: [CGFloat] = [1, 5]
|
||||
private static let muted = ThemePalette.accent.withAlphaComponent(0.4).cgColor
|
||||
private static let aligned = ThemePalette.accent.withAlphaComponent(0.95).cgColor
|
||||
private var muted = ThemePalette.accent.withAlphaComponent(0.4).cgColor
|
||||
private var aligned = ThemePalette.accent.withAlphaComponent(0.95).cgColor
|
||||
private static let shadow = NSColor.black.withAlphaComponent(0.6).cgColor
|
||||
private var themeObservation: ThemeObservation?
|
||||
|
||||
override init(frame frameRect: NSRect) {
|
||||
super.init(frame: frameRect)
|
||||
themeObservation = ThemeObservation { [weak self] in
|
||||
self?.muted = ThemePalette.accent.withAlphaComponent(0.4).cgColor
|
||||
self?.aligned = ThemePalette.accent.withAlphaComponent(0.95).cgColor
|
||||
self?.needsDisplay = true
|
||||
}
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) { fatalError("Conjure creates alignment guides programmatically") }
|
||||
|
||||
override func hitTest(_ point: NSPoint) -> NSView? { nil }
|
||||
|
||||
@@ -75,14 +87,14 @@ private final class AlignmentGuideView: NSView {
|
||||
context.setLineDash(phase: 0, lengths: Self.dash)
|
||||
context.setShadow(offset: .zero, blur: 2, color: Self.shadow)
|
||||
|
||||
context.setStrokeColor(snapsHorizontally ? Self.aligned : Self.muted)
|
||||
context.setStrokeColor(snapsHorizontally ? aligned : muted)
|
||||
context.move(to: NSPoint(x: targetFrame.minX, y: bounds.minY))
|
||||
context.addLine(to: NSPoint(x: targetFrame.minX, y: bounds.maxY))
|
||||
context.move(to: NSPoint(x: targetFrame.maxX, y: bounds.minY))
|
||||
context.addLine(to: NSPoint(x: targetFrame.maxX, y: bounds.maxY))
|
||||
context.strokePath()
|
||||
|
||||
context.setStrokeColor(snapsVertically ? Self.aligned : Self.muted)
|
||||
context.setStrokeColor(snapsVertically ? aligned : muted)
|
||||
context.move(to: NSPoint(x: bounds.minX, y: targetFrame.maxY))
|
||||
context.addLine(to: NSPoint(x: bounds.maxX, y: targetFrame.maxY))
|
||||
context.strokePath()
|
||||
|
||||
Reference in New Issue
Block a user