Revision: 6662
          http://skim-app.svn.sourceforge.net/skim-app/?rev=6662&view=rev
Author:   hofman
Date:     2010-07-30 21:45:16 +0000 (Fri, 30 Jul 2010)

Log Message:
-----------
Fade in fullscreen windows. Reorganize fullscreen code, move fading in/out of 
window and view to separate methods. There should be no need to pass the screen 
to various methods for adding extra windows used in fullscreen modes, as the 
main fullscreen window's screen should be set as it's already displayed.

Modified Paths:
--------------
    trunk/SKFullScreenWindow.h
    trunk/SKFullScreenWindow.m
    trunk/SKMainWindowController.h
    trunk/SKMainWindowController.m
    trunk/SKMainWindowController_Actions.m
    trunk/SKMainWindowController_UI.m
    trunk/SKNavigationWindow.h
    trunk/SKNavigationWindow.m
    trunk/SKPDFView.h
    trunk/SKPDFView.m
    trunk/SKSideWindow.h
    trunk/SKSideWindow.m

Modified: trunk/SKFullScreenWindow.h
===================================================================
--- trunk/SKFullScreenWindow.h  2010-07-29 09:05:37 UTC (rev 6661)
+++ trunk/SKFullScreenWindow.h  2010-07-30 21:45:16 UTC (rev 6662)
@@ -44,10 +44,8 @@
     NSViewAnimation *animation;
 }
 
-...@property (nonatomic, retain) NSView *mainView;
+- (id)initWithScreen:(NSScreen *)screen backgroundColor:(NSColor 
*)backgroundColor level:(NSInteger)level;
 
-- (id)initWithScreen:(NSScreen *)screen;
-
 - (void)fadeOutBlocking;
 - (void)fadeOut;
 - (void)fadeInBlocking;

Modified: trunk/SKFullScreenWindow.m
===================================================================
--- trunk/SKFullScreenWindow.m  2010-07-29 09:05:37 UTC (rev 6661)
+++ trunk/SKFullScreenWindow.m  2010-07-30 21:45:16 UTC (rev 6662)
@@ -45,14 +45,11 @@
 
 @implementation SKFullScreenWindow
 
