Revision: 5920
http://skim-app.svn.sourceforge.net/skim-app/?rev=5920&view=rev
Author: hofman
Date: 2009-10-21 13:59:19 +0000 (Wed, 21 Oct 2009)
Log Message:
-----------
Revert fadeout of fullscreen pdfview using core animation, and go back to using
NSViewAnimation and a separate fullscreen window. On some hardware using core
animation to fade out a PDFView with a large PDF the system seriously runs out
of memory space. Conclusion: PDFView and Core Animation don't go together.
Modified Paths:
--------------
trunk/SKFullScreenWindow.h
trunk/SKFullScreenWindow.m
trunk/SKMainWindowController.h
trunk/SKMainWindowController.m
trunk/SKMainWindowController_UI.m
Modified: trunk/SKFullScreenWindow.h
===================================================================
--- trunk/SKFullScreenWindow.h 2009-10-20 21:03:09 UTC (rev 5919)
+++ trunk/SKFullScreenWindow.h 2009-10-21 13:59:19 UTC (rev 5920)
@@ -40,13 +40,16 @@
#import "SKMainWindow.h"
-...@interface SKFullScreenWindow : SKMainWindow
+...@interface SKFullScreenWindow : SKMainWindow {
+ NSViewAnimation *animation;
+}
- (id)initWithScreen:(NSScreen *)screen;
- (NSView *)mainView;
- (void)setMainView:(NSView *)view;
+- (void)fadeOutBlocking;
- (void)fadeOut;
@end
Modified: trunk/SKFullScreenWindow.m
===================================================================
--- trunk/SKFullScreenWindow.m 2009-10-20 21:03:09 UTC (rev 5919)
+++ trunk/SKFullScreenWindow.m 2009-10-21 13:59:19 UTC (rev 5920)
@@ -53,14 +53,25 @@
[self setAcceptsMouseMovedEvents:YES];
[self setBackgroundColor:[NSColor blackColor]];
[self
setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
- CAAnimation *animation = [CABasicAnimation animation];
- [animation setDuration:FADEOUT_DURATION];
- [animation setTimingFunction:[CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseOut]];
- [self setAnimations:[NSDictionary
dictionaryWithObjectsAndKeys:animation, @"alphaValue", nil]];
+ CAAnimation *alphaAnimation = [CABasicAnimation animation];
+ [alphaAnimation setDuration:FADEOUT_DURATION];
+ [alphaAnimation setTimingFunction:[CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
+ [self setAnimations:[NSDictionary
dictionaryWithObjectsAndKeys:alphaAnimation, @"alphaValue", nil]];
}
return self;
}
+- (void)stopAnimation {
+ [animation stopAnimation];
+ [animation release];
+ animation = nil;
+}
+
+- (void)dealloc {
+ [self stopAnimation];
+ [super dealloc];
+}
+
- (BOOL)canBecomeKeyWindow { return YES; }
- (BOOL)canBecomeMainWindow { return YES; }
@@ -102,20 +113,49 @@
}
- (void)orderFront:(id)sender {
+ [self stopAnimation];
[self setAlphaValue:1.0];
[super orderFront:sender];
}
- (void)makeKeyAndOrderFront:(id)sender {
+ [self stopAnimation];
[self setAlphaValue:1.0];
[super makeKeyAndOrderFront:sender];
}
- (void)orderOut:(id)sender {
+ [self stopAnimation];
[super orderOut:sender];
[self setAlphaValue:1.0];
}
+- (void)fadeOutBlocking {
+ NSDictionary *fadeOutDict = [[NSDictionary alloc]
initWithObjectsAndKeys:self, NSViewAnimationTargetKey,
NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey, nil];
+ animation = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray
arrayWithObjects:fadeOutDict, nil]];
+ [fadeOutDict release];
+
+ [animation setAnimationBlockingMode:NSAnimationBlocking];
+ [animation setAnimationCurve:NSAnimationEaseIn];
+ [animation setDuration:FADEOUT_DURATION];
+ [animation setDelegate:self];
+ [animation startAnimation];
+}
+
+- (void)animationDidEnd:(NSAnimation *)anAnimation {
+ [animation release];
+ animation = nil;
+ [self orderOut:nil];
+ [self setAlphaValue:1.0];
+}
+
+- (void)animationDidStop:(NSAnimation *)anAnimation {
+ [animation release];
+ animation = nil;
+ [self orderOut:nil];
+ [self setAlphaValue:1.0];
+}
+
- (void)fadeOut {
[[self animator] setAlphaValue:0.0];
[self performSelector:@selector(orderOut:) withObject:nil
afterDelay:FADEOUT_DURATION];
Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h 2009-10-20 21:03:09 UTC (rev 5919)
+++ trunk/SKMainWindowController.h 2009-10-21 13:59:19 UTC (rev 5920)
@@ -236,7 +236,6 @@
unsigned int updatingOutlineSelection:1;
unsigned int updatingThumbnailSelection:1;
unsigned int isAnimating:1;
- unsigned int isChangingFullScreen:1;
unsigned int findPanelFind:1;
unsigned int caseInsensitiveSearch:1;
unsigned int wholeWordSearch:1;
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2009-10-20 21:03:09 UTC (rev 5919)
+++ trunk/SKMainWindowController.m 2009-10-21 13:59:19 UTC (rev 5920)
@@ -233,7 +233,6 @@
markedPageIndex = NSNotFound;
beforeMarkedPageIndex = NSNotFound;
mwcFlags.isAnimating = 0;
- mwcFlags.isChangingFullScreen = 0;
mwcFlags.updatingColor = 0;
mwcFlags.updatingFont = 0;
mwcFlags.updatingLine = 0;
@@ -1491,7 +1490,7 @@
}
- (IBAction)enterFullScreen:(id)sender {
- if ([self isFullScreen] || mwcFlags.isChangingFullScreen)
+ if ([self isFullScreen])
return;
NSScreen *screen = [[self window] screen] ?: [NSScreen mainScreen]; // @@
screen: or should we use the main screen?
@@ -1527,7 +1526,7 @@
}
- (IBAction)enterPresentation:(id)sender {
- if ([self isPresentation] || mwcFlags.isChangingFullScreen)
+ if ([self isPresentation])
return;
BOOL wasFullScreen = [self isFullScreen];
@@ -1554,11 +1553,23 @@
[pdfView setInteractionMode:SKPresentationMode screen:screen];
}
-- (void)finishExitFullScreen {
- NSView *contentView = [fullScreenWindow contentView];
- [contentView setWantsLayer:NO];
- [contentView setAnimations:nil];
+- (IBAction)exitFullScreen:(id)sender {
+ if ([self isFullScreen] == NO && [self isPresentation] == NO)
+ return;
+ if ([self isFullScreen])
+ [self hideSideWindows];
+
+ if ([[fullScreenWindow firstResponder] isDescendantOf:pdfView])
+ [fullScreenWindow makeFirstResponder:nil];
+
+ SKFullScreenWindow *bgWindow = [[SKFullScreenWindow alloc]
initWithScreen:[fullScreenWindow screen]];
+ [bgWindow setBackgroundColor:[fullScreenWindow backgroundColor]];
+ [bgWindow setLevel:[fullScreenWindow level]];
+ [bgWindow orderWindow:NSWindowBelow relativeTo:[fullScreenWindow
windowNumber]];
+ [fullScreenWindow setDelegate:nil];
+ [fullScreenWindow fadeOutBlocking];
+
[pdfView setInteractionMode:SKNormalMode screen:[[self window] screen]];
// this should be done before exitPresentationMode to get a smooth
transition
if ([self isFullScreen]) {
@@ -1579,21 +1590,26 @@
else
[self applyPDFSettings:savedNormalSetup];
+ [fullScreenWindow orderWindow:NSWindowBelow relativeTo:[bgWindow
windowNumber]];
+ [fullScreenWindow displayIfNeeded];
+ [bgWindow orderOut:nil];
+ [bgWindow release];
[fullScreenWindow setLevel:NSPopUpMenuWindowLevel];
SetSystemUIMode(kUIModeNormal, 0);
- for (NSWindowController *wc in [[self document] windowControllers]) {
+ NSEnumerator *wcEnum = [[[self document] windowControllers]
objectEnumerator];
+ NSWindowController *wc = [wcEnum nextObject];
+
+ while (wc = [wcEnum nextObject]) {
if ([wc isNoteWindowController] || [wc isSnapshotWindowController])
[(id)wc setForceOnTop:NO];
}
- [fullScreenWindow setDelegate:nil];
[self setWindow:mainWindow];
[mainWindow orderWindow:NSWindowBelow relativeTo:[fullScreenWindow
windowNumber]];
[mainWindow display];
- [[[fullScreenWindow animations] valueForKey:@"alphaValue"]
setDelegate:self];
- [[fullScreenWindow animator] setAlphaValue:0.0];
+ [fullScreenWindow fadeOut];
[mainWindow makeFirstResponder:pdfView];
[mainWindow recalculateKeyViewLoop];
[mainWindow setDelegate:self];
@@ -1602,44 +1618,6 @@
[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 animator] removeFromSuperview];
-}
-
#pragma mark Swapping tables
- (void)finishTableAnimation:(NSDictionary *)info {
Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m 2009-10-20 21:03:09 UTC (rev 5919)
+++ trunk/SKMainWindowController_UI.m 2009-10-21 13:59:19 UTC (rev 5920)
@@ -242,9 +242,6 @@
if ((mwcFlags.isEditingPDF || mwcFlags.isEditingTable) && [self
commitEditing] == NO)
[self discardEditing];
- [fullScreenWindow orderOut:nil];
- [blankingWindows makeObjectsPerformSelector:@selector(orderOut:)
withObject:nil];
-
[ownerController setContent:nil];
}
}
@@ -1469,13 +1466,13 @@
[menuItem setTitle:NSLocalizedString(@"Remove Full Screen", @"Menu
item title")];
else
[menuItem setTitle:NSLocalizedString(@"Full Screen", @"Menu item
title")];
- return [[self pdfDocument] isLocked] == NO &&
mwcFlags.isChangingFullScreen == 0;
+ return [[self pdfDocument] isLocked] == NO;
} else if (action == @selector(togglePresentation:)) {
if ([self isPresentation])
[menuItem setTitle:NSLocalizedString(@"Remove Presentation",
@"Menu item title")];
else
[menuItem setTitle:NSLocalizedString(@"Presentation", @"Menu item
title")];
- return [[self pdfDocument] isLocked] == NO &&
mwcFlags.isChangingFullScreen == 0;
+ return [[self pdfDocument] isLocked] == NO;
} else if (action == @selector(getInfo:)) {
return [self isPresentation] == NO;
} else if (action == @selector(performFit:)) {
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