Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add PBCollapsibleSplitView as subclass of PBNiceSplitView

This adds a subclass to PBNiceSplitView which has collapsible subviews
as well as an uncollapse-method. The initWithTopMin method is used to
set the minimum sizes for the subviews.

Signed-off-by: Johannes Gilger <heipei@hackvalue.de>
  • Loading branch information...
commit d669050551cf47ee351981bbeb84d793f97644a1 1 parent f146e9a
@heipei heipei authored Pieter de Bie committed
View
6 GitX.xcodeproj/project.pbxproj
@@ -44,6 +44,7 @@
93CB42C20EAB7B2200530609 /* PBGitDefaults.m in Sources */ = {isa = PBXBuildFile; fileRef = 93CB42C10EAB7B2200530609 /* PBGitDefaults.m */; };
93F7857F0EA3ABF100C1F443 /* PBCommitMessageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 93F7857E0EA3ABF100C1F443 /* PBCommitMessageView.m */; };
D26DC6450E782C9000C777B2 /* gitx.icns in Resources */ = {isa = PBXBuildFile; fileRef = D26DC6440E782C9000C777B2 /* gitx.icns */; };
+ EB2A734A0FEE3F09006601CF /* PBCollapsibleSplitView.m in Sources */ = {isa = PBXBuildFile; fileRef = EB2A73490FEE3F09006601CF /* PBCollapsibleSplitView.m */; };
F50A411F0EBB874C00208746 /* mainSplitterBar.tiff in Resources */ = {isa = PBXBuildFile; fileRef = F50A411D0EBB874C00208746 /* mainSplitterBar.tiff */; };
F50A41200EBB874C00208746 /* mainSplitterDimple.tiff in Resources */ = {isa = PBXBuildFile; fileRef = F50A411E0EBB874C00208746 /* mainSplitterDimple.tiff */; };
F50A41230EBB875D00208746 /* PBNiceSplitView.m in Sources */ = {isa = PBXBuildFile; fileRef = F50A41220EBB875D00208746 /* PBNiceSplitView.m */; };
@@ -190,6 +191,8 @@
93F7857E0EA3ABF100C1F443 /* PBCommitMessageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBCommitMessageView.m; sourceTree = "<group>"; };
93FCCBA80EA8AF450061B02B /* PBGitConfig.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitConfig.m; sourceTree = "<group>"; };
D26DC6440E782C9000C777B2 /* gitx.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = gitx.icns; sourceTree = "<group>"; };
+ EB2A73480FEE3F09006601CF /* PBCollapsibleSplitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBCollapsibleSplitView.h; sourceTree = "<group>"; };
+ EB2A73490FEE3F09006601CF /* PBCollapsibleSplitView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBCollapsibleSplitView.m; sourceTree = "<group>"; };
F50A411D0EBB874C00208746 /* mainSplitterBar.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = mainSplitterBar.tiff; path = Images/mainSplitterBar.tiff; sourceTree = "<group>"; };
F50A411E0EBB874C00208746 /* mainSplitterDimple.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = mainSplitterDimple.tiff; path = Images/mainSplitterDimple.tiff; sourceTree = "<group>"; };
F50A41210EBB875D00208746 /* PBNiceSplitView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBNiceSplitView.h; sourceTree = "<group>"; };
@@ -530,6 +533,8 @@
F56244080E9684B0002B6C44 /* PBUnsortableTableHeader.m */,
F50A41210EBB875D00208746 /* PBNiceSplitView.h */,
F50A41220EBB875D00208746 /* PBNiceSplitView.m */,
+ EB2A73480FEE3F09006601CF /* PBCollapsibleSplitView.h */,
+ EB2A73490FEE3F09006601CF /* PBCollapsibleSplitView.m */,
F5FC41F20EBCBD4300191D80 /* PBGitXProtocol.h */,
F5FC41F30EBCBD4300191D80 /* PBGitXProtocol.m */,
);
@@ -848,6 +853,7 @@
47DBDB670E94EE8B00671A1E /* PBPrefsWindowController.m in Sources */,
47DBDBCA0E95016F00671A1E /* PBNSURLPathUserDefaultsTransfomer.m in Sources */,
F562C8870FE1766C000EC528 /* NSString_RegEx.m in Sources */,
+ EB2A734A0FEE3F09006601CF /* PBCollapsibleSplitView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
23 PBCollapsibleSplitView.h
@@ -0,0 +1,23 @@
+//
+// PBCollapsibleSplitView.h
+// GitX
+//
+// Created by Johannes Gilger on 6/21/09.
+// Copyright 2009 Johannes Gilger. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import "PBNiceSplitView.h"
+
+@interface PBCollapsibleSplitView : PBNiceSplitView {
+ CGFloat topViewMin;
+ CGFloat bottomViewMin;
+}
+
+@property (readonly) CGFloat topViewMin;
+@property (readonly) CGFloat bottomViewMin;
+
+- (void)setTopMin:(CGFloat)topMin andBottomMin:(CGFloat)bottomMin;
+- (void)uncollapse;
+
+@end
View
28 PBCollapsibleSplitView.m
@@ -0,0 +1,28 @@
+//
+// PBCollapsibleSplitView.m
+// GitX
+//
+// Created by Johannes Gilger on 6/21/09.
+// Copyright 2009 Johannes Gilger. All rights reserved.
+//
+
+#import "PBCollapsibleSplitView.h"
+
+@implementation PBCollapsibleSplitView
+@synthesize topViewMin, bottomViewMin;
+
+- (void)setTopMin:(CGFloat)topMin andBottomMin:(CGFloat)bottomMin {
+ topViewMin = topMin;
+ bottomViewMin = bottomMin;
+}
+
+- (void)uncollapse {
+ for (NSView *subview in [self subviews]) {
+ if([self isSubviewCollapsed:subview]) {
+ [self setPosition:[self frame].size.height / 3 ofDividerAtIndex:0];
+ [self adjustSubviews];
+ }
+ }
+}
+
+@end
View
8 PBGitHistoryController.h
@@ -10,6 +10,7 @@
#import "PBGitCommit.h"
#import "PBGitTree.h"
#import "PBViewController.h"
+#import "PBCollapsibleSplitView.h"
@interface PBGitHistoryController : PBViewController {
IBOutlet NSSearchField *searchField;
@@ -17,6 +18,7 @@
IBOutlet NSTreeController* treeController;
IBOutlet NSOutlineView* fileBrowser;
IBOutlet NSTableView* commitList;
+ IBOutlet PBCollapsibleSplitView *historySplitView;
IBOutlet id webView;
int selectedTab;
@@ -54,4 +56,10 @@
- (BOOL) hasNonlinearPath;
- (NSMenu *)tableColumnMenu;
+
+- (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview;
+- (BOOL)splitView:(NSSplitView *)splitView shouldCollapseSubview:(NSView *)subview forDoubleClickOnDividerAtIndex:(NSInteger)dividerIndex;
+- (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)offset;
+- (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)offset;
+
@end
View
26 PBGitHistoryController.m
@@ -41,6 +41,8 @@ - (void)awakeFromNib
[[commitList tableColumnWithIdentifier:@"subject"] setSortDescriptorPrototype:[[NSSortDescriptor alloc] initWithKey:@"subject" ascending:YES]];
// Add a menu that allows a user to select which columns to view
[[commitList headerView] setMenu:[self tableColumnMenu]];
+ [historySplitView setTopMin:33.0 andBottomMin:100.0];
+ [historySplitView uncollapse];
[super awakeFromNib];
}
@@ -296,4 +298,28 @@ - (NSArray *)menuItemsForPaths:(NSArray *)paths
return menuItems;
}
+- (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview {
+ return TRUE;
+}
+
+- (BOOL)splitView:(NSSplitView *)splitView shouldCollapseSubview:(NSView *)subview forDoubleClickOnDividerAtIndex:(NSInteger)dividerIndex {
+ int index = [[splitView subviews] indexOfObject:subview];
+ // this method (and canCollapse) are called by the splitView to decide how to collapse on double-click
+ // we compare our two subviews, so that always the smaller one is collapsed.
+ if([[[splitView subviews] objectAtIndex:index] frame].size.height < [[[splitView subviews] objectAtIndex:((index+1)%2)] frame].size.height) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+- (CGFloat)splitView:(NSSplitView *)sender constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)offset {
+ return proposedMin + historySplitView.topViewMin;
+}
+
+- (CGFloat)splitView:(NSSplitView *)sender constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)offset {
+ if(offset = 1)
+ return proposedMax - historySplitView.bottomViewMin;
+ return [sender frame].size.height;
+}
+
@end
View
26 PBGitHistoryView.xib
@@ -8,8 +8,8 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <integer value="46"/>
<integer value="237"/>
- <integer value="2"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -420,7 +420,7 @@
<object class="NSTextView" id="239018083">
<reference key="NSNextResponder" ref="948090592"/>
<int key="NSvFlags">2322</int>
- <string key="NSFrameSize">{835, 70}</string>
+ <string key="NSFrameSize">{835, 0}</string>
<reference key="NSSuperview" ref="948090592"/>
<object class="NSTextContainer" key="NSTextContainer" id="53511606">
<object class="NSLayoutManager" key="NSLayoutManager">
@@ -784,7 +784,7 @@
<object class="NSTextView" id="75600241">
<reference key="NSNextResponder" ref="321980917"/>
<int key="NSvFlags">2322</int>
- <string key="NSFrameSize">{543, 112}</string>
+ <string key="NSFrameSize">{543, 0}</string>
<reference key="NSSuperview" ref="321980917"/>
<object class="NSTextContainer" key="NSTextContainer" id="480935218">
<object class="NSLayoutManager" key="NSLayoutManager">
@@ -2093,6 +2093,14 @@
</object>
<int key="connectionID">274</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">historySplitView</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="202620420"/>
+ </object>
+ <int key="connectionID">275</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -2859,7 +2867,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>PBNiceSplitView</string>
+ <string>PBCollapsibleSplitView</string>
<string>{{312, 577}, {852, 384}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
@@ -2994,6 +3002,14 @@
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
+ <string key="className">PBCollapsibleSplitView</string>
+ <string key="superclassName">PBNiceSplitView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">PBCollapsibleSplitView.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">PBCommitList</string>
<string key="superclassName">NSTableView</string>
<object class="NSMutableDictionary" key="outlets">
@@ -3051,6 +3067,7 @@
<string>commitController</string>
<string>commitList</string>
<string>fileBrowser</string>
+ <string>historySplitView</string>
<string>searchField</string>
<string>treeContextMenu</string>
<string>treeController</string>
@@ -3061,6 +3078,7 @@
<string>NSArrayController</string>
<string>NSTableView</string>
<string>NSOutlineView</string>
+ <string>PBCollapsibleSplitView</string>
<string>NSSearchField</string>
<string>NSMenu</string>
<string>NSTreeController</string>
Please sign in to comment.
Something went wrong with that request. Please try again.