Revision: 6656
http://skim-app.svn.sourceforge.net/skim-app/?rev=6656&view=rev
Author: hofman
Date: 2010-07-27 09:49:14 +0000 (Tue, 27 Jul 2010)
Log Message:
-----------
consolidate some fullscreen code and avoid doing things twice
Modified Paths:
--------------
trunk/SKMainWindowController.m
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2010-07-26 12:58:34 UTC (rev 6655)
+++ trunk/SKMainWindowController.m 2010-07-27 09:49:14 UTC (rev 6656)
@@ -1301,10 +1301,21 @@
}
}
+- (void)applyBackgroundColorAndLevelForWindow:(NSWindow *)fullScreenWindow {
+ BOOL isPresentation = [self interactionMode] == SKPresentationMode;
+ NSColor *backgroundColor = isPresentation ? [NSColor blackColor] :
[[NSUserDefaults standardUserDefaults]
colorForKey:SKFullScreenBackgroundColorKey];
+ NSInteger level = isPresentation && [[NSUserDefaults standardUserDefaults]
boolForKey:SKUseNormalLevelForPresentationKey] == NO ? NSPopUpMenuWindowLevel :
NSNormalWindowLevel;
+
+ [fullScreenWindow setBackgroundColor:backgroundColor];
+ [fullScreenWindow setLevel:level];
+ [pdfView setBackgroundColor:isPresentation ? [NSColor clearColor] :
backgroundColor];
+ [secondaryPdfView setBackgroundColor:backgroundColor];
+ [pdfView layoutDocumentView];
+ [pdfView setNeedsDisplay:YES];
+}
+
- (void)goFullScreen {
NSScreen *screen = [[self window] screen] ?: [NSScreen mainScreen]; // @@
screen: or should we use the main screen?
- NSColor *backgroundColor = [self interactionMode] == SKPresentationMode ?
[NSColor blackColor] : [[NSUserDefaults standardUserDefaults]
colorForKey:SKFullScreenBackgroundColorKey];
- NSInteger level = [self interactionMode] == SKPresentationMode &&
[[NSUserDefaults standardUserDefaults]
boolForKey:SKUseNormalLevelForPresentationKey] == NO ? NSPopUpMenuWindowLevel :
NSNormalWindowLevel;
// create a new full screen window
SKMainFullScreenWindow *fullScreenWindow = [[[SKMainFullScreenWindow
alloc] initWithScreen:screen] autorelease];
@@ -1312,10 +1323,7 @@
if ([[mainWindow firstResponder] isDescendantOf:pdfView])
[mainWindow makeFirstResponder:nil];
[fullScreenWindow setMainView:([self interactionMode] ==
SKPresentationMode ? (id)pdfView : (id)pdfSplitView)];
- [fullScreenWindow setBackgroundColor:backgroundColor];
- [fullScreenWindow setLevel:level];
- [pdfView setBackgroundColor:[self interactionMode] == SKPresentationMode ?
[NSColor clearColor] : backgroundColor];
- [secondaryPdfView setBackgroundColor:backgroundColor];
+ [self applyBackgroundColorAndLevelForWindow:fullScreenWindow];
[pdfView layoutDocumentView];
[pdfView setNeedsDisplay:YES];
@@ -1325,6 +1333,7 @@
if (nil == blankingWindows)
blankingWindows = [[NSMutableArray alloc] init];
[blankingWindows removeAllObjects];
+ NSColor *backgroundColor = [fullScreenWindow backgroundColor];
for (NSScreen *screenToBlank in [NSScreen screens]) {
if ([screenToBlank isEqual:screen] == NO) {
SKFullScreenWindow *aWindow = [[SKFullScreenWindow alloc]
initWithScreen:screenToBlank];
@@ -1375,12 +1384,6 @@
if ([pdfView hasReadingBar])
[pdfView toggleReadingBar];
- [pdfView setBackgroundColor:[NSColor clearColor]];
- if ([self window] != mainWindow) {
- [[self window] setBackgroundColor:[NSColor blackColor]];
- [[self window] setLevel:[[NSUserDefaults standardUserDefaults]
boolForKey:SKUseNormalLevelForPresentationKey] == NO ? NSPopUpMenuWindowLevel :
NSNormalWindowLevel];
- }
-
SKPDFView *notesPdfView = [[self presentationNotesDocument] pdfView];
if (notesPdfView)
[notesPdfView goToPage:[[notesPdfView document] pageAtIndex:[[pdfView
currentPage] pageIndex]]];
@@ -1404,32 +1407,29 @@
}
- (IBAction)enterFullScreen:(id)sender {
- if ([self interactionMode] == SKFullScreenMode)
+ SKInteractionMode wasInteractionMode = [self interactionMode];
+ if (wasInteractionMode == SKFullScreenMode)
return;
- BOOL wasPresentation = [self interactionMode] == SKPresentationMode;
-
NSScreen *screen = [[self window] screen] ?: [NSScreen mainScreen]; // @@
screen: or should we use the main screen?
interactionMode = SKFullScreenMode;
- if (wasPresentation) {
+ if (wasInteractionMode == SKPresentationMode) {
[self exitPresentationMode];
+
+ [NSApp updatePresentationOptions];
+
[pdfView setFrame:[pdfContentView bounds]];
[pdfContentView addSubview:pdfView];
[(SKFullScreenWindow *)[self window] setMainView:pdfSplitView];
- [NSApp updatePresentationOptions];
+
+ [self applyBackgroundColorAndLevelForWindow:[self window]];
} else {
[self saveNormalSetup];
[self goFullScreen];
}
- NSColor *backgroundColor = [[NSUserDefaults standardUserDefaults]
colorForKey:SKFullScreenBackgroundColorKey];
- [pdfView setBackgroundColor:backgroundColor];
- [secondaryPdfView setBackgroundColor:backgroundColor];
- [[self window] setBackgroundColor:backgroundColor];
- [[self window] setLevel:NSNormalWindowLevel];
-
NSDictionary *fullScreenSetup = [[NSUserDefaults standardUserDefaults]
dictionaryForKey:SKDefaultFullScreenPDFDisplaySettingsKey];
if ([fullScreenSetup count])
[self applyPDFSettings:fullScreenSetup];
@@ -1439,22 +1439,25 @@
}
- (IBAction)enterPresentation:(id)sender {
- if ([self interactionMode] == SKPresentationMode)
+ SKInteractionMode wasInteractionMode = [self interactionMode];
+ if (wasInteractionMode == SKPresentationMode)
return;
- BOOL wasFullScreen = [self interactionMode] == SKFullScreenMode;
-
[self enterPresentationMode];
NSScreen *screen = [[self window] screen] ?: [NSScreen mainScreen]; // @@
screen: or should we use the main screen?
interactionMode = SKPresentationMode;
- if (wasFullScreen) {
+ if (wasInteractionMode == SKFullScreenMode) {
[NSApp updatePresentationOptions];
+
[pdfSplitView setFrame:[centerContentView bounds]];
[centerContentView addSubview:pdfSplitView];
[(SKFullScreenWindow *)[self window] setMainView:pdfView];
+
+ [self applyBackgroundColorAndLevelForWindow:[self window]];
+
[self hideSideWindows];
} else {
[self goFullScreen];
@@ -1464,10 +1467,11 @@
}
- (IBAction)exitFullScreen:(id)sender {
- if ([self interactionMode] == SKNormalMode)
+ SKInteractionMode wasInteractionMode = [self interactionMode];
+ if (wasInteractionMode == SKNormalMode)
return;
- if ([self interactionMode] == SKFullScreenMode)
+ if (wasInteractionMode == SKFullScreenMode)
[self hideSideWindows];
if ([[[self window] firstResponder] isDescendantOf:pdfView])
@@ -1480,9 +1484,10 @@
// animating the view itself does no work as PDFView does not work nicely
with CoreAnimation, so we use a temporary window
SKMainFullScreenWindow *fullScreenWindow = [[[self window] retain]
autorelease];
SKFullScreenWindow *fadeWindow = [[SKFullScreenWindow alloc]
initWithScreen:[fullScreenWindow screen]];
+ NSView *mainView = [fullScreenWindow mainView];
[fadeWindow setBackgroundColor:[fullScreenWindow backgroundColor]];
[fadeWindow setLevel:[fullScreenWindow level]];
- [fadeWindow setMainView:[fullScreenWindow mainView]];
+ [fadeWindow setMainView:mainView];
[fadeWindow orderWindow:NSWindowAbove relativeTo:[fullScreenWindow
windowNumber]];
[fadeWindow display];
[fullScreenWindow display];
@@ -1491,18 +1496,14 @@
[fadeWindow release];
// this should be done before exitPresentationMode to get a smooth
transition
- if ([self interactionMode] == SKFullScreenMode) {
- [pdfSplitView setFrame:[centerContentView bounds]];
- [centerContentView addSubview:pdfSplitView];
- } else {
- [pdfView setFrame:[pdfContentView bounds]];
- [pdfContentView addSubview:pdfView];
- }
+ NSView *contentView = [self interactionMode] == SKFullScreenMode ?
centerContentView : pdfContentView;
+ [mainView setFrame:[contentView bounds]];
+ [contentView addSubview:mainView];
[pdfView setBackgroundColor:[[NSUserDefaults standardUserDefaults]
colorForKey:SKBackgroundColorKey]];
[secondaryPdfView setBackgroundColor:[[NSUserDefaults
standardUserDefaults] colorForKey:SKBackgroundColorKey]];
[pdfView layoutDocumentView];
- if ([self interactionMode] == SKPresentationMode)
+ if (wasInteractionMode == SKPresentationMode)
[self exitPresentationMode];
else
[self applyPDFSettings:savedNormalSetup];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit