Diff for /chimera/SplashScreenWindow.m between versions 1.4 and 1.5

version 1.4, 2002/04/18 15:40:04 version 1.5, 2002/04/20 00:44:56
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)splashImage:(NSImage *)splashImage withStatusRect:(NSRect)statusRect-(id)splashImage:(NSImage *)splashImage withFade:(BOOL)shouldFade withStatusRect:(NSRect)statusRect
 {  {
     NSRect               splashRect;      NSRect               splashRect;
     NSRect               statusFieldRect;      NSRect               statusFieldRect;
     NSImageView *contentImageView;      NSImageView *contentImageView;
   
       _fadeDelay = (0.5 / 60.0);
   
     if ( ! splashImage ) {      if ( ! splashImage ) {
         if ( [NSImage imageNamed:@"splash"] ) {          if ( [NSImage imageNamed:@"splash"] ) {
             splashImage = [NSImage imageNamed:@"splash"];              splashImage = [NSImage imageNamed:@"splash"];
Line 30 Line 38
     contentImageView  = [[NSImageView alloc] initWithFrame:splashRect];      contentImageView  = [[NSImageView alloc] initWithFrame:splashRect];
     _statusField      = [[NSTextField alloc] initWithFrame:statusFieldRect];      _statusField      = [[NSTextField alloc] initWithFrame:statusFieldRect];
   
    [self initWithContentRect:splashRect    if ( (self = [super initWithContentRect:splashRect
                    styleMask:NSBorderlessWindowMask                            styleMask:NSBorderlessWindowMask
                      backing:NSBackingStoreBuffered                              backing:NSBackingStoreBuffered
                        defer:NO];                                defer:NO]) ) {
        
    [contentImageView setImage:splashImage];        [contentImageView setImage:splashImage];
        _fadeThreadLock = nil;
    [_statusField setDrawsBackground:NO];
    [_statusField setEditable:NO];        [_statusField setDrawsBackground:NO];
    [_statusField setSelectable:NO];        [_statusField setEditable:NO];
    [_statusField setBezeled:NO];        [_statusField setSelectable:NO];
    [_statusField setBordered:NO];        [_statusField setBezeled:NO];
    [_statusField setFont:[NSFont fontWithName:@"Monaco" size:10.0]];        [_statusField setBordered:NO];
    [_statusField setTextColor:[NSColor whiteColor]];        [_statusField setFont:[NSFont fontWithName:@"Monaco" size:10.0]];
    [_statusField setAlignment:NSRightTextAlignment];        [_statusField setTextColor:[NSColor whiteColor]];
    [_statusField setStringValue:@"Loading..."];        [_statusField setAlignment:NSRightTextAlignment];
        [_statusField setStringValue:@"Loading..."];
    [[self contentView] addSubview:contentImageView];
    [[self contentView] addSubview:_statusField];        [[self contentView] addSubview:contentImageView];
    [self setOpaque:NO];        [[self contentView] addSubview:_statusField];
    [self setHasShadow:YES];        [self setOpaque:NO];
    [self setReleasedWhenClosed:YES];        [self setHasShadow:YES];
    [self center];        [self setReleasedWhenClosed:YES];
            [self center];
    [self makeKeyAndOrderFront:self]; 
   
           if ( shouldFade ) {
               [self fadeIn];
           } else {
               [self makeKeyAndOrderFront:self];
           }
           __didFadeIn = shouldFade;
       }
     return self;      return self;
 }  }
   
Line 70 Line 84
     [_statusField display];      [_statusField display];
 }  }
   
   -(void)fadeIn
   {
       [self setAlphaValue:0.0];
       [self makeKeyAndOrderFront:self];
       
       if (_fadeThreadLock == nil) {
           _fadeThreadLock = [[NSLock allocWithZone:[self zone]] init];
       }
       
       [NSThread detachNewThreadSelector:@selector(fadeInThread) toTarget:self withObject:nil];
   }
   
   -(void)fadeInThread
   {
       float fadeLevel = 0.0;
       NSAutoreleasePool *threadMainPool = [[NSAutoreleasePool alloc] init];
   
       [_fadeThreadLock lock];
   
       while ( fadeLevel < 1.0 ) {
           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
   {
       if (_fadeThreadLock == nil) {
           _fadeThreadLock = [[NSLock allocWithZone:[self zone]] init];
       }
   
       [NSThread detachNewThreadSelector:@selector(fadeOutThread) toTarget:self withObject:nil];
   }
   
   -(void)fadeOutThread
   {
       float fadeLevel = 1.0;
       NSAutoreleasePool *threadMainPool = [[NSAutoreleasePool alloc] init];
   
       [_fadeThreadLock lock];
   
       while ( fadeLevel > 0.0 ) {
           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
   {
   //  if ( __didFadeIn ) {
       if (      NO     ) { //Fade out is still problematic...
           [self fadeOut];
       }
       [super close];
   }
   
 -(void)dealloc  -(void)dealloc
 {  {
    if (_splashImage)     if (_splashImage) {
         [_splashImage release];          [_splashImage release];
       }
   
       [_fadeThreadLock release];
   
     [super dealloc];      [super dealloc];
 }  }
   
   
 @end  @end

Removed from v.1.4  
changed lines
  Added in v.1.5


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