From 2e819f4970db82d5f0bba229bff789f3eeb9170a Mon Sep 17 00:00:00 2001 From: vspader Date: Sun, 22 Jun 2008 19:02:53 +0000 Subject: [PATCH] Remember mini mode. --- Application/InvertedToolbarWindow.h | 9 +++- Application/InvertedToolbarWindow.m | 83 ++++++++++++++++++++--------- SideView/SideBarController.m | 1 - SideView/SideWindowController.m | 3 +- 4 files changed, 65 insertions(+), 31 deletions(-) diff --git a/Application/InvertedToolbarWindow.h b/Application/InvertedToolbarWindow.h index 5ef9e4937..fb79ca0b2 100644 --- a/Application/InvertedToolbarWindow.h +++ b/Application/InvertedToolbarWindow.h @@ -11,8 +11,13 @@ @interface InvertedToolbarWindow : NSWindow { BOOL contentHidden; - double contentHeight; - double contentWidth; + NSSize contentSize; } +- (void)hideContent; +- (void)hideContentwithAnimation:(BOOL)animate; + +- (void)showContent; + + @end diff --git a/Application/InvertedToolbarWindow.m b/Application/InvertedToolbarWindow.m index 0208dc91e..659128f5b 100644 --- a/Application/InvertedToolbarWindow.m +++ b/Application/InvertedToolbarWindow.m @@ -11,45 +11,76 @@ @implementation InvertedToolbarWindow ++ (void)initialize +{ + NSMutableDictionary *userDefaultsValuesDict = [NSMutableDictionary dictionary]; + + [userDefaultsValuesDict setObject:[NSNumber numberWithBool:NO] forKey:@"CogWindowHidden"]; + NSLog(@"DICT: %@", userDefaultsValuesDict); + [[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict]; +} + - (void)awakeFromNib { - contentHidden = NO; + contentHidden = [[NSUserDefaults standardUserDefaults] boolForKey:@"CogWindowHidden"]; + if (contentHidden) + { + [self hideContentwithAnimation:YES]; + } } - (void)toggleToolbarShown:(id)sender { if (contentHidden) //Show { - NSRect newFrame = [self frame]; - - newFrame.origin.y -= contentHeight; - newFrame.size.height += contentHeight; - - [[self contentView] resizeSubviewsWithOldSize:NSMakeSize(contentWidth, 0)]; - - [self setFrame:newFrame display:YES animate:YES]; - - [[self contentView] setAutoresizesSubviews:YES]; - - [self setShowsResizeIndicator:YES]; + [self showContent]; } else //Hide { - NSRect newFrame = [self frame]; - - contentWidth = [[self contentView] bounds].size.width; - contentHeight = [[self contentView] bounds].size.height; - - newFrame.origin.y += contentHeight; - newFrame.size.height -= contentHeight; - - [self setShowsResizeIndicator:NO]; - - [[self contentView] setAutoresizesSubviews:NO]; - [self setFrame:newFrame display:YES animate:YES]; + [self hideContent]; } +} + +- (void)hideContent +{ + [self hideContentwithAnimation:YES]; +} + +- (void)hideContentwithAnimation:(BOOL)animate +{ + NSRect newFrame = [self frame]; + + contentSize = [[self contentView] bounds].size; + + newFrame.origin.y += contentSize.height; + newFrame.size.height -= contentSize.height; - contentHidden = !contentHidden; + [self setShowsResizeIndicator:NO]; + + [[self contentView] setAutoresizesSubviews:NO]; + [self setFrame:newFrame display:YES animate:animate]; + + contentHidden = YES; + [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"CogWindowHidden"]; +} + +- (void)showContent +{ + NSRect newFrame = [self frame]; + + newFrame.origin.y -= contentSize.height; + newFrame.size.height += contentSize.height; + + [[self contentView] resizeSubviewsWithOldSize:NSMakeSize(contentSize.width, 0)]; + + [self setFrame:newFrame display:YES animate:YES]; + + [[self contentView] setAutoresizesSubviews:YES]; + + [self setShowsResizeIndicator:YES]; + + contentHidden = NO; + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"CogWindowHidden"]; } - (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)proposedFrameSize { diff --git a/SideView/SideBarController.m b/SideView/SideBarController.m index 3c7834c22..78fdd9920 100644 --- a/SideView/SideBarController.m +++ b/SideView/SideBarController.m @@ -31,7 +31,6 @@ if (self) { [sideViewNibs setObject:@"FileTree" forKey:@"File Tree"]; - [sideViewNibs setObject:@"FileTree" forKey:@"Another File Tree!"]; sideView = nil; } diff --git a/SideView/SideWindowController.m b/SideView/SideWindowController.m index 3e877fc05..6084c9ba9 100644 --- a/SideView/SideWindowController.m +++ b/SideView/SideWindowController.m @@ -16,8 +16,7 @@ self = [super init]; if (self) { - [sideViewNibs setObject:@"FileTree" forKey:@"File Tree In a Window!"]; - [sideViewNibs setObject:@"FileTree" forKey:@"Another File Tree (In a window)!"]; + [sideViewNibs setObject:@"FileTree" forKey:@"File Tree"]; windows = [[NSMutableDictionary alloc] init]; }