fix: dashboard and app settings scroll position when init

fix: adjust dashboard and app settings height
This commit is contained in:
Serhiy Mytrovtsiy
2020-12-26 13:46:45 +01:00
parent ec4fc1e2ec
commit 71a4de8148
3 changed files with 23 additions and 17 deletions

View File

@@ -71,7 +71,9 @@ class ApplicationSettings: NSScrollView {
grid.row(at: 2).height = settingsView.frame.height
self.documentView = grid
self.scroll(NSPoint(x: 0, y: grid.frame.size.height))
if let documentView = self.documentView {
documentView.scroll(NSPoint(x: 0, y: documentView.bounds.size.height))
}
}
required public init?(coder: NSCoder) {
@@ -147,11 +149,13 @@ class ApplicationSettings: NSScrollView {
view.addSubview(grid)
var height: CGFloat = grid.rowSpacing*2
var height: CGFloat = (CGFloat(grid.numberOfRows)-2) * grid.rowSpacing
for i in 0..<grid.numberOfRows {
let row = grid.row(at: i)
for a in 0..<row.numberOfCells {
height += row.cell(at: a).contentView?.frame.height ?? 0
if let contentView = row.cell(at: a).contentView {
height += contentView.frame.height
}
}
}
view.setFrameSize(NSSize(width: view.frame.width, height: max(200, height)))

View File

@@ -56,7 +56,9 @@ class Dashboard: NSScrollView {
grid.row(at: 2).height = specsView.frame.height
self.documentView = grid
self.scroll(NSPoint(x: 0, y: grid.frame.size.height))
if let documentView = self.documentView {
documentView.scroll(NSPoint(x: 0, y: documentView.bounds.size.height))
}
NotificationCenter.default.addObserver(self, selector: #selector(windowOpens), name: .openModuleSettings, object: nil)
}
@@ -129,11 +131,13 @@ class Dashboard: NSScrollView {
view.addSubview(grid)
var height: CGFloat = grid.rowSpacing*2
var height: CGFloat = (CGFloat(grid.numberOfRows)-2) * grid.rowSpacing
for i in 0..<grid.numberOfRows {
let row = grid.row(at: i)
for a in 0..<row.numberOfCells {
height += row.cell(at: a).contentView?.frame.height ?? 0
if let contentView = row.cell(at: a).contentView {
height += contentView.frame.height
}
}
}
view.setFrameSize(NSSize(width: view.frame.width, height: height))
@@ -256,20 +260,18 @@ class Dashboard: NSScrollView {
}
private func gpu() -> [NSView] {
let gpus = SystemKit.shared.device.info.gpu
var gpu: String = LocalizedString("Unknown")
if gpus != nil {
if gpus?.count == 1 {
gpu = gpus![0].name
} else {
gpu = ""
gpus!.forEach{ gpu += "\($0.name)\n" }
var value = ""
if let gpus = SystemKit.shared.device.info.gpu {
for i in 0..<gpus.count {
value += "\(gpus[i].name)\(i == gpus.count-1 ? "" : "\n")"
}
} else {
value = LocalizedString("Unknown")
}
return [
self.titleView("\(LocalizedString("Graphics")):"),
self.valueView(gpu),
self.valueView(value),
]
}

View File

@@ -34,8 +34,8 @@ class SettingsWindow: NSWindow, NSWindowDelegate {
self.collectionBehavior = .moveToActiveSpace
self.titlebarAppearsTransparent = true
self.appearance = NSAppearance(named: .darkAqua)
self.center()
self.setIsVisible(false)
// self.center()
self.setIsVisible(true)
let windowController = NSWindowController()
windowController.window = self