Remember mini mode.

CQTexperiment
vspader 2008-06-22 19:02:53 +00:00
parent f4184dac20
commit 2e819f4970
4 changed files with 65 additions and 31 deletions

View File

@ -11,8 +11,13 @@
@interface InvertedToolbarWindow : NSWindow {
BOOL contentHidden;
double contentHeight;
double contentWidth;
NSSize contentSize;
}
- (void)hideContent;
- (void)hideContentwithAnimation:(BOOL)animate;
- (void)showContent;
@end

View File

@ -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 {

View File

@ -31,7 +31,6 @@
if (self)
{
[sideViewNibs setObject:@"FileTree" forKey:@"File Tree"];
[sideViewNibs setObject:@"FileTree" forKey:@"Another File Tree!"];
sideView = nil;
}

View File

@ -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];
}