when removing the drag overview, fade it out

This commit is contained in:
Mitchell Livingston 2007-05-19 16:07:36 +00:00
parent b9ea37aca9
commit eb28d5394e
3 changed files with 55 additions and 3 deletions

View File

@ -2125,13 +2125,13 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
- (void) draggingExited: (id <NSDraggingInfo>) sender
{
[fWindow removeChildWindow: fOverlayWindow];
[fOverlayWindow close];
[fOverlayWindow fadeOut];
}
- (BOOL) performDragOperation: (id <NSDraggingInfo>) info
{
[fWindow removeChildWindow: fOverlayWindow];
[fOverlayWindow close];
[fOverlayWindow fadeOut];
NSPasteboard * pasteboard = [info draggingPasteboard];
if ([[pasteboard types] containsObject: NSFilenamesPboardType])

View File

@ -28,9 +28,13 @@
@interface DragOverlayWindow : NSWindow
{
tr_handle_t * fLib;
NSTimer * fFadeTimer;
}
- (void) setFiles: (NSArray *) files;
- (void) setURL: (NSString *) url;
- (void) fadeOut;
@end

View File

@ -26,6 +26,12 @@
#import "DragOverlayView.h"
#import "StringAdditions.h"
@interface DragOverlayWindow (Private)
- (void) fade;
@end
@implementation DragOverlayWindow
- (id) initWithLib: (tr_handle_t *) lib
@ -36,7 +42,6 @@
fLib = lib;
[self setBackgroundColor: [NSColor colorWithCalibratedWhite: 0.0 alpha: 0.5]];
[self setAlphaValue: 1.0];
[self setOpaque: NO];
[self setHasShadow: NO];
@ -50,8 +55,22 @@
return self;
}
- (void) dealloc
{
if (fFadeTimer)
[fFadeTimer invalidate];
[super dealloc];
}
- (void) setFiles: (NSArray *) files
{
if (fFadeTimer)
{
[fFadeTimer invalidate];
fFadeTimer = nil;
}
[self setAlphaValue: 1.0];
uint64_t size = 0;
int count = 0;
@ -98,8 +117,37 @@
- (void) setURL: (NSString *) url
{
if (fFadeTimer)
{
[fFadeTimer invalidate];
fFadeTimer = nil;
}
[self setAlphaValue: 1.0];
[[self contentView] setOverlay: [NSImage imageNamed: @"Globe.tiff"]
mainLine: NSLocalizedString(@"Web Address", "Drag overlay -> url") subLine: url];
}
- (void) fadeOut
{
fFadeTimer = [NSTimer scheduledTimerWithTimeInterval: 0.015 target: self
selector: @selector(fade) userInfo: nil repeats: YES];
}
@end
@implementation DragOverlayWindow (Private)
- (void) fade
{
[self setAlphaValue: [self alphaValue] - 0.1];
if ([self alphaValue] <= 0.0)
{
[fFadeTimer invalidate];
fFadeTimer = nil;
[self close];
}
}
@end