From b3a7cd2cded92411d9171bdc5a9dff03929bee45 Mon Sep 17 00:00:00 2001 From: Honza Dvorsky Date: Tue, 13 Oct 2015 18:17:37 +0100 Subject: [PATCH] fixed new window positioning --- Buildasaur.xcodeproj/project.pbxproj | 4 ++++ Buildasaur/AppDelegate.swift | 14 ++++++++++++++ Buildasaur/Base.lproj/Main.storyboard | 18 ++++++++++++++++-- Buildasaur/DashboardViewController.swift | 4 ++++ Buildasaur/MainEditorViewController.swift | 12 +++++++++++- Buildasaur/SyncerViewController.swift | 11 ++--------- Buildasaur/URLUtils.swift | 16 ++++++++++++++++ 7 files changed, 67 insertions(+), 12 deletions(-) create mode 100644 Buildasaur/URLUtils.swift diff --git a/Buildasaur.xcodeproj/project.pbxproj b/Buildasaur.xcodeproj/project.pbxproj index 3556433..84099a2 100644 --- a/Buildasaur.xcodeproj/project.pbxproj +++ b/Buildasaur.xcodeproj/project.pbxproj @@ -56,6 +56,7 @@ 3A9D74221BCC041600DCA23C /* Buildasaur-format-0-example1 in Resources */ = {isa = PBXBuildFile; fileRef = 3A9D74211BCC041600DCA23C /* Buildasaur-format-0-example1 */; settings = {ASSET_TAGS = (); }; }; 3A9D74241BCC103E00DCA23C /* Buildasaur-format-1-example1 in Resources */ = {isa = PBXBuildFile; fileRef = 3A9D74231BCC103E00DCA23C /* Buildasaur-format-1-example1 */; settings = {ASSET_TAGS = (); }; }; 3A9D74261BCC19BB00DCA23C /* Buildasaur-format-2-example1 in Resources */ = {isa = PBXBuildFile; fileRef = 3A9D74251BCC19BB00DCA23C /* Buildasaur-format-2-example1 */; settings = {ASSET_TAGS = (); }; }; + 3AA573061BCD70FC00172D3E /* URLUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AA573051BCD70FC00172D3E /* URLUtils.swift */; settings = {ASSET_TAGS = (); }; }; 3AAA1B661AAB6E9800FA1598 /* SeparatorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AAA1B651AAB6E9800FA1598 /* SeparatorView.swift */; }; 3AAA1B681AAB722600FA1598 /* ProjectViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AAA1B671AAB722600FA1598 /* ProjectViewController.swift */; }; 3AAA1B761AAC504700FA1598 /* XcodeServerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AAA1B751AAC504700FA1598 /* XcodeServerViewController.swift */; }; @@ -275,6 +276,7 @@ 3A9D74231BCC103E00DCA23C /* Buildasaur-format-1-example1 */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "Buildasaur-format-1-example1"; path = "Migration/Buildasaur-format-1-example1"; sourceTree = ""; }; 3A9D74251BCC19BB00DCA23C /* Buildasaur-format-2-example1 */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "Buildasaur-format-2-example1"; path = "Migration/Buildasaur-format-2-example1"; sourceTree = ""; }; 3A9DEC7A1A3BDA6C008C8270 /* PullRequestBranch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PullRequestBranch.swift; path = BuildaGitServer/PullRequestBranch.swift; sourceTree = SOURCE_ROOT; }; + 3AA573051BCD70FC00172D3E /* URLUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URLUtils.swift; sourceTree = ""; }; 3AAA1B651AAB6E9800FA1598 /* SeparatorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SeparatorView.swift; sourceTree = ""; }; 3AAA1B671AAB722600FA1598 /* ProjectViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProjectViewController.swift; sourceTree = ""; }; 3AAA1B751AAC504700FA1598 /* XcodeServerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XcodeServerViewController.swift; sourceTree = ""; }; @@ -441,6 +443,7 @@ children = ( 3AC7D5E01BBC231400786198 /* StoryboardLoadingUtils.swift */, 3A0FF59F1BBFDA7E00FB8051 /* RACUIExtensions.swift */, + 3AA573051BCD70FC00172D3E /* URLUtils.swift */, ); name = Utils; sourceTree = ""; @@ -1371,6 +1374,7 @@ 3A9109C51BC2B0B200C2AECA /* MainEditor_ViewManipulation.swift in Sources */, 3AC7D5E11BBC231400786198 /* StoryboardLoadingUtils.swift in Sources */, 3AAA1B661AAB6E9800FA1598 /* SeparatorView.swift in Sources */, + 3AA573061BCD70FC00172D3E /* URLUtils.swift in Sources */, 3A9109C71BC2B67100C2AECA /* EditableViewController.swift in Sources */, 3AD338B01AAE31D500ECD0F2 /* BuildTemplateViewController.swift in Sources */, 3A9109C31BC2B05C00C2AECA /* MainEditor_EditeeDelegate.swift in Sources */, diff --git a/Buildasaur/AppDelegate.swift b/Buildasaur/AppDelegate.swift index 36bad7f..9e21115 100644 --- a/Buildasaur/AppDelegate.swift +++ b/Buildasaur/AppDelegate.swift @@ -180,6 +180,20 @@ extension AppDelegate: PresentableViewControllerDelegate { } else { newWindow = NSWindow(contentViewController: viewController) newWindow?.autorecalculatesKeyViewLoop = true + + //if we already are showing some windows, let's cascade the new one + if self.windows.count > 0 { + //find the right-most window and cascade from it + let rightMost = self.windows.reduce(CGPoint(x: 0.0, y: 0.0), combine: { (right: CGPoint, window: NSWindow) -> CGPoint in + let origin = window.frame.origin + if origin.x > right.x { + return origin + } + return right + }) + let newOrigin = newWindow!.cascadeTopLeftFromPoint(rightMost) + newWindow?.setFrameTopLeftPoint(newOrigin) + } } guard let window = newWindow else { fatalError("Unable to create window") } diff --git a/Buildasaur/Base.lproj/Main.storyboard b/Buildasaur/Base.lproj/Main.storyboard index dd353fb..c1974ff 100644 --- a/Buildasaur/Base.lproj/Main.storyboard +++ b/Buildasaur/Base.lproj/Main.storyboard @@ -906,7 +906,7 @@ - + + @@ -966,12 +977,14 @@ + + @@ -3545,6 +3558,7 @@ Gw + diff --git a/Buildasaur/DashboardViewController.swift b/Buildasaur/DashboardViewController.swift index f63b1d5..98d6efc 100644 --- a/Buildasaur/DashboardViewController.swift +++ b/Buildasaur/DashboardViewController.swift @@ -142,6 +142,10 @@ class DashboardViewController: PresentableViewController { let syncerViewModel = self.syncerViewModels.value[clickedRow] syncerViewModel.viewButtonClicked() } + + @IBAction func infoButtonClicked(sender: AnyObject) { + openLink("https://github.com/czechboy0/Buildasaur#buildasaur") + } } extension DashboardViewController { diff --git a/Buildasaur/MainEditorViewController.swift b/Buildasaur/MainEditorViewController.swift index 7cfc9b2..4753957 100644 --- a/Buildasaur/MainEditorViewController.swift +++ b/Buildasaur/MainEditorViewController.swift @@ -58,13 +58,23 @@ class MainEditorViewController: PresentableViewController { self.containerView.wantsLayer = true self.containerView.layer!.backgroundColor = NSColor.lightGrayColor().CGColor - + self.setupBindings() //HACK: hack for debugging - jump ahead // self.state.value = (.EditingSyncer, false) } + override func viewDidAppear() { + super.viewDidAppear() + + if let window = self.view.window { + let size = CGSize(width: 600, height: 422) + window.minSize = size + window.maxSize = size + } + } + // moving forward and back func previous(animated animated: Bool) { diff --git a/Buildasaur/SyncerViewController.swift b/Buildasaur/SyncerViewController.swift index eae3b9a..b0163c2 100644 --- a/Buildasaur/SyncerViewController.swift +++ b/Buildasaur/SyncerViewController.swift @@ -266,19 +266,12 @@ extension SyncerViewController { self.performSegueWithIdentifier("showManual", sender: self) } - private func openLink(link: String) { - - if let url = NSURL(string: link) { - NSWorkspace.sharedWorkspace().openURL(url) - } - } - @IBAction func helpLttmButtonTapped(sender: AnyObject) { - self.openLink("https://github.com/czechboy0/Buildasaur/blob/master/README.md#unlock-the-lttm-barrier") + openLink("https://github.com/czechboy0/Buildasaur/blob/master/README.md#unlock-the-lttm-barrier") } @IBAction func helpPostStatusCommentsButtonTapped(sender: AnyObject) { - self.openLink("https://github.com/czechboy0/Buildasaur/blob/master/README.md#envelope-posting-status-comments") + openLink("https://github.com/czechboy0/Buildasaur/blob/master/README.md#envelope-posting-status-comments") } override func prepareForSegue(segue: NSStoryboardSegue, sender: AnyObject?) { diff --git a/Buildasaur/URLUtils.swift b/Buildasaur/URLUtils.swift new file mode 100644 index 0000000..7963d68 --- /dev/null +++ b/Buildasaur/URLUtils.swift @@ -0,0 +1,16 @@ +// +// URLUtils.swift +// Buildasaur +// +// Created by Honza Dvorsky on 10/13/15. +// Copyright © 2015 Honza Dvorsky. All rights reserved. +// + +import Cocoa + +func openLink(link: String) { + + if let url = NSURL(string: link) { + NSWorkspace.sharedWorkspace().openURL(url) + } +}