Added fullscreen support for Mac OS 10.7+ (Lion and newer)

This commit is contained in:
ePirat 2012-11-24 20:08:32 +01:00
parent 5ca4fd7985
commit 1c4ccccf76
5 changed files with 164 additions and 15 deletions

View file

@ -11,7 +11,15 @@
#import "PostModel.h"
#import "NSData+Base64.h"
@implementation NSWindow (FullScreen)
- (BOOL)mn_isFullScreen
{
return (([self styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask);
}
@end
@implementation Controller
@synthesize FullscreenMain;
@synthesize loginViewWindow;
@synthesize loginEntityTextField;
@synthesize loginActivityIndicator;
@ -423,13 +431,48 @@
[accessToken setString:nil forKey:@"entity"];
}
// Mentions window has been visible
// Mentions window has been visible + Changes for better fullscreen mode
- (void)windowDidBecomeKey:(NSNotification *)notification
{
if ([notification object] == mentionsViewWindow)
{
[self unreadMentions:0];
}
[self unreadMentions:0];
}
else if (([notification object] == conversationViewWindow) && ((timelineViewWindow.mn_isFullScreen) || (mentionsViewWindow.mn_isFullScreen)))
{
[conversationViewWindow setLevel:NSModalPanelWindowLevel];
}
}
- (void)windowWillEnterFullScreen:(NSNotification *)notification
{
[TimelineWindowMenuItem setEnabled:NO];
[MentionsWindowMenuItem setEnabled:NO];
[MinimizeMenuItem setEnabled:NO];
if ([notification object] == mentionsViewWindow){
[timelineViewWindow close];
} else {
[mentionsViewWindow close];
}
[timelineView removeFromSuperview];
[mentionsView removeFromSuperview];
[FullscreenMain addSubview:timelineView];
[FullscreenMain addSubview:mentionsView];
[FullscreenMain setFrame:[[[notification object] contentView] bounds]];
[[[notification object] contentView] addSubview:FullscreenMain];
[FullscreenMain setPosition:([[[notification object] contentView] bounds].size.width/2) ofDividerAtIndex:0];
}
- (void)windowWillExitFullScreen:(NSNotification *)notification
{
[TimelineWindowMenuItem setEnabled:YES];
[MentionsWindowMenuItem setEnabled:YES];
[MinimizeMenuItem setEnabled:YES];
[timelineView setFrame:[[timelineViewWindow contentView] bounds]];
[mentionsView setFrame:[[mentionsViewWindow contentView] bounds]];
[FullscreenMain removeFromSuperview];
[[timelineViewWindow contentView] addSubview:timelineView];
[[mentionsViewWindow contentView] addSubview:mentionsView];
}
- (void)getTweetUpdates:(id)sender