Keep the prefs window width constant between panes. Keep the top edge of the window constant.

This commit is contained in:
Brent Simmons 2019-01-26 22:01:38 -08:00
parent 7f731164a3
commit 8a0f65dd24
1 changed files with 5 additions and 5 deletions

View File

@ -29,6 +29,7 @@ private struct ToolbarItemIdentifier {
class PreferencesWindowController : NSWindowController, NSToolbarDelegate {
private let windowFrameName = "Preferences"
private let windowWidth = CGFloat(512.0) // Width is constant for all views; only the height changes
private var viewControllers = [String: NSViewController]()
private let toolbarItemSpecs: [PreferencesToolbarItemSpec] = {
var specs = [PreferencesToolbarItemSpec]()
@ -37,7 +38,6 @@ class PreferencesWindowController : NSWindowController, NSToolbarDelegate {
return specs
}()
override func windowDidLoad() {
let toolbar = NSToolbar(identifier: NSToolbar.Identifier("PreferencesToolbar"))
@ -165,22 +165,22 @@ private extension PreferencesWindowController {
}
func resizeWindow(toFitView view: NSView) {
let viewFrame = view.frame
let windowFrame = window!.frame
let contentViewFrame = window!.contentView!.frame
let deltaHeight = NSHeight(contentViewFrame) - NSHeight(viewFrame)
let heightForWindow = NSHeight(windowFrame) - deltaHeight
let windowOriginY = NSMinY(windowFrame)// + deltaHeight
let windowOriginY = NSMinY(windowFrame) + deltaHeight
var updatedWindowFrame = windowFrame
updatedWindowFrame.size.height = heightForWindow
updatedWindowFrame.origin.y = windowOriginY
updatedWindowFrame.size.width = NSWidth(viewFrame)
updatedWindowFrame.size.width = windowWidth //NSWidth(viewFrame)
var updatedViewFrame = viewFrame
updatedViewFrame.origin = NSZeroPoint
updatedViewFrame.size.width = windowWidth
if viewFrame != updatedViewFrame {
view.frame = updatedViewFrame
}