fix: fixed bug with line chart offset in the menu bar (#1894)

This commit is contained in:
Serhiy Mytrovtsiy
2024-04-15 19:14:10 +02:00
parent 7b62a063e9
commit b016113447
2 changed files with 9 additions and 3 deletions

View File

@@ -198,7 +198,7 @@ public class LineChartView: NSView {
}
let point = CGPoint(
x: (CGFloat(i) * xRatio),
x: (CGFloat(i) * xRatio) + dirtyRect.origin.x,
y: y
)
line.append(point)
@@ -390,7 +390,7 @@ public class NetworkChartView: NSView {
private var inChart: LineChartView
private var outChart: LineChartView
public init(frame: NSRect, num: Int, minMax: Bool = true, reversedOrder: Bool = false,
public init(frame: NSRect, num: Int, minMax: Bool = true, reversedOrder: Bool = false,
outColor: NSColor = .systemRed, inColor: NSColor = .systemBlue, scale: Scale = .none, fixedScale: Double = 1) {
self.reversedOrder = reversedOrder

View File

@@ -58,6 +58,10 @@ public class Portal: PortalWrapper {
right: Constants.Popup.spacing*2
)
let container: NSView = NSView(frame: CGRect(x: 0, y: 0, width: self.frame.width - (Constants.Popup.spacing*8), height: 68))
container.wantsLayer = true
container.layer?.cornerRadius = 3
let chart = NetworkChartView(
frame: CGRect(x: 0, y: 0, width: self.frame.width - (Constants.Popup.spacing*8), height: 68),
num: 120,
@@ -66,8 +70,10 @@ public class Portal: PortalWrapper {
inColor: self.downloadColor,
scale: self.chartScale
)
chart.base = self.base
container.addSubview(chart)
self.chart = chart
view.addArrangedSubview(chart)
view.addArrangedSubview(container)
self.publicIPField = portalRow(view, title: "\(localizedString("Public IP")):", value: localizedString("Unknown"))
view.subviews.last?.heightAnchor.constraint(equalToConstant: 16).isActive = true