diff --git a/ModuleKit/Widgets/Mini.swift b/ModuleKit/Widgets/Mini.swift index 5a0dd99e..79b03ddf 100644 --- a/ModuleKit/Widgets/Mini.swift +++ b/ModuleKit/Widgets/Mini.swift @@ -102,7 +102,7 @@ public class Mini: Widget, CALayerDelegate { case .systemAccent: valueColor = NSColor.controlAccentColor case .utilization: valueColor = self.value.usageColor() case .pressure: valueColor = self.pressureLevel.pressureColor() - case .monochrome: valueColor = NSColor.labelColor + case .monochrome: valueColor = NSColor.textColor default: valueColor = colorFromString("\(self.colorState.self)") } @@ -134,8 +134,8 @@ public class Mini: Widget, CALayerDelegate { self.labelLayer?.isHidden = !self.labelState if var frame = self.valueLayer?.frame { - frame.origin = CGPoint(x: origin.x, y: origin.y) - frame.size = CGSize(width: width - (Constants.Widget.margin*2), height: valueSize) + frame.origin = CGPoint(x: origin.x, y: origin.y-1) + frame.size = CGSize(width: width - (Constants.Widget.margin*2), height: valueSize+1) self.valueLayer?.frame = frame } self.valueLayer?.fontSize = valueSize @@ -160,13 +160,12 @@ public class Mini: Widget, CALayerDelegate { label.frame = CGRect(x: origin.x, y: 11, width: self.width - (Constants.Widget.margin*2), height: 8) label.string = self.title label.alignmentMode = .left - label.isHidden = true label.foregroundColor = NSColor.labelColor.cgColor label.isHidden = !self.labelState let value = CAText(fontSize: valueSize) - value.frame = CGRect(x: origin.x, y: origin.y, width: self.width - (Constants.Widget.margin*2), height: valueSize) - value.font = NSFont.systemFont(ofSize: valueSize, weight: .semibold) + value.frame = CGRect(x: origin.x, y: origin.y-1, width: self.width - (Constants.Widget.margin*2), height: valueSize+1) + value.font = NSFont.systemFont(ofSize: valueSize, weight: .medium) value.string = "\(Int(self.value.rounded(toPlaces: 2) * 100))%" value.fontSize = valueSize value.alignmentMode = alignment @@ -188,14 +187,9 @@ public class Mini: Widget, CALayerDelegate { DispatchQueue.main.async(execute: { self.value = value - - CATransaction.begin() - CATransaction.setDisableActions(true) - CATransaction.setValue(kCFBooleanTrue, forKey: kCATransactionDisableActions) - CATransaction.setAnimationDuration(0) - self.valueLayer?.string = "\(Int(self.value.rounded(toPlaces: 2) * 100))%" - CATransaction.commit() - + CATransaction.disableAnimations { + self.valueLayer?.string = "\(Int(self.value.rounded(toPlaces: 2) * 100))%" + } self.needsDisplay = true }) } diff --git a/Modules/CPU/config.plist b/Modules/CPU/config.plist index 11f2ca1c..46a68fdf 100644 --- a/Modules/CPU/config.plist +++ b/Modules/CPU/config.plist @@ -15,7 +15,7 @@ Preview Value - 0.08 + 0.12 Unsupported colors diff --git a/StatsKit/extensions.swift b/StatsKit/extensions.swift index 021f48d2..592f7d70 100644 --- a/StatsKit/extensions.swift +++ b/StatsKit/extensions.swift @@ -490,3 +490,14 @@ public extension NSColor { return String(format:"#%06x", rgb) } } + +public extension CATransaction { + static func disableAnimations(_ closure: () -> Void) { + CATransaction.begin() + CATransaction.setDisableActions(true) + CATransaction.setValue(kCFBooleanTrue, forKey: kCATransactionDisableActions) + CATransaction.setAnimationDuration(0) + closure() + CATransaction.commit() + } +} diff --git a/StatsKit/helpers.swift b/StatsKit/helpers.swift index 62cec751..de074062 100644 --- a/StatsKit/helpers.swift +++ b/StatsKit/helpers.swift @@ -159,7 +159,7 @@ public struct Units { } public class LabelField: NSTextField { - public init(frame: NSRect, _ label: String) { + public init(frame: NSRect, _ label: String = "") { super.init(frame: frame) self.isEditable = false @@ -181,7 +181,7 @@ public class LabelField: NSTextField { } public class ValueField: NSTextField { - public init(frame: NSRect, _ value: String) { + public init(frame: NSRect, _ value: String = "") { super.init(frame: frame) self.isEditable = false