Revision: 3471
http://skim-app.svn.sourceforge.net/skim-app/?rev=3471&view=rev
Author: hofman
Date: 2008-03-13 16:05:58 -0700 (Thu, 13 Mar 2008)
Log Message:
-----------
Move fading animations of some borderless windows to a common superclass.
Modified Paths:
--------------
trunk/SKApplicationController.m
trunk/SKMainWindowController.m
trunk/SKNavigationWindow.h
trunk/SKNavigationWindow.m
trunk/SKPDFHoverWindow.h
trunk/SKPDFHoverWindow.m
trunk/SKPDFView.m
trunk/SKRemoteStateWindow.h
trunk/SKRemoteStateWindow.m
trunk/Skim.xcodeproj/project.pbxproj
Added Paths:
-----------
trunk/SKAnimatedBorderlessWindow.h
trunk/SKAnimatedBorderlessWindow.m
Added: trunk/SKAnimatedBorderlessWindow.h
===================================================================
--- trunk/SKAnimatedBorderlessWindow.h (rev 0)
+++ trunk/SKAnimatedBorderlessWindow.h 2008-03-13 23:05:58 UTC (rev 3471)
@@ -0,0 +1,68 @@
+//
+// SKAnimatedBorderlessWindow.h
+// Skim
+//
+// Created by Christiaan Hofman on 3/13/08.
+/*
+ This software is Copyright (c) 2008
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+
[EMAIL PROTECTED] SKAnimatedBorderlessWindow : NSWindow {
+ NSViewAnimation *animation;
+ NSTimer *timer;
+}
+
+- (id)initWithContentRect:(NSRect)contentRect screen:(NSScreen *)screen;
+- (id)initWithContentRect:(NSRect)contentRect;
+
+- (void)willClose;
+
+- (float)defaultAlphaValue;
+
+- (NSTimeInterval)fadeInDuration;
+- (NSTimeInterval)fadeOutDuration;
+- (NSTimeInterval)autoHideTimeInterval;
+
+- (void)fadeIn;
+- (void)fadeOut;
+
+- (void)orderOut:(id)sender;
+- (void)orderFront:(id)sender;
+- (void)orderFrontRegardless;
+
+- (void)stopAnimation;
+- (void)cancelDelayedAnimations;
+
[EMAIL PROTECTED]
Added: trunk/SKAnimatedBorderlessWindow.m
===================================================================
--- trunk/SKAnimatedBorderlessWindow.m (rev 0)
+++ trunk/SKAnimatedBorderlessWindow.m 2008-03-13 23:05:58 UTC (rev 3471)
@@ -0,0 +1,165 @@
+//
+// SKAnimatedBorderlessWindow.m
+// Skim
+//
+// Created by Christiaan Hofman on 3/13/08.
+/*
+ This software is Copyright (c) 2008
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "SKAnimatedBorderlessWindow.h"
+
+
[EMAIL PROTECTED] SKAnimatedBorderlessWindow
+
+- (id)initWithContentRect:(NSRect)contentRect screen:(NSScreen *)screen {
+ if (self = [super initWithContentRect:contentRect
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO
screen:screen]) {
+ [self setBackgroundColor:[NSColor clearColor]];
+ [self setOpaque:NO];
+ [self setAlphaValue:[self defaultAlphaValue]];
+ [self setReleasedWhenClosed:NO];
+ }
+ return self;
+}
+
+- (id)initWithContentRect:(NSRect)contentRect {
+ return [self initWithContentRect:contentRect screen:nil];
+}
+
+- (void)dealloc {
+ [self stopAnimation];
+ [super dealloc];
+}
+
+- (BOOL)canBecomeKeyWindow { return NO; }
+
+- (BOOL)canBecomeMainWindow { return NO; }
+
+- (void)willClose {}
+
+- (float)defaultAlphaValue { return 1.0; }
+
+- (NSTimeInterval)fadeInDuration { return 0.3; }
+
+- (NSTimeInterval)fadeOutDuration { return 1.0; }
+
+- (NSTimeInterval)autoHideTimeInterval { return 0.0; }
+
+- (void)stopAnimation {
+ [self cancelDelayedAnimations];
+ [animation stopAnimation];
+ [animation release];
+ animation = nil;
+}
+
+- (void)cancelDelayedAnimations {
+ [[self class] cancelPreviousPerformRequestsWithTarget:self
selector:@selector(fadeOut) object:nil];
+}
+
+- (void)fadeOutAfterTimeout {
+ NSTimeInterval autoHideTimeInterval = [self autoHideTimeInterval];
+ if (autoHideTimeInterval > 0.0)
+ [self performSelector:@selector(fadeOut) withObject:nil
afterDelay:autoHideTimeInterval];
+}
+
+- (void)orderFront:(id)sender {
+ [self stopAnimation];
+ [self setAlphaValue:[self defaultAlphaValue]];
+ [super orderFront:sender];
+ [self fadeOutAfterTimeout];
+}
+
+- (void)orderFrontRegardless {
+ [self stopAnimation];
+ [self setAlphaValue:[self defaultAlphaValue]];
+ [super orderFrontRegardless];
+ [self fadeOutAfterTimeout];
+}
+
+- (void)orderOut:(id)sender {
+ [self stopAnimation];
+ [self willClose];
+ [super orderOut:sender];
+ [self setAlphaValue:[self defaultAlphaValue]];
+}
+
+- (void)fadeOut {
+ [self stopAnimation];
+
+ [self setAlphaValue:[self defaultAlphaValue]];
+ [self willClose];
+
+ NSDictionary *fadeOutDict = [[NSDictionary alloc]
initWithObjectsAndKeys:self, NSViewAnimationTargetKey,
NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey, nil];
+
+ animation = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray
arrayWithObjects:fadeOutDict, nil]];
+ [fadeOutDict release];
+
+ [animation setAnimationBlockingMode:NSAnimationNonblocking];
+ [animation setDuration:[self fadeOutDuration]];
+ [animation setDelegate:self];
+ [animation startAnimation];
+}
+
+- (void)fadeIn {
+ [self stopAnimation];
+
+ NSDictionary *fadeInDict = [[NSDictionary alloc]
initWithObjectsAndKeys:self, NSViewAnimationTargetKey,
NSViewAnimationFadeInEffect, NSViewAnimationEffectKey, nil];
+
+ animation = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray
arrayWithObjects:fadeInDict, nil]];
+ [fadeInDict release];
+
+ [self setAlphaValue:0.0];
+ [super orderFront:self];
+
+ [animation setAnimationBlockingMode:NSAnimationNonblocking];
+ [animation setDuration:[self fadeInDuration]];
+ [animation setDelegate:self];
+ [animation startAnimation];
+ [self fadeOutAfterTimeout];
+}
+
+- (void)animationDidEnd:(NSAnimation*)anAnimation {
+ BOOL isFadeOut = [[[[animation viewAnimations] lastObject]
objectForKey:NSViewAnimationEffectKey] isEqual:NSViewAnimationFadeOutEffect];
+ [animation release];
+ animation = nil;
+ if (isFadeOut)
+ [self orderOut:self];
+ [self setAlphaValue:[self defaultAlphaValue]];
+}
+
+- (void)animationDidStop:(NSAnimation*)anAnimation {
+ [animation release];
+ animation = nil;
+ [self setAlphaValue:[self defaultAlphaValue]];
+}
+
[EMAIL PROTECTED]
Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m 2008-03-13 01:06:17 UTC (rev 3470)
+++ trunk/SKApplicationController.m 2008-03-13 23:05:58 UTC (rev 3471)
@@ -378,12 +378,11 @@
break;
case kRemoteButtonMenu:
remoteScrolling = !remoteScrolling;
- float timeout = [[NSUserDefaults standardUserDefaults]
floatForKey:SKAppleRemoteSwitchIndicationTimeoutKey];
- if (timeout > 0.0) {
+ if ([[NSUserDefaults standardUserDefaults]
floatForKey:SKAppleRemoteSwitchIndicationTimeoutKey] > 0.0) {
NSRect rect = [[controller window] frame];
NSPoint point = NSMakePoint(NSMidX(rect), NSMidY(rect));
int type = remoteScrolling ? SKRemoteStateScroll :
SKRemoteStateResize;
- [SKRemoteStateWindow showWithType:type atPoint:point
timeout:timeout];
+ [SKRemoteStateWindow showWithType:type atPoint:point];
}
break;
default:
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2008-03-13 01:06:17 UTC (rev 3470)
+++ trunk/SKMainWindowController.m 2008-03-13 23:05:58 UTC (rev 3471)
@@ -2099,7 +2099,7 @@
- (IBAction)toggleLeftSidePane:(id)sender {
if ([self isFullScreen]) {
- [[SKPDFHoverWindow sharedHoverWindow] hide];
+ [[SKPDFHoverWindow sharedHoverWindow] fadeOut];
if ([self leftSidePaneIsOpen])
[leftSideWindow collapse];
else
@@ -2112,7 +2112,7 @@
} else if (usesDrawers) {
if ([self leftSidePaneIsOpen]) {
if (leftSidePaneState == SKOutlineSidePaneState || [[searchField
stringValue] length])
- [[SKPDFHoverWindow sharedHoverWindow] hide];
+ [[SKPDFHoverWindow sharedHoverWindow] fadeOut];
[leftSideDrawer close];
} else {
[leftSideDrawer openOnEdge:NSMinXEdge];
@@ -2123,7 +2123,7 @@
if ([self leftSidePaneIsOpen]) {
if (leftSidePaneState == SKOutlineSidePaneState || [[searchField
stringValue] length])
- [[SKPDFHoverWindow sharedHoverWindow] hide];
+ [[SKPDFHoverWindow sharedHoverWindow] fadeOut];
lastLeftSidePaneWidth = NSWidth(sideFrame); // cache this
pdfFrame.size.width += lastLeftSidePaneWidth;
sideFrame.size.width = 0.0;
@@ -3954,7 +3954,7 @@
- (void)outlineView:(NSOutlineView *)ov mouseExitedTableColumn:(NSTableColumn
*)aTableColumn item:(id)item {
if ([ov isEqual:outlineView]) {
- [[SKPDFHoverWindow sharedHoverWindow] hide];
+ [[SKPDFHoverWindow sharedHoverWindow] fadeOut];
}
}
@@ -4211,9 +4211,9 @@
- (void)tableView:(NSTableView *)tv mouseExitedTableColumn:(NSTableColumn
*)aTableColumn row:(int)row {
if ([tv isEqual:findTableView]) {
- [[SKPDFHoverWindow sharedHoverWindow] hide];
+ [[SKPDFHoverWindow sharedHoverWindow] fadeOut];
} else if ([tv isEqual:groupedFindTableView]) {
- [[SKPDFHoverWindow sharedHoverWindow] hide];
+ [[SKPDFHoverWindow sharedHoverWindow] fadeOut];
}
}
Modified: trunk/SKNavigationWindow.h
===================================================================
--- trunk/SKNavigationWindow.h 2008-03-13 01:06:17 UTC (rev 3470)
+++ trunk/SKNavigationWindow.h 2008-03-13 23:05:58 UTC (rev 3471)
@@ -37,16 +37,15 @@
*/
#import <Cocoa/Cocoa.h>
+#import "SKAnimatedBorderlessWindow.h"
@class PDFView, SKNavigationToolTipView, SKNavigationButton;
[EMAIL PROTECTED] SKNavigationWindow : NSWindow {
[EMAIL PROTECTED] SKNavigationWindow : SKAnimatedBorderlessWindow {
NSMutableArray *buttons;
- NSViewAnimation *animation;
}
- (id)initWithPDFView:(PDFView *)pdfView;
- (void)moveToScreen:(NSScreen *)screen;
-- (void)hide;
@end
Modified: trunk/SKNavigationWindow.m
===================================================================
--- trunk/SKNavigationWindow.m 2008-03-13 01:06:17 UTC (rev 3470)
+++ trunk/SKNavigationWindow.m 2008-03-13 23:05:58 UTC (rev 3471)
@@ -57,13 +57,10 @@
screen = [NSScreen mainScreen];
float width = 4 * BUTTON_WIDTH + 2 * SEP_WIDTH + 2 * MARGIN;
NSRect contentRect = NSMakeRect(NSMidX([screen frame]) - 0.5 * width,
NSMinY([screen frame]) + OFFSET, width, BUTTON_WIDTH + 2 * MARGIN);
- if (self = [super initWithContentRect:contentRect
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO
screen:screen]) {
+ if (self = [super initWithContentRect:contentRect screen:screen]) {
NSWindowController *controller = [[pdfView window] windowController];
- [self setBackgroundColor:[NSColor clearColor]];
- [self setOpaque:NO];
[self setDisplaysWhenScreenProfileChanges:YES];
- [self setReleasedWhenClosed:NO];
[self setLevel:[[pdfView window] level]];
[self setHidesOnDeactivate:YES];
[self setMovableByWindowBackground:YES];
@@ -117,15 +114,6 @@
return self;
}
-- (void)dealloc {
- [animation stopAnimation];
- [super dealloc];
-}
-
-- (BOOL)canBecomeKeyWindow { return NO; }
-
-- (BOOL)canBecomeMainWindow { return NO; }
-
- (void)moveToScreen:(NSScreen *)screen {
NSRect winFrame = [self frame];
winFrame.origin.x = NSMidX([screen frame]) - 0.5 * NSWidth(winFrame);
@@ -133,44 +121,11 @@
[self setFrame:winFrame display:NO];
}
-- (void)orderFront:(id)sender {
- [animation stopAnimation];
- [super orderFront:sender];
-}
-
- (void)orderOut:(id)sender {
- [animation stopAnimation];
- [[SKNavigationToolTipWindow sharedToolTipWindow] orderOut:self];
[super orderOut:sender];
+ [[SKNavigationToolTipWindow sharedToolTipWindow] orderOut:self];
}
-- (void)hide {
- [animation stopAnimation];
-
- NSDictionary *fadeOutDict = [[NSDictionary alloc]
initWithObjectsAndKeys:self, NSViewAnimationTargetKey,
NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey, nil];
-
- animation = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray
arrayWithObjects:fadeOutDict, nil]];
- [fadeOutDict release];
-
- [animation setAnimationBlockingMode:NSAnimationNonblocking];
- [animation setDuration:1.0];
- [animation setDelegate:self];
- [animation startAnimation];
-}
-
-- (void)animationDidEnd:(NSAnimation*)anAnimation {
- [animation release];
- animation = nil;
- [self orderOut:self];
- [self setAlphaValue:1.0];
-}
-
-- (void)animationDidStop:(NSAnimation*)anAnimation {
- [animation release];
- animation = nil;
- [self setAlphaValue:1.0];
-}
-
@end
Modified: trunk/SKPDFHoverWindow.h
===================================================================
--- trunk/SKPDFHoverWindow.h 2008-03-13 01:06:17 UTC (rev 3470)
+++ trunk/SKPDFHoverWindow.h 2008-03-13 23:05:58 UTC (rev 3471)
@@ -37,24 +37,22 @@
*/
#import <Cocoa/Cocoa.h>
+#import "SKAnimatedBorderlessWindow.h"
@class PDFAnnotation;
[EMAIL PROTECTED] SKPDFHoverWindow : NSPanel {
[EMAIL PROTECTED] SKPDFHoverWindow : SKAnimatedBorderlessWindow {
NSFont *font;
NSColor *backgroundColor;
NSFont *labelFont;
NSColor *labelColor;
PDFAnnotation *annotation;
NSPoint point;
- NSViewAnimation *animation;
- NSTimer *timer;
}
+ (id)sharedHoverWindow;
- (void)showForAnnotation:(PDFAnnotation *)annotation atPoint:(NSPoint)aPoint;
-- (void)hide;
- (void)handleApplicationWillResignActiveNotification:(NSNotification
*)notification;
Modified: trunk/SKPDFHoverWindow.m
===================================================================
--- trunk/SKPDFHoverWindow.m 2008-03-13 01:06:17 UTC (rev 3470)
+++ trunk/SKPDFHoverWindow.m 2008-03-13 23:05:58 UTC (rev 3471)
@@ -68,14 +68,13 @@
}
- (id)init {
- if (self = [super initWithContentRect:NSZeroRect
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) {
+ if (self = [super initWithContentRect:NSZeroRect]) {
[self setHidesOnDeactivate:NO];
[self setIgnoresMouseEvents:YES];
+ [self setOpaque:YES];
[self setBackgroundColor:[NSColor whiteColor]];
[self setHasShadow:YES];
- [self setReleasedWhenClosed:NO];
[self setLevel:NSStatusWindowLevel];
- [self setAlphaValue:ALPHA_VALUE];
NSImageView *imageView = [[NSImageView alloc] init];
[imageView setImageFrameStyle:NSImageFrameNone];
@@ -89,8 +88,6 @@
annotation = nil;
point = NSZeroPoint;
- animation = nil;
- timer = nil;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleApplicationWillResignActiveNotification:)
name:NSApplicationWillResignActiveNotification object:NSApp];
@@ -151,43 +148,21 @@
}
- (void)handleApplicationWillResignActiveNotification:(NSNotification
*)notification {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
[self orderOut:self];
}
-- (void)stopTimer {
- [timer invalidate];
- [timer release];
- timer = nil;
-}
+- (float)defaultAlphaValue { return 0.95; }
-- (BOOL)canBecomeKeyWindow { return NO; }
+- (NSTimeInterval)autoHideTimeInterval { return 7.0; }
-- (BOOL)canBecomeMainWindow { return NO; }
-
-- (void)orderFront:(id)sender {
- [self stopTimer];
- [animation stopAnimation];
- [self setAlphaValue:ALPHA_VALUE];
- [super orderFront:sender];
-}
-
-- (void)orderOut:(id)sender {
- [self stopTimer];
- [animation stopAnimation];
- [self setAlphaValue:ALPHA_VALUE];
+- (void)willClose {
[annotation release];
annotation = nil;
point = NSZeroPoint;
- [super orderOut:sender];
}
-- (void)hideWithTimer:(NSTimer *)aTimer {
- [self stopTimer];
- [animation stopAnimation];
- [self hide];
-}
-
-- (void)showWithTimer:(NSTimer *)aTimer {
+- (void)showDelayed {
NSUserDefaults *sud = [NSUserDefaults standardUserDefaults];
NSPoint thePoint = NSEqualPoints(point, NSZeroPoint) ? [NSEvent
mouseLocation] : point;
NSRect contentRect = NSMakeRect(thePoint.x, thePoint.y - WINDOW_OFFSET,
[sud floatForKey:SKToolTipWidthKey], [sud floatForKey:SKToolTipHeightKey]);
@@ -196,7 +171,7 @@
NSString *string = nil;
NSColor *color = nil;
- [self stopTimer];
+ [self cancelDelayedAnimations];
if ([[annotation type] isEqualToString:SKLinkString]) {
@@ -329,87 +304,40 @@
[[imageView enclosingScrollView] setBackgroundColor:color];
- [animation stopAnimation];
- if ([self isVisible] && [self alphaValue] > 0.9) {
+ [self stopAnimation];
+ if ([self isVisible] && [self alphaValue] > 0.9)
[self orderFront:self];
- } else {
- NSDictionary *fadeInDict = [[NSDictionary alloc]
initWithObjectsAndKeys:self, NSViewAnimationTargetKey,
NSViewAnimationFadeInEffect, NSViewAnimationEffectKey, nil];
-
- animation = [[NSViewAnimation alloc]
initWithViewAnimations:[NSArray arrayWithObjects:fadeInDict, nil]];
- [fadeInDict release];
-
- [self setAlphaValue:0.0];
- [super orderFront:self];
-
- [animation setAnimationBlockingMode:NSAnimationNonblocking];
- [animation setDuration:0.3];
- [animation setDelegate:self];
- [animation startAnimation];
- }
+ else
+ [self fadeIn];
- timer = [[NSTimer scheduledTimerWithTimeInterval:7.0 target:self
selector:@selector(hideWithTimer:) userInfo:NULL repeats:NO] retain];
-
} else {
- [self hide];
+ [self fadeOut];
}
}
+- (void)cancelDelayedAnimations {
+ [super cancelDelayedAnimations];
+ [[self class] cancelPreviousPerformRequestsWithTarget:self
selector:@selector(showDelayed) object:nil];
+}
+
- (void)showForAnnotation:(PDFAnnotation *)note atPoint:(NSPoint)aPoint {
point = aPoint;
if ([note isEqual:annotation] == NO) {
- [self stopTimer];
+ [self cancelDelayedAnimations];
if ([self isVisible] && [self alphaValue] > 0.9)
- [animation stopAnimation];
+ [self stopAnimation];
[annotation release];
annotation = [note retain];
- NSDate *date = [NSDate dateWithTimeIntervalSinceNow:[self isVisible] ?
0.1 : 1.0];
- timer = [[NSTimer alloc] initWithFireDate:date interval:0 target:self
selector:@selector(showWithTimer:) userInfo:NULL repeats:NO];
- [[NSRunLoop currentRunLoop] addTimer:timer
forMode:NSDefaultRunLoopMode];
+ [self performSelector:@selector(showDelayed) withObject:nil
afterDelay:[self isVisible] ? 0.1 : 1.0];
}
}
-- (void)hide {
- if (annotation == nil)
- return;
-
- [self stopTimer];
- [animation stopAnimation];
-
- [annotation release];
- annotation = nil;
- point = NSZeroPoint;
-
- NSDictionary *fadeOutDict = [[NSDictionary alloc]
initWithObjectsAndKeys:self, NSViewAnimationTargetKey,
NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey, nil];
-
- animation = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray
arrayWithObjects:fadeOutDict, nil]];
- [fadeOutDict release];
-
- [animation setAnimationBlockingMode:NSAnimationNonblocking];
- [animation setDuration:1.0];
- [animation setDelegate:self];
- [animation startAnimation];
-}
-
-- (void)animationDidEnd:(NSAnimation*)anAnimation {
- BOOL isFadeOut = [[[[animation viewAnimations] lastObject]
objectForKey:NSViewAnimationEffectKey] isEqual:NSViewAnimationFadeOutEffect];
- [animation release];
- animation = nil;
- if (isFadeOut)
- [self orderOut:self];
- [self setAlphaValue:ALPHA_VALUE];
-}
-
-- (void)animationDidStop:(NSAnimation*)anAnimation {
- [animation release];
- animation = nil;
-}
-
@end
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2008-03-13 01:06:17 UTC (rev 3470)
+++ trunk/SKPDFView.m 2008-03-13 23:05:58 UTC (rev 3471)
@@ -1159,7 +1159,7 @@
[super mouseMoved:theEvent];
if ([[activeAnnotation type] isEqualToString:SKLinkString]) {
- [[SKPDFHoverWindow sharedHoverWindow] hide];
+ [[SKPDFHoverWindow sharedHoverWindow] fadeOut];
[self setActiveAnnotation:nil];
}
@@ -1400,7 +1400,7 @@
if (trackingNumber == trackingRect) {
[[self window] setAcceptsMouseMovedEvents:NO];
} else if (hoverRect == trackingNumber) {
- [[SKPDFHoverWindow sharedHoverWindow] hide];
+ [[SKPDFHoverWindow sharedHoverWindow] fadeOut];
hoverRect = 0;
}
}
@@ -2312,7 +2312,7 @@
if (autohidesCursor)
[NSCursor setHiddenUntilMouseMoves:YES];
if (hasNavigation)
- [navWindow hide];
+ [navWindow fadeOut];
}
#pragma mark Event handling
Modified: trunk/SKRemoteStateWindow.h
===================================================================
--- trunk/SKRemoteStateWindow.h 2008-03-13 01:06:17 UTC (rev 3470)
+++ trunk/SKRemoteStateWindow.h 2008-03-13 23:05:58 UTC (rev 3471)
@@ -37,15 +37,13 @@
*/
#import <Cocoa/Cocoa.h>
+#import "SKAnimatedBorderlessWindow.h"
enum {
SKRemoteStateResize,
SKRemoteStateScroll
};
[EMAIL PROTECTED] SKRemoteStateWindow : NSWindow {
- NSViewAnimation *animation;
- NSTimer *timer;
-}
-+ (void)showWithType:(int)remoteState atPoint:(NSPoint)point
timeout:(NSTimeInterval)timeout;
[EMAIL PROTECTED] SKRemoteStateWindow : SKAnimatedBorderlessWindow
++ (void)showWithType:(int)remoteState atPoint:(NSPoint)point;
@end
Modified: trunk/SKRemoteStateWindow.m
===================================================================
--- trunk/SKRemoteStateWindow.m 2008-03-13 01:06:17 UTC (rev 3470)
+++ trunk/SKRemoteStateWindow.m 2008-03-13 23:05:58 UTC (rev 3471)
@@ -39,6 +39,7 @@
#import "SKRemoteStateWindow.h"
#import "NSGeometry_SKExtensions.h"
#import "NSBezierPath_BDSKExtensions.h"
+#import "SKStringConstants.h"
@interface SKRemoteStateView : NSView {
@@ -60,12 +61,8 @@
- (id)init {
NSRect contentRect = SKRectFromCenterAndSize(NSZeroPoint,
SKMakeSquareSize(60.0));
- if (self = [super initWithContentRect:contentRect
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) {
+ if (self = [super initWithContentRect:contentRect]) {
[self setIgnoresMouseEvents:YES];
- [self setReleasedWhenClosed:NO];
- [self setBackgroundColor:[NSColor clearColor]];
- [self setAlphaValue:0.95];
- [self setOpaque:NO];
[self setDisplaysWhenScreenProfileChanges:NO];
[self setLevel:NSStatusWindowLevel];
[self setContentView:[[[SKRemoteStateView alloc] init] autorelease]];
@@ -73,58 +70,27 @@
return self;
}
-- (BOOL)canBecomeKeyWindow { return NO; }
+- (float)defaultAlphaValue { return 0.95; }
-- (BOOL)canBecomeMainWindow { return NO; }
-
-- (void)animationDidEnd:(NSAnimation *)anAnimation {
- [animation release];
- animation = nil;
- [self orderOut:self];
- [self setAlphaValue:1.0];
+- (NSTimeInterval)autoHideTimeInterval {
+ return [[NSUserDefaults standardUserDefaults]
floatForKey:SKAppleRemoteSwitchIndicationTimeoutKey];
}
-- (void)animationDidStop:(NSAnimation *)anAnimation {
- [animation release];
- animation = nil;
- [self orderOut:self];
- [self setAlphaValue:1.0];
+- (void)showWithType:(int)remoteState atPoint:(NSPoint)point {
+ if ([self autoHideTimeInterval] > 0.0) {
+ [self stopAnimation];
+
+ [self setFrame:SKRectFromCenterAndSize(point, SKMakeSquareSize(60.0))
display:NO animate:NO];
+ [(SKRemoteStateView *)[self contentView] setRemoteState:remoteState];
+
+ [self orderFrontRegardless];
+ }
}
-- (void)fadeOut:(id)sender {
- [timer invalidate];
- [timer release];
- timer = nil;
-
- NSDictionary *fadeOutDict = [[NSDictionary alloc]
initWithObjectsAndKeys:self, NSViewAnimationTargetKey,
NSViewAnimationFadeOutEffect, NSViewAnimationEffectKey, nil];
- animation = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray
arrayWithObjects:fadeOutDict, nil]];
- [fadeOutDict release];
- [animation setDuration:1.0];
- [animation setAnimationBlockingMode:NSAnimationNonblocking];
- [animation setDelegate:self];
- [animation startAnimation];
++ (void)showWithType:(int)remoteState atPoint:(NSPoint)point {
+ [[self sharedRemoteStateWindow] showWithType:remoteState atPoint:point];
}
-- (void)showWithType:(int)remoteState atPoint:(NSPoint)point
timeout:(NSTimeInterval)timeout {
- [timer invalidate];
- [timer release];
- timer = nil;
-
- [animation stopAnimation];
- [animation release];
- animation = nil;
-
- [self setFrame:SKRectFromCenterAndSize(point, SKMakeSquareSize(60.0))
display:NO animate:NO];
- [(SKRemoteStateView *)[self contentView] setRemoteState:remoteState];
-
- [self orderFrontRegardless];
- timer = [[NSTimer scheduledTimerWithTimeInterval:timeout target:self
selector:@selector(fadeOut:) userInfo:nil repeats:NO] retain];
-}
-
-+ (void)showWithType:(int)remoteState atPoint:(NSPoint)point
timeout:(NSTimeInterval)timeout {
- [[[self class] sharedRemoteStateWindow] showWithType:remoteState
atPoint:point timeout:timeout];
-}
-
@end
#pragma mark -
Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj 2008-03-13 01:06:17 UTC (rev
3470)
+++ trunk/Skim.xcodeproj/project.pbxproj 2008-03-13 23:05:58 UTC (rev
3471)
@@ -155,6 +155,7 @@
CEA575CE0B9206E60003D2E7 /* SKNoteOutlineView.m in Sources */ =
{isa = PBXBuildFile; fileRef = CEA575CD0B9206E60003D2E7 /* SKNoteOutlineView.m
*/; };
CEA575E50B9207B80003D2E7 /* SKThumbnailTableView.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CEA575E40B9207B80003D2E7 /*
SKThumbnailTableView.m */; };
CEA575FD0B9208B60003D2E7 /* SKTocOutlineView.m in Sources */ =
{isa = PBXBuildFile; fileRef = CEA575FC0B9208B60003D2E7 /* SKTocOutlineView.m
*/; };
+ CEA8FCD60D89C34A00E8A6F4 /* SKAnimatedBorderlessWindow.m in
Sources */ = {isa = PBXBuildFile; fileRef = CEA8FCD50D89C34A00E8A6F4 /*
SKAnimatedBorderlessWindow.m */; };
CEAA55800C6DE030006BD633 /* SKDownloadController.m in Sources
*/ = {isa = PBXBuildFile; fileRef = CEAA557E0C6DE030006BD633 /*
SKDownloadController.m */; };
CEAA559E0C6DE235006BD633 /* SKDownload.m in Sources */ = {isa =
PBXBuildFile; fileRef = CEAA559C0C6DE235006BD633 /* SKDownload.m */; };
CEAA55B70C6DE452006BD633 /* SKProgressCell.m in Sources */ =
{isa = PBXBuildFile; fileRef = CEAA55B50C6DE452006BD633 /* SKProgressCell.m */;
};
@@ -668,6 +669,8 @@
CEA575E40B9207B80003D2E7 /* SKThumbnailTableView.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKThumbnailTableView.m; sourceTree = "<group>"; };
CEA575FB0B9208B60003D2E7 /* SKTocOutlineView.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKTocOutlineView.h; sourceTree = "<group>"; };
CEA575FC0B9208B60003D2E7 /* SKTocOutlineView.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKTocOutlineView.m; sourceTree = "<group>"; };
+ CEA8FCD40D89C34A00E8A6F4 /* SKAnimatedBorderlessWindow.h */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
path = SKAnimatedBorderlessWindow.h; sourceTree = "<group>"; };
+ CEA8FCD50D89C34A00E8A6F4 /* SKAnimatedBorderlessWindow.m */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.objc; path = SKAnimatedBorderlessWindow.m; sourceTree = "<group>";
};
CEAA557D0C6DE02F006BD633 /* SKDownloadController.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKDownloadController.h; sourceTree = "<group>"; };
CEAA557E0C6DE030006BD633 /* SKDownloadController.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKDownloadController.m; sourceTree = "<group>"; };
CEAA559B0C6DE235006BD633 /* SKDownload.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKDownload.h; sourceTree = "<group>"; };
@@ -1142,6 +1145,8 @@
CE49724F0BDE898F00D7F1D2 /* SKMainWindow.m */,
CE2DE49B0B85D4F400D0DA12 /*
SKFullScreenWindow.h */,
CE2DE49C0B85D4F400D0DA12 /*
SKFullScreenWindow.m */,
+ CEA8FCD40D89C34A00E8A6F4 /*
SKAnimatedBorderlessWindow.h */,
+ CEA8FCD50D89C34A00E8A6F4 /*
SKAnimatedBorderlessWindow.m */,
CE2DE4C40B85D78200D0DA12 /*
SKMiniaturizeWindow.h */,
CE2DE4C50B85D78200D0DA12 /*
SKMiniaturizeWindow.m */,
CEFDF8BC0B3848C40091C61A /*
SKNavigationWindow.h */,
@@ -1862,6 +1867,7 @@
CE9B951E0D04657A00EB1A6C /*
SKRemoteStateWindow.m in Sources */,
CE6DC77B0D687272003A072F /*
SKPrintAccessoryViewController.m in Sources */,
CE6DC7BB0D689138003A072F /*
PDFDocument_SKExtensions.m in Sources */,
+ CEA8FCD60D89C34A00E8A6F4 /*
SKAnimatedBorderlessWindow.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit