Diff for /chimera/SplashScreenWindow.m between versions 1.2 and 1.3

version 1.2, 2002/03/20 10:24:50 version 1.3, 2002/04/05 00:28:47
Line 8 Line 8
   
 #import "SplashScreenWindow.h"  #import "SplashScreenWindow.h"
   
   @interface SplashScreenWindow (Private)
   -(void)fadeIn;
   -(void)fadeInThread;
   -(void)fadeOut;
   -(void)fadeOutThread;
   @end
   
 @implementation SplashScreenWindow  @implementation SplashScreenWindow
   
-(id)splash;-(id)splashImage:(NSImage *)splashImage withFade:(BOOL)shouldFade withStatusRect:(NSRect)statusRect
 {  {
     NSRect               splashRect;      NSRect               splashRect;
     NSRect               statusFieldRect;      NSRect               statusFieldRect;
     NSImageView *contentImageView;      NSImageView *contentImageView;
    
    if ( ! [self splashImage] ) {    _fadeDelay = (0.5 / 60.0);
        [self setSplashImage:[NSImage imageNamed:@"splash"]];
     if ( ! splashImage ) {
         if ( [NSImage imageNamed:@"splash"] ) {
             splashImage = [NSImage imageNamed:@"splash"];
         } else {
             splashImage = [NSImage imageNamed:@"NSApplicationIcon"];
         }
     }      }
   
    splashRect            = NSMakeRect(0.0, 0.0, [[self splashImage] size].width, [[self splashImage] size].height);    splashRect            = NSMakeRect(0.0, 0.0, [splashImage size].width, [splashImage size].height);
     statusFieldRect   = NSMakeRect(0.0, 170.0, (splashRect.size.width - 5.0), 16.0);      statusFieldRect   = NSMakeRect(0.0, 170.0, (splashRect.size.width - 5.0), 16.0);
     contentImageView  = [[NSImageView alloc] initWithFrame:splashRect];      contentImageView  = [[NSImageView alloc] initWithFrame:splashRect];
     _statusField      = [[NSTextField alloc] initWithFrame:statusFieldRect];      _statusField      = [[NSTextField alloc] initWithFrame:statusFieldRect];
    
     [self initWithContentRect:splashRect      [self initWithContentRect:splashRect
                     styleMask:NSBorderlessWindowMask                      styleMask:NSBorderlessWindowMask
                       backing:NSBackingStoreBuffered                        backing:NSBackingStoreBuffered
                         defer:NO];                          defer:NO];
            
    [contentImageView setImage:[self splashImage]];    [contentImageView setImage:splashImage];
     _fadeThreadLock = nil;
   
     [_statusField setDrawsBackground:NO];      [_statusField setDrawsBackground:NO];
     [_statusField setEditable:NO];      [_statusField setEditable:NO];
Line 45 Line 58
   
     [[self contentView] addSubview:contentImageView];      [[self contentView] addSubview:contentImageView];
     [[self contentView] addSubview:_statusField];      [[self contentView] addSubview:_statusField];
       [self setOpaque:NO];
     [self setHasShadow:YES];      [self setHasShadow:YES];
     [self setReleasedWhenClosed:YES];      [self setReleasedWhenClosed:YES];
     [self center];      [self center];
           
    if ( [self fades] ) {    if ( shouldFade ) {
         [self fadeIn];          [self fadeIn];
     } else {      } else {
         [self makeKeyAndOrderFront:self];          [self makeKeyAndOrderFront:self];
     }      }
       __didFadeIn = shouldFade;
   
     return self;      return self;
 }  }
   
-(BOOL)fades-(NSString *)statusText
{ 
    return _fades; 
} 
 
-(void)setFades:(BOOL)fadeFlag; 
{ 
    _fades = fadeFlag; 
} 
 
-(NSImage *)splashImage 
 {  {
    return _splashImage;    return [_statusField stringValue];
} 
 
-(void)setSplashImage:(NSImage *)newImage; 
{ 
    [_splashImage autorelease]; 
    _splashImage = [newImage copy]; 
 }  }
   
 -(void)setStatusText:(NSString *)newText  -(void)setStatusText:(NSString *)newText
Line 87 Line 86
   
 -(void)fadeIn  -(void)fadeIn
 {  {
    [self setAlphaValue:0.5];    [self setAlphaValue:0.0];
     [self makeKeyAndOrderFront:self];      [self makeKeyAndOrderFront:self];
    
    if (!_fadeTimer) {    if (_fadeThreadLock == nil) {
        _fadeTimer = [NSTimer scheduledTimerWithTimeInterval:.10        _fadeThreadLock = [[NSLock allocWithZone:[self zone]] init];
                                                      target:self 
                                                    selector:@selector(fadeStepUp:) 
                                                    userInfo:nil 
                                                     repeats:YES]; 
     }      }
       
       [NSThread detachNewThreadSelector:@selector(fadeInThread) toTarget:self withObject:nil];
 }  }
   
-(void)fadeStepUp:(NSTimer *)aTimer-(void)fadeInThread
 {  {
    NSLog(@"Fade up");    float fadeLevel = 0.0;
    [self setAlphaValue:([self alphaValue] + 0.05)];    NSAutoreleasePool *threadMainPool = [[NSAutoreleasePool alloc] init];
 
     [_fadeThreadLock lock];
   
    if ( [self alphaValue] == 1.0 ) {    while ( fadeLevel < 1.0 ) {
        [_fadeTimer invalidate];        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
         fadeLevel += 0.20;
         [self setAlphaValue:fadeLevel];
         [self flushWindow];
         [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:_fadeDelay]];
         [pool release];
     }      }
   
       [_fadeThreadLock unlock];
       [threadMainPool release];
 }  }
   
 -(void)fadeOut  -(void)fadeOut
 {  {
    if (!_fadeTimer) {    if (_fadeThreadLock == nil) {
        _fadeTimer = [NSTimer scheduledTimerWithTimeInterval:.10        _fadeThreadLock = [[NSLock allocWithZone:[self zone]] init];
                                                      target:self 
                                                    selector:@selector(fadeStepDown:) 
                                                    userInfo:nil 
                                                     repeats:YES]; 
     }      }
   
       [NSThread detachNewThreadSelector:@selector(fadeOutThread) toTarget:self withObject:nil];
 }  }
   
-(void)fadeStepDown:(NSTimer *)aTimer-(void)fadeOutThread
 {  {
    [self setAlphaValue:([self alphaValue] - 0.05)];    float fadeLevel = 1.0;
     NSAutoreleasePool *threadMainPool = [[NSAutoreleasePool alloc] init];
 
     [_fadeThreadLock lock];
   
    if ( [self alphaValue] == 0.0 ) {    while ( fadeLevel > 0.0 ) {
        [_fadeTimer invalidate];        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
         fadeLevel -= 0.1;
         [self setAlphaValue:fadeLevel];
         [self flushWindow];
         [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:_fadeDelay]];
         [pool release];
     }      }
   
       [_fadeThreadLock unlock];
       [threadMainPool release];
 }  }
   
 -(void)close  -(void)close
 {  {
    if ( [self fades] ) {//  if ( __didFadeIn ) {
     if (      NO     ) { //Fade out is still problematic...
         [self fadeOut];          [self fadeOut];
     }      }
     [super close];      [super close];
Line 142 Line 159
     if (_splashImage) {      if (_splashImage) {
         [_splashImage release];          [_splashImage release];
     }      }
   
       [_fadeThreadLock release];
   
     [super dealloc];      [super dealloc];
 }  }
   

Removed from v.1.2  
changed lines
  Added in v.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>