From 6e2ee55701c758659cce4d7987464bafd0d16c2f Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Sat, 19 May 2007 18:42:12 +0000 Subject: [PATCH] simplify fade in code a little --- macosx/DragOverlayView.m | 2 -- macosx/DragOverlayWindow.m | 50 ++++++++++++++++---------------------- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/macosx/DragOverlayView.m b/macosx/DragOverlayView.m index 0f0e00eef..093547ea4 100644 --- a/macosx/DragOverlayView.m +++ b/macosx/DragOverlayView.m @@ -138,8 +138,6 @@ [subLine drawInRect: lineRect withAttributes: fSubLineAttributes]; [fBadge unlockFocus]; - - [self setNeedsDisplay: YES]; } -(void) drawRect: (NSRect) rect diff --git a/macosx/DragOverlayWindow.m b/macosx/DragOverlayWindow.m index aa5cd19e7..0870794e3 100644 --- a/macosx/DragOverlayWindow.m +++ b/macosx/DragOverlayWindow.m @@ -28,6 +28,7 @@ @interface DragOverlayWindow (Private) +- (void) beginFadeIn; - (void) fadeIn; - (void) fadeOut; @@ -68,18 +69,6 @@ - (void) setFiles: (NSArray *) files { - [self setAlphaValue: 0.0]; - if (fFadeInTimer) - { - [fFadeInTimer invalidate]; - fFadeInTimer = nil; - } - if (fFadeOutTimer) - { - [fFadeOutTimer invalidate]; - fFadeOutTimer = nil; - } - uint64_t size = 0; int count = 0; @@ -123,30 +112,15 @@ [[self contentView] setOverlay: icon mainLine: name subLine: sizeString]; - fFadeInTimer = [NSTimer scheduledTimerWithTimeInterval: 0.0075 target: self - selector: @selector(fadeIn) userInfo: nil repeats: YES]; + [self beginFadeIn]; } -#warning combine - (void) setURL: (NSString *) url { - [self setAlphaValue: 0.0]; - if (fFadeInTimer) - { - [fFadeInTimer invalidate]; - fFadeInTimer = nil; - } - if (fFadeOutTimer) - { - [fFadeOutTimer invalidate]; - fFadeOutTimer = nil; - } - [[self contentView] setOverlay: [NSImage imageNamed: @"Globe.tiff"] mainLine: NSLocalizedString(@"Web Address", "Drag overlay -> url") subLine: url]; - fFadeInTimer = [NSTimer scheduledTimerWithTimeInterval: 0.0075 target: self - selector: @selector(fadeIn) userInfo: nil repeats: YES]; + [self beginFadeIn]; } - (void) closeFadeOut @@ -170,6 +144,24 @@ @implementation DragOverlayWindow (Private) +- (void) beginFadeIn +{ + [self setAlphaValue: 0.0]; + if (fFadeInTimer) + { + [fFadeInTimer invalidate]; + fFadeInTimer = nil; + } + if (fFadeOutTimer) + { + [fFadeOutTimer invalidate]; + fFadeOutTimer = nil; + } + + fFadeInTimer = [NSTimer scheduledTimerWithTimeInterval: 0.0075 target: self + selector: @selector(fadeIn) userInfo: nil repeats: YES]; +} + - (void) fadeIn { [self setAlphaValue: [self alphaValue] + 0.1];