Skip to content

Commit

Permalink
Make preferences resize more correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmichel committed Dec 18, 2016
1 parent 2c70f0a commit 3c76f96
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Juice/Classes/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,24 @@ final class PreferencesWindowController: NSWindowController, NSToolbarDelegate {
}
set {
guard let window = window,
let value = newValue else {
let contentView = window.contentView,
let value = newValue,
let newView = newValue?.view else {
super.contentViewController = newValue
return
}

let preferredOrigin = window.frame.origin
let heightDelta = newView.frame.height - contentView.frame.height

value.preferredScreenOrigin = window.frame.origin
super.contentViewController = value
window.setFrameOrigin(value.preferredScreenOrigin)

var windowFrame = window.frame
windowFrame.size = NSSize(width: windowFrame.size.width, height: windowFrame.size.height + heightDelta)
windowFrame.origin = NSPoint(x: preferredOrigin.x, y: preferredOrigin.y - heightDelta)

window.setFrameOrigin(windowFrame.origin)
}
}

Expand All @@ -48,6 +58,9 @@ final class PreferencesWindowController: NSWindowController, NSToolbarDelegate {
override func windowDidLoad() {
super.windowDidLoad()
window?.level = Int(CGWindowLevelForKey(.floatingWindow))

toolbar.selectedItemIdentifier = Identifiers.General
generalToolbarItemClicked()
}

func customToolbarItem(itemForItemIdentifier itemIdentifier: String, label: String, paletteLabel: String, toolTip: String, target: AnyObject, itemContent: NSImage?, action: Selector?, menu: NSMenu?) -> NSToolbarItem? {
Expand Down

0 comments on commit 3c76f96

Please sign in to comment.