fix: adjusted sensors portal width per row (#1819)

This commit is contained in:
Serhiy Mytrovtsiy
2024-02-20 20:12:20 +01:00
parent 90ef1b1818
commit 82fd30668e
2 changed files with 8 additions and 1 deletions

View File

@@ -484,6 +484,10 @@ public class ScrollableStackView: NSView {
private let clipView: NSClipView = NSClipView()
private let scrollView: NSScrollView = NSScrollView()
public var scrollWidth: CGFloat? {
self.scrollView.verticalScroller?.frame.size.width
}
public init(frame: NSRect = NSRect.zero, orientation: NSUserInterfaceLayoutOrientation = .vertical) {
super.init(frame: frame)

View File

@@ -71,7 +71,10 @@ public class Portal: NSStackView, Portal_p {
self.list = [:]
}
let width: CGFloat = self.frame.width - self.edgeInsets.left - self.edgeInsets.right - Constants.Popup.margins
var width: CGFloat = self.frame.width - self.edgeInsets.left - self.edgeInsets.right
if list.count >= 4 {
width -= self.container.scrollWidth ?? Constants.Popup.margins
}
list.forEach { s in
let v = ValueSensorView(s, width: width, callback: {})
self.container.stackView.addArrangedSubview(v)