Revision: 5916
          http://skim-app.svn.sourceforge.net/skim-app/?rev=5916&view=rev
Author:   hofman
Date:     2009-10-20 11:42:49 +0000 (Tue, 20 Oct 2009)

Log Message:
-----------
Don't run the runloop while fading out fullscreen pdfview. Do the rest from the 
animation delegate method.

Modified Paths:
--------------
    trunk/SKMainWindowController.m

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2009-10-20 11:20:31 UTC (rev 5915)
+++ trunk/SKMainWindowController.m      2009-10-20 11:42:49 UTC (rev 5916)
@@ -1551,49 +1551,10 @@
     [pdfView setInteractionMode:SKPresentationMode screen:screen];
 }
 
-- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
-    if ([theAnimation isKindOfClass:[CATransition class]]) {
-        mwcFlags.isFadingOut = 0;
-    } else {
-        [fullScreenWindow orderOut:nil];
-        mwcFlags.isChangingFullScreen = 0;
-        [theAnimation setDelegate:nil];
-    }
-}
-
-- (IBAction)exitFullScreen:(id)sender {
-    if ([self isFullScreen] == NO && [self isPresentation] == NO)
-        return;
+- (void)finishExitFullScreen {
+    mwcFlags.isFadingOut = 0;
     
-    mwcFlags.isChangingFullScreen = 1;
-    
-    if ([self isFullScreen])
-        [self hideSideWindows];
-    
-    if ([[fullScreenWindow firstResponder] isDescendantOf:pdfView])
-        [fullScreenWindow makeFirstResponder:nil];
-    
-    NSView *view = [self isFullScreen] ? (NSView *)pdfSplitView : (NSView 
*)pdfView;
-    NSView *contentView = [view superview];
-    NSDate *limitDate = [NSDate dateWithTimeIntervalSinceNow:3.5];
-    NSDate *endDate;
-    CAAnimation *animation = [CATransition animation];
-    
-    // 10.5 has problems animating with a transparent background
-    if ([self isPresentation])
-        [pdfView setBackgroundColor:[NSColor blackColor]];
-    [animation setTimingFunction:[CAMediaTimingFunction 
functionWithName:kCAMediaTimingFunctionEaseIn]];
-    [animation setDuration:0.5];
-    [animation setDelegate:self];
-    [contentView setAnimations:[NSDictionary dictionaryWithObject:animation 
forKey:@"subviews"]];
-    [contentView setWantsLayer:YES];
-    [contentView displayIfNeeded];
-    mwcFlags.isFadingOut = 1;
-    endDate = [NSDate dateWithTimeIntervalSinceNow:0.5];
-    [[view animator] removeFromSuperview];
-    while (mwcFlags.isFadingOut && [limitDate compare:[NSDate date]] != 
NSOrderedAscending)
-        [[NSRunLoop currentRunLoop] runUntilDate:endDate];
-    mwcFlags.isFadingOut = 0;
+    NSView *contentView = [fullScreenWindow contentView];
     [contentView setWantsLayer:NO];
     [contentView setAnimations:nil];
     
@@ -1602,11 +1563,13 @@
     if ([self isFullScreen]) {
         [pdfSplitView setFrame:[pdfContentView bounds]];
         [pdfContentView addSubview:pdfSplitView];
+        [pdfSplitView release];
         [pdfEdgeView setEdges:BDSKMinXEdgeMask | BDSKMaxXEdgeMask | 
BDSKMinYEdgeMask];
         [secondaryPdfEdgeView setEdges:BDSKEveryEdgeMask];
     } else {
         [pdfView setFrame:[[pdfEdgeView contentView] bounds]];
         [pdfEdgeView addSubview:pdfView]; 
+        [pdfView release];
     }
     [pdfView setBackgroundColor:[[NSUserDefaults standardUserDefaults] 
colorForKey:SKBackgroundColorKey]];
     [secondaryPdfView setBackgroundColor:[[NSUserDefaults 
standardUserDefaults] colorForKey:SKBackgroundColorKey]];
@@ -1640,6 +1603,46 @@
     [blankingWindows makeObjectsPerformSelector:@selector(fadeOut)];
 }
 
+- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
+    if ([theAnimation isKindOfClass:[CATransition class]]) {
+        [self finishExitFullScreen];
+    } else {
+        [fullScreenWindow orderOut:nil];
+        mwcFlags.isChangingFullScreen = 0;
+        [theAnimation setDelegate:nil];
+    }
+}
+
+- (IBAction)exitFullScreen:(id)sender {
+    if ([self isFullScreen] == NO && [self isPresentation] == NO)
+        return;
+    
+    mwcFlags.isChangingFullScreen = 1;
+    
+    if ([self isFullScreen])
+        [self hideSideWindows];
+    
+    if ([[fullScreenWindow firstResponder] isDescendantOf:pdfView])
+        [fullScreenWindow makeFirstResponder:nil];
+    
+    NSView *view = [self isFullScreen] ? (NSView *)pdfSplitView : (NSView 
*)pdfView;
+    NSView *contentView = [view superview]; // this should be 
[fullScreenWindow contentView]
+    CAAnimation *animation = [CATransition animation];
+    
+    // 10.5 has problems animating with a transparent background
+    if ([self isPresentation])
+        [pdfView setBackgroundColor:[NSColor blackColor]];
+    [animation setTimingFunction:[CAMediaTimingFunction 
functionWithName:kCAMediaTimingFunctionEaseIn]];
+    [animation setDuration:0.5];
+    [animation setDelegate:self];
+    [contentView setAnimations:[NSDictionary dictionaryWithObject:animation 
forKey:@"subviews"]];
+    [contentView setWantsLayer:YES];
+    [contentView displayIfNeeded];
+    [view retain];
+    mwcFlags.isFadingOut = 1;
+    [[view animator] removeFromSuperview];
+}
+
 #pragma mark Swapping tables
 
 - (void)finishTableAnimation:(NSDictionary *)info {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to