-...@dynamic mainView;
-
-- (id)initWithScreen:(NSScreen *)screen {
-    if (screen == nil)
-        screen = [NSScreen mainScreen];
-    NSRect screenFrame = [screen frame];
+- (id)initWithScreen:(NSScreen *)screen backgroundColor:(NSColor 
*)backgroundColor level:(NSInteger)level {
+    NSRect screenFrame = [(screen ?: [NSScreen mainScreen]) frame];
     if (self = [self initWithContentRect:screenFrame 
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) {
-        [self setBackgroundColor:[NSColor blackColor]];
+        [self setBackgroundColor:backgroundColor];
+        [self setLevel:level];
         [self setReleasedWhenClosed:NO];
         [self setExcludedFromWindowsMenu:YES];
         // appartently this is needed for secondary screens
@@ -102,8 +99,7 @@
         [fadeOutDict release];
         
         [animation setAnimationBlockingMode:block ? NSAnimationBlocking : 
NSAnimationNonblockingThreaded];
-        [animation setAnimationCurve:block ? NSAnimationEaseIn : 
NSAnimationEaseInOut];
-        [animation setDuration:0.5];
+        [animation setDuration:0.25];
         [animation setDelegate:self];
         [animation startAnimation];
     }
@@ -121,8 +117,7 @@
         [super orderFront:nil];
         
         [animation setAnimationBlockingMode:block ? NSAnimationBlocking : 
NSAnimationNonblockingThreaded];
-        [animation setAnimationCurve:block ? NSAnimationEaseIn : 
NSAnimationEaseInOut];
-        [animation setDuration:0.5];
+        [animation setDuration:0.25];
         [animation setDelegate:self];
         [animation startAnimation];
     }
@@ -158,21 +153,12 @@
     [self setAlphaValue:1.0];
 }
 
-- (NSView *)mainView {
-    return [[[self contentView] subviews] lastObject];
-}
-
-- (void)setMainView:(NSView *)view {
-    [view setFrame:[[self contentView] bounds]];
-    [[self contentView] addSubview:view];
-}
-
 @end
 
 @implementation SKMainFullScreenWindow
 
-- (id)initWithScreen:(NSScreen *)screen canBecomeMain:(BOOL)flag {
-    if (self = [super initWithScreen:screen]) {
+- (id)initWithScreen:(NSScreen *)screen backgroundColor:(NSColor 
*)backgroundColor level:(NSInteger)level {
+    if (self = [super initWithScreen:screen backgroundColor:backgroundColor 
level:level]) {
         [self setDisplaysWhenScreenProfileChanges:YES];
         [self setAcceptsMouseMovedEvents:YES];
         [self setExcludedFromWindowsMenu:NO];

Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h      2010-07-29 09:05:37 UTC (rev 6661)
+++ trunk/SKMainWindowController.h      2010-07-30 21:45:16 UTC (rev 6662)
@@ -37,10 +37,10 @@
  */
 
 #import <Cocoa/Cocoa.h>
-#import <IOKit/pwr_mgt/IOPMLib.h>
 #import "SKSnapshotWindowController.h"
 #import "SKThumbnail.h"
 #import "NSDocument_SKExtensions.h"
+#import <IOKit/pwr_mgt/IOPMLib.h>
 
 enum {
     SKThumbnailSidePaneState,
@@ -268,8 +268,8 @@
 @property (nonatomic) SKRightSidePaneState rightSidePaneState;
 @property (nonatomic) SKFindPaneState findPaneState;
 
-- (void)showLeftSideWindowOnScreen:(NSScreen *)screen;
-- (void)showRightSideWindowOnScreen:(NSScreen *)screen;
+- (void)showLeftSideWindow;
+- (void)showRightSideWindow;
 - (void)hideLeftSideWindow;
 - (void)hideRightSideWindow;
 

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2010-07-29 09:05:37 UTC (rev 6661)
+++ trunk/SKMainWindowController.m      2010-07-30 21:45:16 UTC (rev 6662)
@@ -158,6 +158,16 @@
 
 #define SKDisplayNoteBoundsKey @"SKDisplayNoteBounds" 
 
+static void addSideSubview(NSView *view, NSView *contentView, BOOL 
usesDrawers) {
+    NSRect rect = [contentView bounds];
+    if (usesDrawers == 0) {
+        rect = NSInsetRect(rect, -1, -1);
+        rect.size.height -= 1;
+    }
+    [view setFrame:rect];
+    [contentView addSubview:view];
+}
+
 @interface SKMainWindowController (SKPrivate)
 
 - (void)applyLeftSideWidth:(CGFloat)leftSideWidth 
rightSideWidth:(CGFloat)rightSideWidth;
@@ -314,20 +324,8 @@
     [pdfContentView setAutoresizesSubviews:YES];
     
     // make sure the first thing we call on the side view controllers is its 
view so their nib is loaded
-    NSRect rect = [leftSideContentView bounds];
-    if (mwcFlags.usesDrawers == 0) {
-        rect = NSInsetRect(rect, -1, -1);
-        rect.size.height -= 1;
-    }
-    [[leftSideController view] setFrame:rect];
-    [leftSideContentView addSubview:leftSideController.view];
-    rect = [rightSideContentView bounds];
-    if (mwcFlags.usesDrawers == 0) {
-        rect = NSInsetRect(rect, -1, -1);
-        rect.size.height -= 1;
-    }
-    [[rightSideController view] setFrame:rect];
-    [rightSideContentView addSubview:rightSideController.view];
+    addSideSubview(leftSideController.view, leftSideContentView, 
mwcFlags.usesDrawers);
+    addSideSubview(rightSideController.view, rightSideContentView, 
mwcFlags.usesDrawers);
     
     [leftSideController.searchField setAction:@selector(search:)];
     [leftSideController.searchField setTarget:self];
@@ -1202,7 +1200,7 @@
 
 #pragma mark Full Screen support
 
-- (void)showLeftSideWindowOnScreen:(NSScreen *)screen {
+- (void)showLeftSideWindow {
     if (leftSideWindow == nil)
         leftSideWindow = [[SKSideWindow alloc] initWithMainController:self 
edge:NSMinXEdge];
     
@@ -1216,15 +1214,15 @@
         [leftSideWindow setAlphaValue:PRESENTATION_SIDE_WINDOW_ALPHA];
         [leftSideWindow setEnabled:NO];
         [leftSideWindow 
makeFirstResponder:leftSideController.thumbnailTableView];
-        [leftSideWindow attachToWindow:[self window] onScreen:screen];
+        [leftSideWindow attachToWindow:[self window]];
         [leftSideWindow expand];
     } else {
         [leftSideWindow makeFirstResponder:leftSideController.searchField];
-        [leftSideWindow attachToWindow:[self window] onScreen:screen];
+        [leftSideWindow attachToWindow:[self window]];
     }
 }
 
-- (void)showRightSideWindowOnScreen:(NSScreen *)screen {
+- (void)showRightSideWindow {
     if (rightSideWindow == nil) 
         rightSideWindow = [[SKSideWindow alloc] initWithMainController:self 
edge:NSMaxXEdge];
     
@@ -1235,10 +1233,10 @@
     if ([self interactionMode] == SKPresentationMode) {
         [rightSideWindow setAlphaValue:PRESENTATION_SIDE_WINDOW_ALPHA];
         [rightSideWindow setEnabled:NO];
-        [rightSideWindow attachToWindow:[self window] onScreen:screen];
+        [rightSideWindow attachToWindow:[self window]];
         [rightSideWindow expand];
     } else {
-        [rightSideWindow attachToWindow:[self window] onScreen:screen];
+        [rightSideWindow attachToWindow:[self window]];
     }
 }
 
@@ -1248,13 +1246,7 @@
         
         if ([[leftSideWindow firstResponder] 
isDescendantOf:leftSideController.view])
             [leftSideWindow makeFirstResponder:nil];
-        NSRect rect = [leftSideContentView bounds];
-        if (mwcFlags.usesDrawers == 0) {
-            rect = NSInsetRect(rect, -1, -1);
-            rect.size.height -= 1;
-        }
-        [leftSideController.view setFrame:rect];
-        [leftSideContentView addSubview:leftSideController.view];
+        addSideSubview(leftSideController.view, leftSideContentView, 
mwcFlags.usesDrawers);
         
         SKDESTROY(leftSideWindow);
     }
@@ -1266,34 +1258,12 @@
         
         if ([[rightSideWindow firstResponder] 
isDescendantOf:rightSideController.view])
             [rightSideWindow makeFirstResponder:nil];
-        NSRect rect = [rightSideContentView bounds];
-        if (mwcFlags.usesDrawers == 0) {
-            rect = NSInsetRect(rect, -1, -1);
-            rect.size.height -= 1;
-        }
-        [rightSideController.view setFrame:rect];
-        [rightSideContentView addSubview:rightSideController.view];
+        addSideSubview(rightSideController.view, rightSideContentView, 
mwcFlags.usesDrawers);
         
         SKDESTROY(rightSideWindow);
     }
 }
 
-- (void)showSideWindowsOnScreen:(NSScreen *)screen {
-    [self showLeftSideWindowOnScreen:screen];
-    [self showRightSideWindowOnScreen:screen];
-    
-    if ([SKSideWindow isAutoHideEnabled])
-        [pdfSplitView setFrame:NSInsetRect([[pdfSplitView superview] bounds], 
9.0, 0.0)];
-    [[pdfSplitView superview] setNeedsDisplay:YES];
-}
-
-- (void)hideSideWindows {
-    [self hideLeftSideWindow];
-    [self hideRightSideWindow];
-    
-    [pdfView setFrame:[[pdfView superview] bounds]];
-}
-
 - (void)forceSubwindowsOnTop:(BOOL)flag {
     for (NSWindowController *wc in [[self document] windowControllers]) {
         if ([wc respondsToSelector:@selector(setForceOnTop:)])
@@ -1301,75 +1271,10 @@
     }
 }
 
-- (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];
-    
-    // create a new full screen window, it may have to be displayed on a 
different screen or space
-    SKMainFullScreenWindow *fullScreenWindow = [[[SKMainFullScreenWindow 
alloc] initWithScreen:screen] autorelease];
-    
-    if ([[mainWindow firstResponder] isDescendantOf:pdfView])
-        [mainWindow makeFirstResponder:nil];
-    [fullScreenWindow setMainView:([self interactionMode] == 
SKPresentationMode ? (NSView *)pdfView : (NSView *)pdfSplitView)];
-    [self applyBackgroundColorAndLevelForWindow:fullScreenWindow];
-    [pdfView layoutDocumentView];
-    [pdfView setNeedsDisplay:YES];
-    
-    [self forceSubwindowsOnTop:YES];
-    
-    if ([self interactionMode] == SKFullScreenMode && [[NSUserDefaults 
standardUserDefaults] boolForKey:SKBlankAllScreensInFullScreenKey] && 
[[NSScreen screens] count] > 1) {
-        if (nil == blankingWindows)
-            blankingWindows = [[NSMutableArray alloc] init];
-        NSColor *backgroundColor = [fullScreenWindow backgroundColor];
-        for (NSScreen *screenToBlank in [NSScreen screens]) {
-            if ([screenToBlank isEqual:screen] == NO) {
-                SKFullScreenWindow *aWindow = [[SKFullScreenWindow alloc] 
initWithScreen:screenToBlank];
-                [aWindow setBackgroundColor:backgroundColor];
-                [aWindow setLevel:NSFloatingWindowLevel];
-                [aWindow 
setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
-                [aWindow setHidesOnDeactivate:YES];
-                [aWindow orderFront:nil];
-                [blankingWindows addObject:aWindow];
-                [aWindow release];
-            }
-        }
-    }
-    
-    [mainWindow setDelegate:nil];
-    [self setWindow:fullScreenWindow];
-    [fullScreenWindow makeKeyAndOrderFront:self];
-    [fullScreenWindow makeFirstResponder:pdfView];
-    [fullScreenWindow recalculateKeyViewLoop];
-    [mainWindow orderOut:self];    
-    [fullScreenWindow setDelegate:self];
-    [NSApp addWindowsItem:fullScreenWindow title:[self 
windowTitleForDocumentDisplayName:[[self document] displayName]] filename:NO];
-}
-
-- (void)saveNormalSetup {
-    NSScrollView *scrollView = [[pdfView documentView] enclosingScrollView];
-    [savedNormalSetup setDictionary:[self currentPDFSettings]];
-    [savedNormalSetup setObject:[NSNumber numberWithBool:[scrollView 
hasHorizontalScroller]] forKey:HASHORIZONTALSCROLLER_KEY];
-    [savedNormalSetup setObject:[NSNumber numberWithBool:[scrollView 
hasVerticalScroller]] forKey:HASVERTICALSCROLLER_KEY];
-    [savedNormalSetup setObject:[NSNumber numberWithBool:[scrollView 
autohidesScrollers]] forKey:AUTOHIDESSCROLLERS_KEY];
-}
-
 - (void)enterPresentationMode {
     NSScrollView *scrollView = [[pdfView documentView] enclosingScrollView];
-    if ([self interactionMode] == SKNormalMode)
-        [self saveNormalSetup];
     // Set up presentation mode
+    [pdfView setBackgroundColor:[NSColor clearColor]];
     [pdfView setAutoScales:YES];
     [pdfView setDisplayMode:kPDFDisplaySinglePage];
     [pdfView setDisplayBox:kPDFDisplayBoxCropBox];
@@ -1404,12 +1309,114 @@
     [self hideLeftSideWindow];
 }
 
+- (void)fadeInFullScreenWindowWithBackgroundColor:(NSColor *)backgroundColor 
level:(NSInteger)level {
+    // remember normal setup to return to
+    NSScrollView *scrollView = [[pdfView documentView] enclosingScrollView];
+    [savedNormalSetup setDictionary:[self currentPDFSettings]];
+    [savedNormalSetup setObject:[NSNumber numberWithBool:[scrollView 
hasHorizontalScroller]] forKey:HASHORIZONTALSCROLLER_KEY];
+    [savedNormalSetup setObject:[NSNumber numberWithBool:[scrollView 
hasVerticalScroller]] forKey:HASVERTICALSCROLLER_KEY];
+    [savedNormalSetup setObject:[NSNumber numberWithBool:[scrollView 
autohidesScrollers]] forKey:AUTOHIDESSCROLLERS_KEY];
+    
+    if ([[mainWindow firstResponder] isDescendantOf:pdfSplitView])
+        [mainWindow makeFirstResponder:nil];
+    
+    SKMainFullScreenWindow *fullScreenWindow = [[SKMainFullScreenWindow alloc] 
initWithScreen:[mainWindow screen] backgroundColor:backgroundColor 
level:NSPopUpMenuWindowLevel];
+    
+    [mainWindow setDelegate:nil];
+    [fullScreenWindow fadeInBlocking];
+    [self setWindow:fullScreenWindow];  
+    [fullScreenWindow makeKeyWindow];
+    [mainWindow orderOut:nil];  
+    [fullScreenWindow setLevel:level];
+    [fullScreenWindow orderFront:nil];
+    [fullScreenWindow release];
+}
+
+- (void)fadeInFullScreenView:(NSView *)view inset:(CGFloat)inset {
+    SKMainFullScreenWindow *fullScreenWindow = (SKMainFullScreenWindow *)[self 
window];
+    SKFullScreenWindow *fadeWindow = [[SKFullScreenWindow alloc] 
initWithScreen:[fullScreenWindow screen] backgroundColor:[fullScreenWindow 
backgroundColor] level:[fullScreenWindow level]];
+    
+    [view setFrame:NSInsetRect([[fadeWindow contentView] bounds], inset, 0.0)];
+    [[fadeWindow contentView] addSubview:view];
+    [fadeWindow setAlphaValue:0.0];
+    [pdfView layoutDocumentView];
+    [pdfView setNeedsDisplay:YES];
+    [fadeWindow orderWindow:NSWindowAbove relativeTo:[fullScreenWindow 
windowNumber]];
+    [fadeWindow fadeInBlocking];
+    [[fullScreenWindow contentView] addSubview:view];
+    [fullScreenWindow makeFirstResponder:pdfView];
+    [fullScreenWindow recalculateKeyViewLoop];
+    [fullScreenWindow setDelegate:self];
+    [fullScreenWindow display];
+    [fadeWindow orderOut:nil];
+    [fadeWindow release];
+}
+
+- (void)fadeOutFullScreenView:(NSView *)view {
+    SKMainFullScreenWindow *fullScreenWindow = (SKMainFullScreenWindow *)[self 
window];
+    SKFullScreenWindow *fadeWindow = [[SKFullScreenWindow alloc] 
initWithScreen:[fullScreenWindow screen] backgroundColor:[fullScreenWindow 
backgroundColor] level:[fullScreenWindow level]];
+    
+    [[fadeWindow contentView] addSubview:view];
+    [fadeWindow orderWindow:NSWindowAbove relativeTo:[fullScreenWindow 
windowNumber]];
+    [fadeWindow display];
+    [fullScreenWindow display];
+    [fullScreenWindow setDelegate:nil];
+    [fullScreenWindow makeFirstResponder:nil];
+    [fadeWindow fadeOutBlocking];
+    [fadeWindow release];
+}
+
+- (void)fadeOutFullScreenWindow {
+    SKMainFullScreenWindow *fullScreenWindow = (SKMainFullScreenWindow 
*)[[[self window] retain] autorelease];
+    
+    [fullScreenWindow setLevel:NSPopUpMenuWindowLevel];
+    [self setWindow:mainWindow];
+    // trick to make sure the main window shows up in the same space as the 
fullscreen window
+    [fullScreenWindow addChildWindow:mainWindow ordered:NSWindowBelow];
+    [fullScreenWindow removeChildWindow:mainWindow];
+    // these can change due to the child window trick
+    [mainWindow setLevel:NSNormalWindowLevel];
+    [mainWindow setCollectionBehavior:NSWindowCollectionBehaviorDefault];
+    [mainWindow display];
+    [mainWindow makeFirstResponder:pdfView];
+    [mainWindow recalculateKeyViewLoop];
+    [mainWindow setDelegate:self];
+    [mainWindow makeKeyWindow];
+    [fullScreenWindow fadeOut];
+}
+
+- (void)showBlankingWindows {
+    if ([[NSUserDefaults standardUserDefaults] 
boolForKey:SKBlankAllScreensInFullScreenKey] && [[NSScreen screens] count] > 1) 
{
+        if (nil == blankingWindows)
+            blankingWindows = [[NSMutableArray alloc] init];
+        NSScreen *screen = [[self window] screen];
+        NSColor *backgroundColor = [[self window] backgroundColor];
+        for (NSScreen *screenToBlank in [NSScreen screens]) {
+            if ([screenToBlank isEqual:screen] == NO) {
+                SKFullScreenWindow *aWindow = [[SKFullScreenWindow alloc] 
initWithScreen:screenToBlank backgroundColor:backgroundColor 
level:NSFloatingWindowLevel];
+                [aWindow 
setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
+                [aWindow setHidesOnDeactivate:YES];
+                [aWindow fadeIn];
+                [blankingWindows addObject:aWindow];
+                [aWindow release];
+            }
+        }
+    }
+}
+
+- (void)removeBlankingWindows {
+    [blankingWindows makeObjectsPerformSelector:@selector(fadeOut)];
+    [blankingWindows autorelease];
+    blankingWindows = nil;
+}
+
 - (IBAction)enterFullScreen:(id)sender {
     SKInteractionMode wasInteractionMode = [self interactionMode];
     if (wasInteractionMode == SKFullScreenMode)
         return;
     
-    NSScreen *screen = [[self window] screen] ?: [NSScreen mainScreen];
+    NSColor *backgroundColor = [[NSUserDefaults standardUserDefaults] 
colorForKey:SKFullScreenBackgroundColorKey];
+    NSDictionary *fullScreenSetup = [[NSUserDefaults standardUserDefaults] 
dictionaryForKey:SKDefaultFullScreenPDFDisplaySettingsKey];
     
     interactionMode = SKFullScreenMode;
     
@@ -1420,20 +1427,35 @@
         
         [pdfView setFrame:[pdfContentView bounds]];
         [pdfContentView addSubview:pdfView];
-        [(SKFullScreenWindow *)[self window] setMainView:pdfSplitView];
+        [pdfSplitView setFrame:NSInsetRect([[[self window] contentView] 
bounds], [SKSideWindow requiredMargin], 0.0)];
+        [[[self window] contentView] addSubview:pdfSplitView];
         
-        [self applyBackgroundColorAndLevelForWindow:[self window]];
+        [[self window] setBackgroundColor:backgroundColor];
+        [[self window] setLevel:NSNormalWindowLevel];
+        [pdfView setBackgroundColor:backgroundColor];
+        [secondaryPdfView setBackgroundColor:backgroundColor];
+        [self applyPDFSettings:fullScreenSetup];
+        [pdfView layoutDocumentView];
+        [pdfView setNeedsDisplay:YES];
     } else {
-        [self saveNormalSetup];
-        [self goFullScreen];
+        [self fadeInFullScreenWindowWithBackgroundColor:backgroundColor 
level:NSNormalWindowLevel];
+        
+        [pdfView setBackgroundColor:backgroundColor];
+        [secondaryPdfView setBackgroundColor:backgroundColor];
+        [self applyPDFSettings:fullScreenSetup];
+        
+        [self fadeInFullScreenView:pdfSplitView inset:[SKSideWindow 
requiredMargin]];
+        
+        [NSApp addWindowsItem:[self window] title:[self 
windowTitleForDocumentDisplayName:[[self document] displayName]] filename:NO];
     }
     
-    NSDictionary *fullScreenSetup = [[NSUserDefaults standardUserDefaults] 
dictionaryForKey:SKDefaultFullScreenPDFDisplaySettingsKey];
-    if ([fullScreenSetup count])
-        [self applyPDFSettings:fullScreenSetup];
+    [self forceSubwindowsOnTop:YES];
     
-    [pdfView setInteractionMode:SKFullScreenMode screen:screen];
-    [self showSideWindowsOnScreen:screen];
+    [pdfView setInteractionMode:SKFullScreenMode];
+    
+    [self showBlankingWindows];
+    [self showLeftSideWindow];
+    [self showRightSideWindow];
 }
 
 - (IBAction)enterPresentation:(id)sender {
@@ -1441,27 +1463,40 @@
     if (wasInteractionMode == SKPresentationMode)
         return;
     
-    [self enterPresentationMode];
+    NSColor *backgroundColor = [NSColor blackColor];
+    NSInteger level = [[NSUserDefaults standardUserDefaults] 
boolForKey:SKUseNormalLevelForPresentationKey] ? NSNormalWindowLevel : 
NSPopUpMenuWindowLevel;
     
-    NSScreen *screen = [[self window] screen] ?: [NSScreen mainScreen];
-    
     interactionMode = SKPresentationMode;
     
     if (wasInteractionMode == SKFullScreenMode) {
+        [self enterPresentationMode];
+        
         [NSApp updatePresentationOptionsForWindow:[self window]];
         
         [pdfSplitView setFrame:[centerContentView bounds]];
         [centerContentView addSubview:pdfSplitView];
-        [(SKFullScreenWindow *)[self window] setMainView:pdfView];
+        [pdfView setFrame:[[[self window] contentView] bounds]];
+        [[[self window] contentView] addSubview:pdfView];
         
-        [self applyBackgroundColorAndLevelForWindow:[self window]];
+        [[self window] setBackgroundColor:backgroundColor];
+        [[self window] setLevel:level];
+        [pdfView layoutDocumentView];
+        [pdfView setNeedsDisplay:YES];
         
-        [self hideSideWindows];
+        [self forceSubwindowsOnTop:NO];
+        
+        [self hideLeftSideWindow];
+        [self hideRightSideWindow];
+        [self removeBlankingWindows];
     } else {
-        [self goFullScreen];
+        [self fadeInFullScreenWindowWithBackgroundColor:backgroundColor 
level:level];
+        
+        [self enterPresentationMode];
+        
+        [self fadeInFullScreenView:pdfView inset:0.0];
     }
     
-    [pdfView setInteractionMode:SKPresentationMode screen:screen];
+    [pdfView setInteractionMode:SKPresentationMode];
 }
 
 - (IBAction)exitFullScreen:(id)sender {
@@ -1469,37 +1504,32 @@
     if (wasInteractionMode == SKNormalMode)
         return;
     
-    if (wasInteractionMode == SKFullScreenMode)
-        [self hideSideWindows];
+    NSColor *backgroundColor = [[NSUserDefaults standardUserDefaults] 
colorForKey:SKBackgroundColorKey];
+    NSView *view;
+    NSView *contentView;
     
-    if ([[[self window] firstResponder] isDescendantOf:pdfView])
-        [[self window] makeFirstResponder:nil];
+    if (wasInteractionMode == SKFullScreenMode) {
+        view = pdfSplitView;
+        contentView = centerContentView;
+        [self hideLeftSideWindow];
+        [self hideRightSideWindow];
+    } else {
+        view = pdfView;
+        contentView = pdfContentView;
+    }
     
     // do this first, otherwise the navigation window may be covered by 
fadeWindow and then reveiled again, which looks odd
-    [pdfView setInteractionMode:SKNormalMode screen:[[self window] screen]];
+    [pdfView setInteractionMode:SKNormalMode];
     
-    // first fade out the pdfView so we can move the pdfView to the main 
window before it's revealed
-    // 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:mainView];
-    [fadeWindow orderWindow:NSWindowAbove relativeTo:[fullScreenWindow 
windowNumber]];
-    [fadeWindow display];
-    [fullScreenWindow display];
-    [fullScreenWindow setDelegate:nil];
-    [fadeWindow fadeOutBlocking];
-    [fadeWindow release];
+    [self fadeOutFullScreenView:view];
     
     // this should be done before exitPresentationMode to get a smooth 
transition
-    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]];
+    [view setFrame:[contentView bounds]];
+    [contentView addSubview:view];
+    [pdfView setBackgroundColor:backgroundColor];
+    [secondaryPdfView setBackgroundColor:backgroundColor];
     [pdfView layoutDocumentView];
+    [pdfView setNeedsDisplay:YES];
     
     if (wasInteractionMode == SKPresentationMode)
         [self exitPresentationMode];
@@ -1508,29 +1538,14 @@
     
     [self forceSubwindowsOnTop:NO];
     
-    [fullScreenWindow setLevel:NSPopUpMenuWindowLevel];
-    
     interactionMode = SKNormalMode;
     
-    [self setWindow:mainWindow];
-    // trick to make sure the main window shows up in the same space as the 
fullscreen window
-    [fullScreenWindow addChildWindow:mainWindow ordered:NSWindowBelow];
-    [fullScreenWindow removeChildWindow:mainWindow];
-    // these can change due to the child window trick
-    [mainWindow setLevel:NSNormalWindowLevel];
-    [mainWindow setCollectionBehavior:NSWindowCollectionBehaviorDefault];
-    [mainWindow display];
-    [mainWindow makeFirstResponder:pdfView];
-    [mainWindow recalculateKeyViewLoop];
-    [mainWindow setDelegate:self];
-    [mainWindow makeKeyWindow];
-    [fullScreenWindow fadeOut];
+    [self fadeOutFullScreenWindow];
+    
     // the page number may have changed
     [self synchronizeWindowTitleWithDocumentName];
     
-    [blankingWindows makeObjectsPerformSelector:@selector(fadeOut)];
-    [blankingWindows autorelease];
-    blankingWindows = nil;
+    [self removeBlankingWindows];
 }
 
 #pragma mark Swapping tables

Modified: trunk/SKMainWindowController_Actions.m
===================================================================
--- trunk/SKMainWindowController_Actions.m      2010-07-29 09:05:37 UTC (rev 
6661)
+++ trunk/SKMainWindowController_Actions.m      2010-07-30 21:45:16 UTC (rev 
6662)
@@ -848,7 +848,7 @@
         if ([leftSideWindow isVisible])
             [self hideLeftSideWindow];
         else
-            [self showLeftSideWindowOnScreen:[[self window] screen]];
+            [self showLeftSideWindow];
     } else if (mwcFlags.usesDrawers) {
         if ([self leftSidePaneIsOpen]) {
             if (mwcFlags.leftSidePaneState == SKOutlineSidePaneState || 
[[leftSideController.searchField stringValue] length])
@@ -882,7 +882,7 @@
         if ([rightSideWindow isVisible])
             [self hideRightSideWindow];
         else
-            [self showRightSideWindowOnScreen:[[self window] screen]];
+            [self showRightSideWindow];
     } else if (mwcFlags.usesDrawers) {
         if ([self rightSidePaneIsOpen])
             [rightSideDrawer close];

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2010-07-29 09:05:37 UTC (rev 6661)
+++ trunk/SKMainWindowController_UI.m   2010-07-30 21:45:16 UTC (rev 6662)
@@ -252,11 +252,11 @@
         if ([self interactionMode] == SKFullScreenMode) {
             if ([[leftSideWindow screen] isEqual:screen] == NO) {
                 [leftSideWindow remove];
-                [leftSideWindow attachToWindow:[self window] onScreen:screen];
+                [leftSideWindow attachToWindow:[self window]];
             }
             if ([[rightSideWindow screen] isEqual:screen] == NO) {
                 [rightSideWindow remove];
-                [rightSideWindow attachToWindow:[self window] onScreen:screen];
+                [rightSideWindow attachToWindow:[self window]];
             }
         }
         [pdfView layoutDocumentView];
@@ -272,9 +272,9 @@
             [[self window] setFrame:screenFrame display:NO];
             if ([self interactionMode] == SKFullScreenMode) {
                 [leftSideWindow remove];
-                [leftSideWindow attachToWindow:[self window] onScreen:screen];
+                [leftSideWindow attachToWindow:[self window]];
                 [rightSideWindow remove];
-                [rightSideWindow attachToWindow:[self window] onScreen:screen];
+                [rightSideWindow attachToWindow:[self window]];
             }
             [pdfView layoutDocumentView];
             [pdfView setNeedsDisplay:YES];

Modified: trunk/SKNavigationWindow.h
===================================================================
--- trunk/SKNavigationWindow.h  2010-07-29 09:05:37 UTC (rev 6661)
+++ trunk/SKNavigationWindow.h  2010-07-30 21:45:16 UTC (rev 6662)
@@ -48,7 +48,7 @@
     SKNavigationButton *closeButton;
     NSSlider *zoomSlider;
 }
-- (id)initWithPDFView:(SKPDFView *)pdfView hasSlider:(BOOL)hasSlider 
screen:(NSScreen *)screen;
+- (id)initWithPDFView:(SKPDFView *)pdfView hasSlider:(BOOL)hasSlider;
 - (void)handleScaleChangedNotification:(NSNotification *)notification;
 @end
 

Modified: trunk/SKNavigationWindow.m
===================================================================
--- trunk/SKNavigationWindow.m  2010-07-29 09:05:37 UTC (rev 6661)
+++ trunk/SKNavigationWindow.m  2010-07-30 21:45:16 UTC (rev 6662)
@@ -62,9 +62,8 @@
 
 @implementation SKNavigationWindow
 
-- (id)initWithPDFView:(SKPDFView *)pdfView hasSlider:(BOOL)hasSlider 
screen:(NSScreen *)screen {
-    if (screen == nil)
-        screen = [[pdfView window] screen] ?: [NSScreen mainScreen];
+- (id)initWithPDFView:(SKPDFView *)pdfView hasSlider:(BOOL)hasSlider {
+    NSScreen *screen = [[pdfView window] screen] ?: [NSScreen mainScreen];
     CGFloat width = 4 * BUTTON_WIDTH + 2 * SEP_WIDTH + 2 * BUTTON_MARGIN;
     if (hasSlider)
         width += SLIDER_WIDTH;
@@ -73,7 +72,6 @@
         
         [self setDisplaysWhenScreenProfileChanges:YES];
         [self setLevel:[[pdfView window] level]];
-        [self setHidesOnDeactivate:YES];
         [self setMovableByWindowBackground:YES];
         
         [self setContentView:[[[SKNavigationContentView alloc] init] 
autorelease]];

Modified: trunk/SKPDFView.h
===================================================================
--- trunk/SKPDFView.h   2010-07-29 09:05:37 UTC (rev 6661)
+++ trunk/SKPDFView.h   2010-07-30 21:45:16 UTC (rev 6662)
@@ -139,7 +139,7 @@
 @property (nonatomic, retain) SKTypeSelectHelper *typeSelectHelper;
 @property (nonatomic, readonly) NSUndoManager *undoManager;
 
-- (void)setInteractionMode:(SKInteractionMode)newInteractionMode 
screen:(NSScreen *)screen;
+- (void)setInteractionMode:(SKInteractionMode)newInteractionMode;
 - (void)toggleReadingBar;
 
 - (IBAction)delete:(id)sender;

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2010-07-29 09:05:37 UTC (rev 6661)
+++ trunk/SKPDFView.m   2010-07-30 21:45:16 UTC (rev 6662)
@@ -139,7 +139,7 @@
 - (NSRange)visiblePageIndexRange;
 - (NSRect)visibleContentRect;
 
-- (void)enableNavigationForScreen:(NSScreen *)screen;
+- (void)enableNavigation;
 - (void)disableNavigation;
 
 - (void)doAutohide:(BOOL)flag;
@@ -483,7 +483,7 @@
     }
 }
 
-- (void)setInteractionMode:(SKInteractionMode)newInteractionMode 
screen:(NSScreen *)screen {
+- (void)setInteractionMode:(SKInteractionMode)newInteractionMode {
     if (interactionMode != newInteractionMode) {
         if (interactionMode == SKPresentationMode && [[self documentView] 
isHidden])
             [[self documentView] setHidden:NO];
@@ -491,7 +491,7 @@
         if (interactionMode == SKNormalMode)
             [self disableNavigation];
         else
-            [self enableNavigationForScreen:screen];
+            [self enableNavigation];
         [self resetPDFToolTipRects];
     }
 }
@@ -2412,7 +2412,7 @@
     [navWindow remove];
 }
 
-- (void)enableNavigationForScreen:(NSScreen *)screen {
+- (void)enableNavigation {
     navigationMode = [[NSUserDefaults standardUserDefaults] 
integerForKey:interactionMode == SKPresentationMode ? 
SKPresentationNavigationOptionKey : SKFullScreenNavigationOptionKey];
     
     // always recreate the navWindow, since moving between screens of 
different resolution can mess up the location (in spite of moveToScreen:)
@@ -2423,7 +2423,7 @@
         [[NSNotificationCenter defaultCenter] addObserver: self selector: 
@selector(handleWindowWillCloseNotification:) 
                                                      name: 
NSWindowWillCloseNotification object: [self window]];
     }
-    navWindow = [[SKNavigationWindow alloc] initWithPDFView:self 
hasSlider:interactionMode == SKFullScreenMode screen:screen];
+    navWindow = [[SKNavigationWindow alloc] initWithPDFView:self 
hasSlider:interactionMode == SKFullScreenMode];
     
     [self doAutohide:YES];
 }

Modified: trunk/SKSideWindow.h
===================================================================
--- trunk/SKSideWindow.h        2010-07-29 09:05:37 UTC (rev 6661)
+++ trunk/SKSideWindow.h        2010-07-30 21:45:16 UTC (rev 6662)
@@ -54,7 +54,7 @@
     BOOL acceptsMouseOver;
 }
 
-+ (BOOL)isAutoHideEnabled;
++ (CGFloat)requiredMargin;
 
 @property (nonatomic, retain) NSView *mainView;
 @property (nonatomic, readonly) NSRectEdge edge;
@@ -63,7 +63,7 @@
 @property (nonatomic) BOOL acceptsMouseOver;
 
 - (id)initWithMainController:(SKMainWindowController *)aController 
edge:(NSRectEdge)anEdge;
-- (void)attachToWindow:(NSWindow *)window onScreen:(NSScreen *)screen;
+- (void)attachToWindow:(NSWindow *)window;
 - (void)slideIn;
 - (void)slideOut;
 - (void)expand;

Modified: trunk/SKSideWindow.m
===================================================================
--- trunk/SKSideWindow.m        2010-07-29 09:05:37 UTC (rev 6661)
+++ trunk/SKSideWindow.m        2010-07-30 21:45:16 UTC (rev 6662)
@@ -72,8 +72,8 @@
         WINDOW_OFFSET = 0.0;
 }
 
-+ (BOOL)isAutoHideEnabled {
-    return hideWhenClosed != SKClosedSidePanelHide;
++ (CGFloat)requiredMargin {
+    return hideWhenClosed == SKClosedSidePanelHide ? 0.0 : WINDOW_OFFSET + 1.0;
 }
 
 - (id)initWithMainController:(SKMainWindowController *)aController 
edge:(NSRectEdge)anEdge {
@@ -152,9 +152,9 @@
 
 - (BOOL)canBecomeKeyWindow { return YES; }
 
-- (void)attachToWindow:(NSWindow *)window onScreen:(NSScreen *)screen {
+- (void)attachToWindow:(NSWindow *)window {
     NSRect frame, ignored;
-    NSDivideRect([screen frame], &frame, &ignored, WINDOW_OFFSET, edge);
+    NSDivideRect([[window screen] frame], &frame, &ignored, WINDOW_OFFSET, 
edge);
     [self setFrame:NSInsetRect(frame, 0.0, WINDOW_INSET) display:NO];
     state = NSDrawerClosedState;
     if (hideWhenClosed != SKClosedSidePanelCollapse)


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://p.sf.net/sfu/dev2dev-palm
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to