From 537a66d6aa0d5e00e66f3d0e62ac2fbbf1226050 Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Fri, 8 Mar 2019 17:43:43 -0500 Subject: [PATCH] Add album art preferences pane --- .../PreferencesViewController.swift | 70 ++++++----- .../Resources/Base.lproj/Main.storyboard | 115 +++++++++++++++--- 2 files changed, 135 insertions(+), 50 deletions(-) diff --git a/Persephone/Preferences/Controllers/PreferencesViewController.swift b/Persephone/Preferences/Controllers/PreferencesViewController.swift index 566917a..a8b3fcd 100644 --- a/Persephone/Preferences/Controllers/PreferencesViewController.swift +++ b/Persephone/Preferences/Controllers/PreferencesViewController.swift @@ -9,7 +9,6 @@ import Cocoa class PreferencesViewController: NSTabViewController { - private lazy var tabViewSizes: [String : NSSize] = [:] override func viewDidLoad() { @@ -20,39 +19,38 @@ class PreferencesViewController: NSTabViewController { super.viewDidLoad() } - override func transition(from fromViewController: NSViewController, to toViewController: NSViewController, options: NSViewController.TransitionOptions, completionHandler completion: (() -> Void)?) { - - NSAnimationContext.runAnimationGroup({ context in - context.duration = 0.5 - self.updateWindowFrameAnimated(viewController: toViewController) - super.transition( - from: fromViewController, - to: toViewController, - options: [.crossfade, .allowUserInteraction], - completionHandler: completion - ) - }, completionHandler: nil) - } - - func updateWindowFrameAnimated(viewController: NSViewController) { - guard let title = viewController.title, let window = view.window - else { return } - - let contentSize: NSSize - - if tabViewSizes.keys.contains(title) { - contentSize = tabViewSizes[title]! - } else { - contentSize = viewController.view.frame.size - tabViewSizes[title] = contentSize - } - - let newWindowSize = window.frameRect(forContentRect: NSRect(origin: NSPoint.zero, size: contentSize)).size - - var frame = window.frame - frame.origin.y += frame.height - frame.origin.y -= newWindowSize.height - frame.size = newWindowSize - window.animator().setFrame(frame, display: false) - } +// override func transition(from fromViewController: NSViewController, to toViewController: NSViewController, options: NSViewController.TransitionOptions, completionHandler completion: (() -> Void)?) { +// NSAnimationContext.runAnimationGroup({ context in +// context.duration = 0.5 +// self.updateWindowFrameAnimated(viewController: toViewController) +// super.transition( +// from: fromViewController, +// to: toViewController, +// options: [.crossfade, .allowUserInteraction], +// completionHandler: completion +// ) +// }, completionHandler: nil) +// } +// +// func updateWindowFrameAnimated(viewController: NSViewController) { +// guard let title = viewController.title, let window = view.window +// else { return } +// +// let contentSize: NSSize +// +// if tabViewSizes.keys.contains(title) { +// contentSize = tabViewSizes[title]! +// } else { +// contentSize = viewController.view.frame.size +// tabViewSizes[title] = contentSize +// } +// +// let newWindowSize = window.frameRect(forContentRect: NSRect(origin: NSPoint.zero, size: contentSize)).size +// +// var frame = window.frame +// frame.origin.y += frame.height +// frame.origin.y -= newWindowSize.height +// frame.size = newWindowSize +// window.animator().setFrame(frame, display: false) +// } } diff --git a/Persephone/Resources/Base.lproj/Main.storyboard b/Persephone/Resources/Base.lproj/Main.storyboard index 89f45ee..29d5bd5 100644 --- a/Persephone/Resources/Base.lproj/Main.storyboard +++ b/Persephone/Resources/Base.lproj/Main.storyboard @@ -259,24 +259,94 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - @@ -286,9 +356,11 @@ - + - + + + @@ -302,18 +374,19 @@ - + - + + + - + - @@ -321,6 +394,18 @@ + + + + + + + + + + + + @@ -329,7 +414,7 @@ - + @@ -488,7 +573,7 @@ - + @@ -543,6 +628,8 @@ + +