Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix the Stage view's horizontal split view

It will now remember it's position and the divider will keep its position relative to the bottom when the window resizes.
  • Loading branch information...
commit c545832108c2a95f97ac8173f7fd9894b45a20d8 1 parent b11d4f7
@brotherbard authored
View
2  PBGitCommitController.h
@@ -10,6 +10,7 @@
#import "PBViewController.h"
@class PBGitIndexController, PBIconAndTextCell, PBWebChangesController, PBGitIndex;
+@class PBNiceSplitView;
@interface PBGitCommitController : PBViewController {
// This might have to transfer over to the PBGitRepository
@@ -23,6 +24,7 @@
IBOutlet PBGitIndexController *indexController;
IBOutlet PBWebChangesController *webController;
+ IBOutlet PBNiceSplitView *commitSplitView;
}
@property(readonly) PBGitIndex *index;
View
83 PBGitCommitController.m
@@ -11,6 +11,10 @@
#import "PBChangedFile.h"
#import "PBWebChangesController.h"
#import "PBGitIndex.h"
+#import "PBNiceSplitView.h"
+
+
+#define kCommitSplitViewPositionDefault @"Commit SplitView Position"
@interface PBGitCommitController ()
- (void)refreshFinished:(NSNotification *)notification;
@@ -22,6 +26,7 @@ - (void)commitHookFailed:(NSNotification *)notification;
- (void)amendCommit:(NSNotification *)notification;
- (void)indexChanged:(NSNotification *)notification;
- (void)indexOperationFailed:(NSNotification *)notification;
+- (void)saveCommitSplitViewPosition;
@end
@implementation PBGitCommitController
@@ -65,10 +70,14 @@ - (void)awakeFromNib
[cachedFilesController setAutomaticallyRearrangesObjects:NO];
[unstagedFilesController setAutomaticallyRearrangesObjects:NO];
+
+ [commitSplitView setHidden:YES];
+ [self performSelector:@selector(restoreCommitSplitViewPositiion) withObject:nil afterDelay:0];
}
- (void)closeView
{
+ [self saveCommitSplitViewPosition];
[webController closeView];
}
@@ -211,4 +220,78 @@ - (void)indexOperationFailed:(NSNotification *)notification
[[repository windowController] showMessageSheet:@"Index operation failed" infoText:[[notification userInfo] objectForKey:@"description"]];
}
+
+#pragma mark NSSplitView delegate methods
+
+#define kCommitSplitViewTopViewMin 150
+#define kCommitSplitViewBottomViewMin 100
+
+- (CGFloat)splitView:(NSSplitView *)splitView constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex
+{
+ if (splitView == commitSplitView)
+ return kCommitSplitViewTopViewMin;
+
+ return proposedMin;
+}
+
+- (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex
+{
+ if (splitView == commitSplitView)
+ return [splitView frame].size.height - [splitView dividerThickness] - kCommitSplitViewBottomViewMin;
+
+ return proposedMax;
+}
+
+// while the user resizes the window keep the lower (changes/message) view constant and just resize the upper view
+// unless the upper view gets too small
+- (void)resizeCommitSplitView
+{
+ NSRect newFrame = [commitSplitView frame];
+
+ float dividerThickness = [commitSplitView dividerThickness];
+
+ NSView *upperView = [[commitSplitView subviews] objectAtIndex:0];
+ NSRect upperFrame = [upperView frame];
+ upperFrame.size.width = newFrame.size.width;
+
+ NSView *lowerView = [[commitSplitView subviews] objectAtIndex:1];
+ NSRect lowerFrame = [lowerView frame];
+ lowerFrame.size.width = newFrame.size.width;
+
+ upperFrame.size.height = newFrame.size.height - lowerFrame.size.height - dividerThickness;
+ if (upperFrame.size.height < kCommitSplitViewTopViewMin)
+ upperFrame.size.height = kCommitSplitViewTopViewMin;
+
+ lowerFrame.size.height = newFrame.size.height - upperFrame.size.height - dividerThickness;
+ lowerFrame.origin.y = newFrame.size.height - lowerFrame.size.height;
+
+ [upperView setFrame:upperFrame];
+ [lowerView setFrame:lowerFrame];
+}
+
+- (void)splitView:(NSSplitView *)splitView resizeSubviewsWithOldSize:(NSSize)oldSize
+{
+ if (splitView == commitSplitView)
+ [self resizeCommitSplitView];
+}
+
+// NSSplitView does not save and restore the position of the splitView correctly so do it manually
+- (void)saveCommitSplitViewPosition
+{
+ float position = [[[commitSplitView subviews] objectAtIndex:0] frame].size.height;
+ [[NSUserDefaults standardUserDefaults] setFloat:position forKey:kCommitSplitViewPositionDefault];
+ [[NSUserDefaults standardUserDefaults] synchronize];
+}
+
+// make sure this happens after awakeFromNib
+- (void)restoreCommitSplitViewPositiion
+{
+ float position = [[NSUserDefaults standardUserDefaults] floatForKey:kCommitSplitViewPositionDefault];
+ if (position < 1.0)
+ position = [commitSplitView frame].size.height - 225;
+
+ [commitSplitView setPosition:position ofDividerAtIndex:0];
+ [commitSplitView setHidden:NO];
+}
+
@end
View
324 PBGitCommitView.xib
@@ -2,10 +2,10 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">10C540</string>
- <string key="IBDocument.InterfaceBuilderVersion">762</string>
- <string key="IBDocument.AppKitVersion">1038.25</string>
- <string key="IBDocument.HIToolboxVersion">458.00</string>
+ <string key="IBDocument.SystemVersion">10H574</string>
+ <string key="IBDocument.InterfaceBuilderVersion">804</string>
+ <string key="IBDocument.AppKitVersion">1038.35</string>
+ <string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
@@ -15,8 +15,8 @@
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
- <string>762</string>
- <string>762</string>
+ <string>804</string>
+ <string>804</string>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
@@ -365,7 +365,7 @@
<string>public.url</string>
</object>
</object>
- <string key="NSFrameSize">{427, 41}</string>
+ <string key="NSFrame">{{0, 27}, {427, 14}}</string>
<reference key="NSSuperview" ref="245211955"/>
<object class="NSTextContainer" key="NSTextContainer" id="311869542">
<object class="NSLayoutManager" key="NSLayoutManager">
@@ -696,7 +696,6 @@
</object>
<string key="NSFrameSize">{852, 432}</string>
<reference key="NSSuperview" ref="750704519"/>
- <string key="NSAutosaveName">CommitViewSplitView</string>
</object>
</object>
<string key="NSFrameSize">{852, 432}</string>
@@ -1031,6 +1030,22 @@
</object>
<int key="connectionID">307</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="812432808"/>
+ <reference key="destination" ref="1001"/>
+ </object>
+ <int key="connectionID">313</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">commitSplitView</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="812432808"/>
+ </object>
+ <int key="connectionID">314</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -1419,12 +1434,19 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">311</int>
+ <int key="maxID">314</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
+ <string key="className">NSApplication</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">NSApplication+GitXScripting.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">PBCommitMessageView</string>
<string key="superclassName">NSTextView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -1448,6 +1470,7 @@
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>commit:</string>
+ <string>forceCommit:</string>
<string>refresh:</string>
<string>signOff:</string>
</object>
@@ -1456,6 +1479,36 @@
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="actionInfosByName">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>commit:</string>
+ <string>forceCommit:</string>
+ <string>refresh:</string>
+ <string>signOff:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBActionInfo">
+ <string key="name">commit:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">forceCommit:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">refresh:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">signOff:</string>
+ <string key="candidateClassName">id</string>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
@@ -1465,6 +1518,7 @@
<string>cachedFilesController</string>
<string>commitButton</string>
<string>commitMessageView</string>
+ <string>commitSplitView</string>
<string>indexController</string>
<string>unstagedFilesController</string>
<string>webController</string>
@@ -1474,11 +1528,56 @@
<string>NSArrayController</string>
<string>NSButton</string>
<string>NSTextView</string>
+ <string>PBNiceSplitView</string>
<string>PBGitIndexController</string>
<string>NSArrayController</string>
<string>PBWebChangesController</string>
</object>
</object>
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>cachedFilesController</string>
+ <string>commitButton</string>
+ <string>commitMessageView</string>
+ <string>commitSplitView</string>
+ <string>indexController</string>
+ <string>unstagedFilesController</string>
+ <string>webController</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBToOneOutletInfo">
+ <string key="name">cachedFilesController</string>
+ <string key="candidateClassName">NSArrayController</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">commitButton</string>
+ <string key="candidateClassName">NSButton</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">commitMessageView</string>
+ <string key="candidateClassName">NSTextView</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">commitSplitView</string>
+ <string key="candidateClassName">PBNiceSplitView</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">indexController</string>
+ <string key="candidateClassName">PBGitIndexController</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">unstagedFilesController</string>
+ <string key="candidateClassName">NSArrayController</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">webController</string>
+ <string key="candidateClassName">PBWebChangesController</string>
+ </object>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">PBGitCommitController.h</string>
@@ -1500,6 +1599,25 @@
<string>NSTableView</string>
</object>
</object>
+ <object class="NSMutableDictionary" key="actionInfosByName">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>rowClicked:</string>
+ <string>tableClicked:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBActionInfo">
+ <string key="name">rowClicked:</string>
+ <string key="candidateClassName">NSCell</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">tableClicked:</string>
+ <string key="candidateClassName">NSTableView</string>
+ </object>
+ </object>
+ </object>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
@@ -1519,6 +1637,40 @@
<string>NSTableView</string>
</object>
</object>
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>commitController</string>
+ <string>stagedFilesController</string>
+ <string>stagedTable</string>
+ <string>unstagedFilesController</string>
+ <string>unstagedTable</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBToOneOutletInfo">
+ <string key="name">commitController</string>
+ <string key="candidateClassName">PBGitCommitController</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">stagedFilesController</string>
+ <string key="candidateClassName">NSArrayController</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">stagedTable</string>
+ <string key="candidateClassName">NSTableView</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">unstagedFilesController</string>
+ <string key="candidateClassName">NSArrayController</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">unstagedTable</string>
+ <string key="candidateClassName">NSTableView</string>
+ </object>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">PBGitIndexController.h</string>
@@ -1547,6 +1699,13 @@
<string key="NS.key.0">refresh:</string>
<string key="NS.object.0">id</string>
</object>
+ <object class="NSMutableDictionary" key="actionInfosByName">
+ <string key="NS.key.0">refresh:</string>
+ <object class="IBActionInfo" key="NS.object.0">
+ <string key="name">refresh:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">PBViewController.h</string>
@@ -1572,6 +1731,35 @@
<string>NSArrayController</string>
</object>
</object>
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>cachedFilesController</string>
+ <string>controller</string>
+ <string>indexController</string>
+ <string>unstagedFilesController</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBToOneOutletInfo">
+ <string key="name">cachedFilesController</string>
+ <string key="candidateClassName">NSArrayController</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">controller</string>
+ <string key="candidateClassName">PBGitCommitController</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">indexController</string>
+ <string key="candidateClassName">PBGitIndexController</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">unstagedFilesController</string>
+ <string key="candidateClassName">NSArrayController</string>
+ </object>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">PBWebChangesController.h</string>
@@ -1593,6 +1781,25 @@
<string>WebView</string>
</object>
</object>
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>repository</string>
+ <string>view</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBToOneOutletInfo">
+ <string key="name">repository</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBToOneOutletInfo">
+ <string key="name">view</string>
+ <string key="candidateClassName">WebView</string>
+ </object>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">PBWebController.h</string>
@@ -1980,6 +2187,34 @@
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">QuartzCore.framework/Headers/CAAnimation.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">QuartzCore.framework/Headers/CALayer.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">QuartzCore.framework/Headers/CIImageProvider.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
+ <string key="minorKey">ScriptingBridge.framework/Headers/SBApplication.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
+ <string key="className">NSObject</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Sparkle.framework/Headers/SUAppcast.h</string>
</object>
</object>
@@ -2185,6 +2420,13 @@
<string key="NS.key.0">view</string>
<string key="NS.object.0">NSView</string>
</object>
+ <object class="NSMutableDictionary" key="toOneOutletInfosByName">
+ <string key="NS.key.0">view</string>
+ <object class="IBToOneOutletInfo" key="NS.object.0">
+ <string key="name">view</string>
+ <string key="candidateClassName">NSView</string>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSViewController.h</string>
@@ -2224,6 +2466,70 @@
<string>id</string>
</object>
</object>
+ <object class="NSMutableDictionary" key="actionInfosByName">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>goBack:</string>
+ <string>goForward:</string>
+ <string>makeTextLarger:</string>
+ <string>makeTextSmaller:</string>
+ <string>makeTextStandardSize:</string>
+ <string>reload:</string>
+ <string>reloadFromOrigin:</string>
+ <string>stopLoading:</string>
+ <string>takeStringURLFrom:</string>
+ <string>toggleContinuousSpellChecking:</string>
+ <string>toggleSmartInsertDelete:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBActionInfo">
+ <string key="name">goBack:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">goForward:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">makeTextLarger:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">makeTextSmaller:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">makeTextStandardSize:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">reload:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">reloadFromOrigin:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">stopLoading:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">takeStringURLFrom:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">toggleContinuousSpellChecking:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ <object class="IBActionInfo">
+ <string key="name">toggleSmartInsertDelete:</string>
+ <string key="candidateClassName">id</string>
+ </object>
+ </object>
+ </object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">WebKit.framework/Headers/WebView.h</string>
Please sign in to comment.
Something went wrong with that request. Please try again.