From e6bdb2df2b92afcb8fbfda8a476f1dee1be7c3ac Mon Sep 17 00:00:00 2001 From: Serhiy Mytrovtsiy Date: Mon, 16 Mar 2026 21:42:15 +0100 Subject: [PATCH] feat: renamed BarChart to ColumnChart --- Kit/plugins/Charts.swift | 44 ++++++++++++++++++++++++++++------------ Modules/CPU/popup.swift | 8 ++++---- Modules/CPU/portal.swift | 8 ++++---- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/Kit/plugins/Charts.swift b/Kit/plugins/Charts.swift index c0dfa782..6e4cd0a7 100644 --- a/Kit/plugins/Charts.swift +++ b/Kit/plugins/Charts.swift @@ -157,9 +157,10 @@ public class LineChartView: NSView { self.addTrackingArea(NSTrackingArea( rect: CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height), options: [ - NSTrackingArea.Options.activeAlways, - NSTrackingArea.Options.mouseEnteredAndExited, - NSTrackingArea.Options.mouseMoved + .activeAlways, + .mouseEnteredAndExited, + .mouseMoved, + .inVisibleRect ], owner: self, userInfo: nil )) @@ -346,11 +347,12 @@ public class LineChartView: NSView { public override func updateTrackingAreas() { self.trackingAreas.forEach({ self.removeTrackingArea($0) }) self.addTrackingArea(NSTrackingArea( - rect: CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height), + rect: .zero, options: [ - NSTrackingArea.Options.activeAlways, - NSTrackingArea.Options.mouseEnteredAndExited, - NSTrackingArea.Options.mouseMoved + .activeAlways, + .mouseEnteredAndExited, + .mouseMoved, + .inVisibleRect ], owner: self, userInfo: nil )) @@ -538,7 +540,7 @@ public class PieChartView: NSView { private var segments: [circle_segment] = [] private var queue: DispatchQueue = DispatchQueue(label: "eu.exelban.Stats.charts.pie") - public init(frame: NSRect, segments: [circle_segment], filled: Bool = false, drawValue: Bool = false) { + public init(frame: NSRect = .zero, segments: [circle_segment] = [], filled: Bool = false, drawValue: Bool = false) { self.filled = filled self.drawValue = drawValue self.segments = segments @@ -817,10 +819,10 @@ internal class TachometerGraphView: NSView { } } -public class BarChartView: NSView { +public class ColumnChartView: NSView { private var values: [ColorValue] = [] private var cursor: CGPoint? = nil - private var queue: DispatchQueue = DispatchQueue(label: "eu.exelban.Stats.charts.bar") + private var queue: DispatchQueue = DispatchQueue(label: "eu.exelban.Stats.charts.column") public init(frame: NSRect = NSRect.zero, num: Int) { super.init(frame: frame) @@ -829,9 +831,10 @@ public class BarChartView: NSView { self.addTrackingArea(NSTrackingArea( rect: CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height), options: [ - NSTrackingArea.Options.activeAlways, - NSTrackingArea.Options.mouseEnteredAndExited, - NSTrackingArea.Options.mouseMoved + .activeAlways, + .mouseEnteredAndExited, + .mouseMoved, + .inVisibleRect ], owner: self, userInfo: nil )) @@ -936,6 +939,21 @@ public class BarChartView: NSView { self.cursor = nil self.display() } + + public override func updateTrackingAreas() { + self.trackingAreas.forEach({ self.removeTrackingArea($0) }) + self.addTrackingArea(NSTrackingArea( + rect: .zero, + options: [ + .activeAlways, + .mouseEnteredAndExited, + .mouseMoved, + .inVisibleRect + ], + owner: self, userInfo: nil + )) + super.updateTrackingAreas() + } } public class GridChartView: NSView { diff --git a/Modules/CPU/popup.swift b/Modules/CPU/popup.swift index 89ca6194..cc4d97f2 100644 --- a/Modules/CPU/popup.swift +++ b/Modules/CPU/popup.swift @@ -69,7 +69,7 @@ internal class Popup: PopupWrapper { private var sliderView: NSView? = nil private var lineChart: LineChartView? = nil - private var barChart: BarChartView? = nil + private var columnChart: ColumnChartView? = nil private var circle: PieChartView? = nil private var temperatureCircle: HalfCircleGraphView? = nil private var frequencyCircle: HalfCircleGraphView? = nil @@ -244,13 +244,13 @@ internal class Popup: PopupWrapper { box.layer?.backgroundColor = NSColor.lightGray.withAlphaComponent(0.1).cgColor box.layer?.cornerRadius = 3 - let chart = BarChartView(frame: NSRect( + let chart = ColumnChartView(frame: NSRect( x: Constants.Popup.spacing, y: Constants.Popup.spacing, width: view.frame.width - (Constants.Popup.spacing*2), height: box.frame.height - (Constants.Popup.spacing*2) ), num: Int(cores)) - self.barChart = chart + self.columnChart = chart box.addSubview(chart) @@ -396,7 +396,7 @@ internal class Popup: PopupWrapper { usagePerCore.append(ColorValue(value.usagePerCore[i], color: NSColor.systemBlue)) } } - self.barChart?.setValues(usagePerCore) + self.columnChart?.setValues(usagePerCore) self.initialized = true } diff --git a/Modules/CPU/portal.swift b/Modules/CPU/portal.swift index 0361d54d..837330dd 100644 --- a/Modules/CPU/portal.swift +++ b/Modules/CPU/portal.swift @@ -14,7 +14,7 @@ import Kit public class Portal: PortalWrapper { private var circle: PieChartView? = nil - private var barChart: BarChartView? = nil + private var columnChart: ColumnChartView? = nil private var initialized: Bool = false @@ -99,8 +99,8 @@ public class Portal: PortalWrapper { box.layer?.backgroundColor = NSColor.lightGray.withAlphaComponent(0.1).cgColor box.layer?.cornerRadius = 3 - let chart = BarChartView(num: Int(cores)) - self.barChart = chart + let chart = ColumnChartView(num: Int(cores)) + self.columnChart = chart box.addArrangedSubview(chart) return box @@ -163,7 +163,7 @@ public class Portal: PortalWrapper { usagePerCore.append(ColorValue(value.usagePerCore[i], color: NSColor.systemBlue)) } } - self.barChart?.setValues(usagePerCore) + self.columnChart?.setValues(usagePerCore) self.initialized = true }