diff --git a/Kit/plugins/Charts.swift b/Kit/plugins/Charts.swift index dc85a386..0e162534 100644 --- a/Kit/plugins/Charts.swift +++ b/Kit/plugins/Charts.swift @@ -335,17 +335,17 @@ public class NetworkChartView: NSView { } let lineWidth = 1 / (NSScreen.main?.backingScaleFactor ?? 1) - let zero: CGFloat = (dirtyRect.height/2) + dirtyRect.origin.y - let xRatio: CGFloat = (dirtyRect.width + (lineWidth*3)) / CGFloat(points.count) + let zero: CGFloat = (self.frame.height/2) + self.frame.origin.y + let xRatio: CGFloat = (self.frame.width + (lineWidth*3)) / CGFloat(points.count) let columnXPoint = { (point: Int) -> CGFloat in - return (CGFloat(point) * xRatio) + (dirtyRect.origin.x - lineWidth) + return (CGFloat(point) * xRatio) + (self.frame.origin.x - lineWidth) } let uploadYPoint = { (point: Int) -> CGFloat in - return scaleValue(scale: self.scale, value: points[point].0, maxValue: uploadMax, maxHeight: dirtyRect.height/2) + (dirtyRect.height/2 + dirtyRect.origin.y) + return scaleValue(scale: self.scale, value: points[point].0, maxValue: uploadMax, maxHeight: self.frame.height/2) + (self.frame.height/2 + self.frame.origin.y) } let downloadYPoint = { (point: Int) -> CGFloat in - return (dirtyRect.height/2 + dirtyRect.origin.y) - scaleValue(scale: self.scale, value: points[point].1, maxValue: downloadMax, maxHeight: dirtyRect.height/2) + return (self.frame.height/2 + self.frame.origin.y) - scaleValue(scale: self.scale, value: points[point].1, maxValue: downloadMax, maxHeight: self.frame.height/2) } let uploadlinePath = NSBezierPath() @@ -401,7 +401,7 @@ public class NetworkChartView: NSView { let uploadTextWidth = uploadText.widthOfString(usingFont: stringAttributes[NSAttributedString.Key.font] as! NSFont) let downloadTextWidth = downloadText.widthOfString(usingFont: stringAttributes[NSAttributedString.Key.font] as! NSFont) - var rect = CGRect(x: 1, y: dirtyRect.height - 9, width: uploadTextWidth, height: 8) + var rect = CGRect(x: 1, y: self.frame.height - 9, width: uploadTextWidth, height: 8) NSAttributedString.init(string: uploadText, attributes: stringAttributes).draw(with: rect) rect = CGRect(x: 1, y: 2, width: downloadTextWidth, height: 8) @@ -480,7 +480,7 @@ public class PieChartView: NSView { } public override func draw(_ rect: CGRect) { - let arcWidth: CGFloat = self.filled ? min(rect.width, rect.height) / 2 : 7 + let arcWidth: CGFloat = self.filled ? min(self.frame.width, self.frame.height) / 2 : 7 let fullCircle = 2 * CGFloat.pi var segments = self.segments let totalAmount = segments.reduce(0) { $0 + $1.value } @@ -488,8 +488,8 @@ public class PieChartView: NSView { segments.append(circle_segment(value: Double(1-totalAmount), color: self.nonActiveSegmentColor.withAlphaComponent(0.5))) } - let centerPoint = CGPoint(x: rect.midX, y: rect.midY) - let radius = (min(rect.width, rect.height) - arcWidth) / 2 + let centerPoint = CGPoint(x: self.frame.width/2, y: self.frame.height/2) + let radius = (min(self.frame.width, self.frame.height) - arcWidth) / 2 guard let context = NSGraphicsContext.current?.cgContext else { return } context.setShouldAntialias(true) @@ -564,8 +564,8 @@ public class HalfCircleGraphView: NSView { public override func draw(_ rect: CGRect) { let arcWidth: CGFloat = 7.0 - let centerPoint = CGPoint(x: rect.midX, y: rect.midY) - let radius = (min(rect.width, rect.height) - arcWidth) / 2 + let radius = (min(self.frame.width, self.frame.height) - arcWidth) / 2 + let centerPoint = CGPoint(x: self.frame.width/2, y: self.frame.height/2) guard let context = NSGraphicsContext.current?.cgContext else { return } context.setShouldAntialias(true) @@ -585,7 +585,7 @@ public class HalfCircleGraphView: NSView { var previousAngle = startAngle context.saveGState() - context.translateBy(x: rect.width, y: 0) + context.translateBy(x: self.frame.width, y: 0) context.scaleBy(x: -1, y: 1) for segment in segments { @@ -647,22 +647,22 @@ public class TachometerGraphView: NSView { } public override func draw(_ rect: CGRect) { - let arcWidth: CGFloat = self.filled ? min(rect.width, rect.height) / 2 : 7 + let arcWidth: CGFloat = self.filled ? min(self.frame.width, self.frame.height) / 2 : 7 var segments = self.segments let totalAmount = segments.reduce(0) { $0 + $1.value } if totalAmount < 1 { segments.append(circle_segment(value: Double(1-totalAmount), color: NSColor.lightGray.withAlphaComponent(0.5))) } - let centerPoint = CGPoint(x: rect.midX, y: rect.midY) - let radius = (min(rect.width, rect.height) - arcWidth) / 2 + let centerPoint = CGPoint(x: self.frame.width/2, y: self.frame.height/2) + let radius = (min(self.frame.width, self.frame.height) - arcWidth) / 2 guard let context = NSGraphicsContext.current?.cgContext else { return } context.setShouldAntialias(true) context.setLineWidth(arcWidth) context.setLineCap(.butt) - context.translateBy(x: rect.width, y: -4) + context.translateBy(x: self.frame.width, y: -4) context.scaleBy(x: -1, y: 1) let startAngle: CGFloat = 0 diff --git a/Modules/CPU/popup.swift b/Modules/CPU/popup.swift index 2a7a8018..428258c5 100644 --- a/Modules/CPU/popup.swift +++ b/Modules/CPU/popup.swift @@ -204,29 +204,30 @@ internal class Popup: PopupWrapper { private func initDashboard() -> NSView { let view: NSView = NSView(frame: NSRect(x: 0, y: 0, width: self.frame.width, height: self.dashboardHeight)) - let container: NSView = NSView(frame: NSRect(x: 0, y: 10, width: view.frame.width, height: self.dashboardHeight-20)) - self.circle = PieChartView(frame: NSRect( - x: (container.frame.width - container.frame.height)/2, - y: 0, - width: container.frame.height, - height: container.frame.height - ), segments: [], drawValue: true) - self.circle!.toolTip = localizedString("CPU usage") - container.addSubview(self.circle!) + let usageSize = self.dashboardHeight-20 + let usageX = (view.frame.width - usageSize)/2 - let centralWidth: CGFloat = self.dashboardHeight-20 - let sideWidth: CGFloat = (view.frame.width - centralWidth - (Constants.Popup.margins*2))/2 - self.temperatureCircle = HalfCircleGraphView(frame: NSRect(x: (sideWidth - 60)/2, y: 10, width: 60, height: 50)) + let usage = NSView(frame: NSRect(x: usageX, y: (view.frame.height - usageSize)/2, width: usageSize, height: usageSize)) + let temperature = NSView(frame: NSRect(x: (usageX - 50)/2, y: (view.frame.height - 50)/2 - 3, width: 50, height: 50)) + let frequency = NSView(frame: NSRect(x: (usageX+usageSize) + (usageX - 50)/2, y: (view.frame.height - 50)/2 - 3, width: 50, height: 50)) + + self.circle = PieChartView(frame: NSRect(x: 0, y: 0, width: usage.frame.width, height: usage.frame.height), segments: [], drawValue: true) + self.circle!.toolTip = localizedString("CPU usage") + usage.addSubview(self.circle!) + + self.temperatureCircle = HalfCircleGraphView(frame: NSRect(x: 0, y: 0, width: temperature.frame.width, height: temperature.frame.height)) self.temperatureCircle!.toolTip = localizedString("CPU temperature") (self.temperatureCircle! as NSView).isHidden = true + temperature.addSubview(self.temperatureCircle!) - self.frequencyCircle = HalfCircleGraphView(frame: NSRect(x: view.frame.width - 60 - Constants.Popup.margins*2, y: 10, width: 60, height: 50)) + self.frequencyCircle = HalfCircleGraphView(frame: NSRect(x: 0, y: 0, width: frequency.frame.width, height: frequency.frame.height)) self.frequencyCircle!.toolTip = localizedString("CPU frequency") (self.frequencyCircle! as NSView).isHidden = true + frequency.addSubview(self.frequencyCircle!) - view.addSubview(self.temperatureCircle!) - view.addSubview(container) - view.addSubview(self.frequencyCircle!) + view.addSubview(temperature) + view.addSubview(usage) + view.addSubview(frequency) return view } diff --git a/Modules/GPU/popup.swift b/Modules/GPU/popup.swift index 04dbc182..18b034b5 100644 --- a/Modules/GPU/popup.swift +++ b/Modules/GPU/popup.swift @@ -46,7 +46,7 @@ internal class Popup: PopupWrapper { private func recalculateHeight() { let h = self.arrangedSubviews.map({ $0.bounds.height + self.spacing }).reduce(0, +) - self.spacing - if self.frame.size.height != h { + if self.frame.size.height != h && h >= 0 { self.setFrameSize(NSSize(width: self.frame.width, height: h)) self.sizeCallback?(self.frame.size) } @@ -181,9 +181,7 @@ private class GPUView: NSStackView { } private func addStats(id: String, _ val: Double? = nil) { - guard let value = val else { - return - } + guard let value = val else { return } var circle: HalfCircleGraphView var chart: LineChartView @@ -196,7 +194,7 @@ private class GPUView: NSStackView { circle.toolTip = localizedString("GPU \(id)") if let row = self.circleRow { row.setFrameSize(NSSize(width: row.frame.width, height: self.circleSize + 20)) - row.edgeInsets = NSEdgeInsets(top: 10, left: 0, bottom: 0, right: 0) + row.edgeInsets = NSEdgeInsets(top: 10, left: 10, bottom: 0, right: 10) row.heightAnchor.constraint(equalToConstant: row.bounds.height).isActive = true row.addArrangedSubview(circle) } diff --git a/Modules/RAM/popup.swift b/Modules/RAM/popup.swift index b81077a8..4a06a7c6 100644 --- a/Modules/RAM/popup.swift +++ b/Modules/RAM/popup.swift @@ -419,8 +419,8 @@ public class PressureView: NSView { public override func draw(_ rect: CGRect) { let arcWidth: CGFloat = 7.0 - let centerPoint = CGPoint(x: rect.midX, y: rect.midY) - let radius = (min(rect.width, rect.height) - arcWidth) / 2 + let centerPoint = CGPoint(x: self.frame.width/2, y: self.frame.height/2) + let radius = (min(self.frame.width, self.frame.height) - arcWidth) / 2 guard let context = NSGraphicsContext.current?.cgContext else { return } context.setShouldAntialias(true) @@ -433,7 +433,7 @@ public class PressureView: NSView { var previousAngle = startAngle context.saveGState() - context.translateBy(x: rect.width, y: 0) + context.translateBy(x: self.frame.width, y: 0) context.scaleBy(x: -1, y: 1) for segment in self.segments { diff --git a/Modules/Sensors/popup.swift b/Modules/Sensors/popup.swift index 30d609e4..55797772 100644 --- a/Modules/Sensors/popup.swift +++ b/Modules/Sensors/popup.swift @@ -107,7 +107,7 @@ internal class Popup: PopupWrapper { if let fan = f as? Fan { let view = FanView(fan, width: self.frame.width) { [weak self] in let h = container.arrangedSubviews.map({ $0.bounds.height + container.spacing }).reduce(0, +) - container.spacing - if container.frame.size.height != h { + if container.frame.size.height != h && h >= 0 { container.setFrameSize(NSSize(width: container.frame.width, height: h)) } self?.recalculateHeight() diff --git a/Stats.xcodeproj/project.pbxproj b/Stats.xcodeproj/project.pbxproj index f3a60617..8bd72819 100644 --- a/Stats.xcodeproj/project.pbxproj +++ b/Stats.xcodeproj/project.pbxproj @@ -1407,7 +1407,7 @@ New, ); LastSwiftUpdateCheck = 1410; - LastUpgradeCheck = 1430; + LastUpgradeCheck = 1500; ORGANIZATIONNAME = "Serhiy Mytrovtsiy"; TargetAttributes = { 5C22299C29CCB3C400F00E69 = { @@ -2234,6 +2234,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; @@ -2302,6 +2303,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ANALYZER_NONNULL = YES; diff --git a/Stats.xcodeproj/xcshareddata/xcschemes/SMC.xcscheme b/Stats.xcodeproj/xcshareddata/xcschemes/SMC.xcscheme index 83caeb87..f16ea553 100644 --- a/Stats.xcodeproj/xcshareddata/xcschemes/SMC.xcscheme +++ b/Stats.xcodeproj/xcshareddata/xcschemes/SMC.xcscheme @@ -1,6 +1,6 @@