feat: added an Based on cluster colorize option. It will colorize efficiency and performance cores in the bar chart chart widget.

This commit is contained in:
Serhiy Mytrovtsiy
2022-08-12 18:56:43 +02:00
parent 900600ce7b
commit a2a4b93db4
8 changed files with 29 additions and 3 deletions

View File

@@ -171,8 +171,9 @@ public class BarChart: WidgetWrapper {
if partitionValue.color == nil {
switch self.colorState {
case .systemAccent: controlAccentColor.set()
case .utilization: partitionValue.value.usageColor(zones: self.colorZones, reversed: self.title == "Battery").setFill()
case .pressure: self.pressureLevel.pressureColor().setFill()
case .utilization: partitionValue.value.usageColor(zones: self.colorZones, reversed: self.title == "Battery").set()
case .pressure: self.pressureLevel.pressureColor().set()
case .cluster: (partitionValue.value.clusterColor(i) ?? controlAccentColor).set()
case .monochrome:
if self.boxState {
(isDarkMode ? NSColor.black : NSColor.white).set()

View File

@@ -193,6 +193,22 @@ public extension Double {
}
}
func clusterColor(_ i: Int) -> NSColor? {
guard let cores = SystemKit.shared.device.info.cpu?.cores,
let core = cores.first(where: {$0.id == i }) else {
return nil
}
switch core.type {
case .efficiency:
return .systemTeal
case .performance:
return .systemBlue
default:
return nil
}
}
func secondsToHoursMinutesSeconds() -> (Int, Int) {
let mins = (self.truncatingRemainder(dividingBy: 3600)) / 60
return (Int(self / 3600), Int(mins))

View File

@@ -120,6 +120,7 @@ public struct Color: KeyValue_p, Equatable {
extension Color: CaseIterable {
public static var utilization: Color { return Color(key: "utilization", value: "Based on utilization", additional: NSColor.black) }
public static var pressure: Color { return Color(key: "pressure", value: "Based on pressure", additional: NSColor.black) }
public static var cluster: Color { return Color(key: "cluster", value: "Based on cluster", additional: NSColor.black) }
public static var separator1: Color { return Color(key: "separator_1", value: "separator_1", additional: NSColor.black) }
@@ -160,7 +161,7 @@ extension Color: CaseIterable {
} }
public static var allCases: [Color] {
return [.utilization, .pressure, separator1,
return [.utilization, .pressure, .cluster, separator1,
.systemAccent, .monochrome, separator2,
.clear, .white, .black, .gray, .secondGray, .darkGray, .lightGray,
.red, .secondRed, .green, .secondGreen, .blue, .secondBlue, .yellow, .secondYellow,

View File

@@ -55,6 +55,7 @@
<key>Unsupported colors</key>
<array>
<string>pressure</string>
<string>cluster</string>
</array>
<key>Order</key>
<integer>2</integer>

View File

@@ -61,6 +61,7 @@
<key>Unsupported colors</key>
<array>
<string>pressure</string>
<string>cluster</string>
</array>
<key>Order</key>
<integer>2</integer>

View File

@@ -58,6 +58,7 @@
<key>Unsupported colors</key>
<array>
<string>pressure</string>
<string>cluster</string>
</array>
<key>Order</key>
<integer>3</integer>

View File

@@ -59,6 +59,10 @@
</dict>
<key>Order</key>
<integer>3</integer>
<key>Unsupported colors</key>
<array>
<string>cluster</string>
</array>
</dict>
<key>pie_chart</key>
<dict>

View File

@@ -41,6 +41,7 @@
<key>Unsupported colors</key>
<array>
<string>pressure</string>
<string>cluster</string>
</array>
<key>Order</key>
<integer>2</integer>