Skip to content

Commit

Permalink
Merge pull request #164 from czechboy0/hd/window_positioning
Browse files Browse the repository at this point in the history
fixed new window positioning
  • Loading branch information
czechboy0 committed Oct 13, 2015
2 parents 1340b87 + b3a7cd2 commit a8c2f6b
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 12 deletions.
4 changes: 4 additions & 0 deletions Buildasaur.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 = "<group>"; };
3A9D74251BCC19BB00DCA23C /* Buildasaur-format-2-example1 */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "Buildasaur-format-2-example1"; path = "Migration/Buildasaur-format-2-example1"; sourceTree = "<group>"; };
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 = "<group>"; };
3AAA1B651AAB6E9800FA1598 /* SeparatorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SeparatorView.swift; sourceTree = "<group>"; };
3AAA1B671AAB722600FA1598 /* ProjectViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProjectViewController.swift; sourceTree = "<group>"; };
3AAA1B751AAC504700FA1598 /* XcodeServerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XcodeServerViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -441,6 +443,7 @@
children = (
3AC7D5E01BBC231400786198 /* StoryboardLoadingUtils.swift */,
3A0FF59F1BBFDA7E00FB8051 /* RACUIExtensions.swift */,
3AA573051BCD70FC00172D3E /* URLUtils.swift */,
);
name = Utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down
14 changes: 14 additions & 0 deletions Buildasaur/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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") }
Expand Down
18 changes: 16 additions & 2 deletions Buildasaur/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@
</tableHeaderView>
</scrollView>
<stackView distribution="fill" orientation="horizontal" alignment="centerY" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="l5l-vU-g4x">
<rect key="frame" x="262" y="259" width="418" height="21"/>
<rect key="frame" x="222" y="259" width="458" height="21"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="E55-J5-dz5">
<rect key="frame" x="-6" y="-7" width="115" height="32"/>
Expand Down Expand Up @@ -937,7 +937,7 @@
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="Z79-7V-Vm9">
<rect key="frame" x="194" y="1" width="141" height="18"/>
<rect key="frame" x="194" y="1.5" width="141" height="18"/>
<animations/>
<buttonCell key="cell" type="check" title="Autostart on launch" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="Ckv-ih-HFt">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand All @@ -959,19 +959,32 @@
<action selector="stopAllButtonClicked:" target="fGl-D9-6Tw" id="pHR-m2-BVt"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="x6z-V9-yJw">
<rect key="frame" x="426" y="0.0" width="32" height="21"/>
<animations/>
<buttonCell key="cell" type="bevel" bezelStyle="rounded" image="NSInfo" imagePosition="only" alignment="center" imageScaling="proportionallyDown" inset="2" id="yzS-7U-OPv">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="infoButtonClicked:" target="fGl-D9-6Tw" id="gLi-hz-y9i"/>
</connections>
</button>
</subviews>
<animations/>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
Expand Down Expand Up @@ -3545,6 +3558,7 @@ Gw
</scene>
</scenes>
<resources>
<image name="NSInfo" width="32" height="32"/>
<image name="NSStatusNone" width="16" height="16"/>
<image name="NSTrashEmpty" width="32" height="32"/>
</resources>
Expand Down
4 changes: 4 additions & 0 deletions Buildasaur/DashboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 11 additions & 1 deletion Buildasaur/MainEditorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
11 changes: 2 additions & 9 deletions Buildasaur/SyncerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand Down
16 changes: 16 additions & 0 deletions Buildasaur/URLUtils.swift
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit a8c2f6b

Please sign in to comment.