Remember mini mode.
parent
f4184dac20
commit
2e819f4970
|
@ -11,8 +11,13 @@
|
||||||
|
|
||||||
@interface InvertedToolbarWindow : NSWindow {
|
@interface InvertedToolbarWindow : NSWindow {
|
||||||
BOOL contentHidden;
|
BOOL contentHidden;
|
||||||
double contentHeight;
|
NSSize contentSize;
|
||||||
double contentWidth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)hideContent;
|
||||||
|
- (void)hideContentwithAnimation:(BOOL)animate;
|
||||||
|
|
||||||
|
- (void)showContent;
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -11,45 +11,76 @@
|
||||||
|
|
||||||
@implementation InvertedToolbarWindow
|
@implementation InvertedToolbarWindow
|
||||||
|
|
||||||
|
+ (void)initialize
|
||||||
|
{
|
||||||
|
NSMutableDictionary *userDefaultsValuesDict = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
|
[userDefaultsValuesDict setObject:[NSNumber numberWithBool:NO] forKey:@"CogWindowHidden"];
|
||||||
|
NSLog(@"DICT: %@", userDefaultsValuesDict);
|
||||||
|
[[NSUserDefaults standardUserDefaults] registerDefaults:userDefaultsValuesDict];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)awakeFromNib
|
- (void)awakeFromNib
|
||||||
{
|
{
|
||||||
contentHidden = NO;
|
contentHidden = [[NSUserDefaults standardUserDefaults] boolForKey:@"CogWindowHidden"];
|
||||||
|
if (contentHidden)
|
||||||
|
{
|
||||||
|
[self hideContentwithAnimation:YES];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)toggleToolbarShown:(id)sender
|
- (void)toggleToolbarShown:(id)sender
|
||||||
{
|
{
|
||||||
if (contentHidden) //Show
|
if (contentHidden) //Show
|
||||||
{
|
{
|
||||||
NSRect newFrame = [self frame];
|
[self showContent];
|
||||||
|
|
||||||
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];
|
|
||||||
}
|
}
|
||||||
else //Hide
|
else //Hide
|
||||||
{
|
{
|
||||||
NSRect newFrame = [self frame];
|
[self hideContent];
|
||||||
|
|
||||||
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];
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (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 {
|
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)proposedFrameSize {
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
[sideViewNibs setObject:@"FileTree" forKey:@"File Tree"];
|
[sideViewNibs setObject:@"FileTree" forKey:@"File Tree"];
|
||||||
[sideViewNibs setObject:@"FileTree" forKey:@"Another File Tree!"];
|
|
||||||
|
|
||||||
sideView = nil;
|
sideView = nil;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
[sideViewNibs setObject:@"FileTree" forKey:@"File Tree In a Window!"];
|
[sideViewNibs setObject:@"FileTree" forKey:@"File Tree"];
|
||||||
[sideViewNibs setObject:@"FileTree" forKey:@"Another File Tree (In a window)!"];
|
|
||||||
|
|
||||||
windows = [[NSMutableDictionary alloc] init];
|
windows = [[NSMutableDictionary alloc] init];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue