2007-10-31 22:53:52 -03:00
|
|
|
//
|
|
|
|
// InvertedToolbarWindow.m
|
|
|
|
// Cog
|
|
|
|
//
|
|
|
|
// Created by Vincent Spader on 10/31/07.
|
|
|
|
// Copyright 2007 __MyCompanyName__. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "InvertedToolbarWindow.h"
|
|
|
|
|
|
|
|
|
|
|
|
@implementation InvertedToolbarWindow
|
|
|
|
|
2008-06-22 15:02:53 -04:00
|
|
|
+ (void)initialize
|
|
|
|
{
|
|
|
|
NSMutableDictionary *userDefaultsValuesDict = [NSMutableDictionary dictionary];
|
|
|
|
|
2008-06-22 15:04:15 -04:00
|
|
|
[userDefaultsValuesDict setObject:[NSNumber numberWithBool:NO] forKey:@"WindowContentHidden"];
|
|
|
|
|
2008-06-22 15:02:53 -04:00
|
|
|
[[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict];
|
|
|
|
}
|
|
|
|
|
2007-10-31 22:53:52 -03:00
|
|
|
- (void)awakeFromNib
|
|
|
|
{
|
2008-06-22 15:04:15 -04:00
|
|
|
contentHidden = [[NSUserDefaults standardUserDefaults] boolForKey:@"WindowContentHidden"];
|
2008-06-22 15:02:53 -04:00
|
|
|
if (contentHidden)
|
|
|
|
{
|
|
|
|
[self hideContentwithAnimation:YES];
|
|
|
|
}
|
2007-10-31 22:53:52 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)toggleToolbarShown:(id)sender
|
|
|
|
{
|
2007-10-31 23:15:14 -03:00
|
|
|
if (contentHidden) //Show
|
|
|
|
{
|
2008-06-22 15:02:53 -04:00
|
|
|
[self showContent];
|
2007-10-31 22:53:52 -03:00
|
|
|
}
|
2007-10-31 23:15:14 -03:00
|
|
|
else //Hide
|
|
|
|
{
|
2008-06-22 15:02:53 -04:00
|
|
|
[self hideContent];
|
2007-10-31 22:53:52 -03:00
|
|
|
}
|
2008-06-22 15:02:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (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;
|
|
|
|
|
|
|
|
[self setShowsResizeIndicator:NO];
|
2007-10-31 22:53:52 -03:00
|
|
|
|
2008-06-22 15:02:53 -04:00
|
|
|
[[self contentView] setAutoresizesSubviews:NO];
|
|
|
|
[self setFrame:newFrame display:YES animate:animate];
|
|
|
|
|
|
|
|
contentHidden = YES;
|
2008-06-22 15:04:15 -04:00
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"WindowContentHidden"];
|
2008-06-22 15:02:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (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;
|
2008-06-22 15:04:15 -04:00
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WindowContentHidden"];
|
2007-10-31 22:53:52 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)proposedFrameSize {
|
|
|
|
if (contentHidden) {
|
|
|
|
proposedFrameSize.height = [self frame].size.height;
|
|
|
|
}
|
|
|
|
|
|
|
|
return proposedFrameSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|