From 10b9fa08a3a9254229b54d31e211b4914643f134 Mon Sep 17 00:00:00 2001 From: German Laullon Date: Wed, 2 Mar 2011 14:40:08 -0800 Subject: [PATCH] working --- PBGitHistoryController.h | 1 + PBGitHistoryController.m | 1 + PBGitWindowController.h | 4 ++++ PBGitWindowController.m | 28 +++++++++++++++++++++++++--- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h index 93bfea0..a456d90 100644 --- a/PBGitHistoryController.h +++ b/PBGitHistoryController.h @@ -57,6 +57,7 @@ } @property (readonly) NSTreeController* treeController; +@property (readonly) PBCollapsibleSplitView *historySplitView; @property (assign) int selectedCommitDetailsIndex; @property (retain) PBGitCommit *webCommit; @property (retain) PBGitTree* gitTree; diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m index e3be741..bc955cb 100644 --- a/PBGitHistoryController.m +++ b/PBGitHistoryController.m @@ -48,6 +48,7 @@ @synthesize searchController; @synthesize commitList; @synthesize treeController; +@synthesize historySplitView; - (void)awakeFromNib { diff --git a/PBGitWindowController.h b/PBGitWindowController.h index 1cd193c..70b268d 100644 --- a/PBGitWindowController.h +++ b/PBGitWindowController.h @@ -9,6 +9,9 @@ #import #import "PBGitRepository.h" +#define kGitSplitViewMinWidth 150.0f +#define kGitSplitViewMaxWidth 300.0f + @class PBViewController, PBGitSidebarController, PBGitCommitController; @interface PBGitWindowController : NSWindowController { @@ -39,6 +42,7 @@ - (void)showMessageSheet:(NSString *)messageText infoText:(NSString *)infoText; - (void)showErrorSheet:(NSError *)error; - (void)showErrorSheetTitle:(NSString *)title message:(NSString *)message arguments:(NSArray *)arguments output:(NSString *)output; +- (void)collapseSplitView:(NSSplitView *)sp show:(BOOL)show; - (IBAction) showCommitView:(id)sender; - (IBAction) showHistoryView:(id)sender; diff --git a/PBGitWindowController.m b/PBGitWindowController.m index 8a2ce1e..b2d6b77 100644 --- a/PBGitWindowController.m +++ b/PBGitWindowController.m @@ -217,16 +217,38 @@ - (IBAction) changeLayout:(id)sender{ NSLog(@"selectedSegment=%ld (%d)",[sender selectedSegment],[sender isSelectedForSegment:[sender selectedSegment]]); + NSSplitView *sp=nil; + switch ([sender selectedSegment]) { + case 0: + sp=splitView; + break; + case 1: + sp=[[sidebarController historyViewController] historySplitView]; + break; + } + NSLog(@"sp=%@",sp); + if(sp!=nil) { + [self collapseSplitView:sp show:[sender isSelectedForSegment:[sender selectedSegment]]]; + } } +- (void)collapseSplitView:(NSSplitView *)sp show:(BOOL)show{ + NSView *clipview = [[sp subviews] objectAtIndex:0]; + NSRect clipFrame = [clipview frame]; + + if ([sp isVertical]) { + clipFrame.size.width = kGitSplitViewMinWidth * show; + }else{ + clipFrame.size.height = kGitSplitViewMinWidth * show; + } + [clipview setFrame:clipFrame]; + [sp adjustSubviews]; +} #pragma mark - #pragma mark SplitView Delegates -#define kGitSplitViewMinWidth 150.0f -#define kGitSplitViewMaxWidth 300.0f - #pragma mark min/max widths while moving the divider - (CGFloat)splitView:(NSSplitView *)view constrainMinCoordinate:(CGFloat)proposedMin ofSubviewAt:(NSInteger)dividerIndex