X-Git-Url: http://git.ithinksw.org/ITKit.git/blobdiff_plain/56515bcf2e6dd44a8fe3767b7f3791cae184d940..7c89200521dd8c6cb8fc8a17c633ac80d4b18bd2:/ITTransientStatusWindow.m?ds=sidebyside diff --git a/ITTransientStatusWindow.m b/ITTransientStatusWindow.m index 45ad1e3..6cb33a3 100755 --- a/ITTransientStatusWindow.m +++ b/ITTransientStatusWindow.m @@ -1,20 +1,11 @@ #import "ITTransientStatusWindow.h" +#import "ITWindowEffect.h" #import #import "ITCoreGraphicsHacks.h" #import "ITTextField.h" #import "ITGrayRoundedView.h" -@class ITTextField; -@class ITGrayRoundedView; - -/*************************************************************************/ -#pragma mark - -#pragma mark EVIL HACKERY -/*************************************************************************/ - -@interface NSApplication (HACKHACKHACKHACK) -- (CGSConnectionID)contextID; -@end +#define EFFECT_FPS 30.0 /*************************************************************************/ @@ -27,10 +18,7 @@ exitMode:(ITTransientStatusWindowExitMode)exitMode backgroundType:(ITTransientStatusWindowBackgroundType)backgroundType; - (void)rebuildWindow; -- (void)performEffect; -- (void)dissolveEffect:(BOOL)entering; -- (void)slideVerticalEffect:(BOOL)entering; -- (void)slideHorizontalEffect:(BOOL)entering; +- (void)startVanishTimer; @end @@ -71,7 +59,7 @@ static ITTransientStatusWindow *staticWindow = nil; { NSRect contentRect; - // If no Content View was provided, use a generic NSView with the app icon. + // If no Content View was provided, use a generic view. if ( ! (contentView) ) { contentView = [[[NSView alloc] initWithFrame: NSMakeRect(100.0, 100.0, 200.0, 200.0)] autorelease]; @@ -89,20 +77,20 @@ static ITTransientStatusWindow *staticWindow = nil; _exitMode = exitMode; _exitDelay = DEFAULT_EXIT_DELAY; _backgroundType = backgroundType; - _verticalPosition = ITTransientStatusWindowPositionBottom; - _horizontalPosition = ITTransientStatusWindowPositionLeft; - _entryEffect = ITTransientStatusWindowEffectNone; - _exitEffect = ITTransientStatusWindowEffectDissolve; - _effectTime = DEFAULT_EFFECT_TIME; + _verticalPosition = ITWindowPositionBottom; + _horizontalPosition = ITWindowPositionLeft; + _screenPadding = 32.0; + _screenNumber = 0; + _entryEffect = nil; + _exitEffect = nil; _reallyIgnoresEvents = YES; - _delayTimer = nil; - _fadeTimer = nil; + _delayTimer = nil; -// if ( _backgroundType == ITTransientStatusWindowRounded ) { -// _contentSubView = contentView; -// } else { -// [self setContentView:contentView]; -// } +// if ( _backgroundType == ITTransientStatusWindowRounded ) { +// _contentSubView = contentView; +// } else { +// [self setContentView:contentView]; +// } [self setIgnoresMouseEvents:YES]; [self setLevel:NSScreenSaverWindowLevel]; @@ -118,18 +106,6 @@ static ITTransientStatusWindow *staticWindow = nil; #pragma mark INSTANCE METHODS /*************************************************************************/ -- (void)setRotation:(float)angle -{ - CGAffineTransform transform = CGAffineTransformMakeRotation(angle); - transform.tx = -32.0; - transform.ty = [self frame].size.height + 32.0; - CGSSetWindowTransform([NSApp contextID], - (CGSWindowID)[self windowNumber], - CGAffineTransformTranslate(transform, - (([self frame].origin.x - 32.0) * -1), - (([[self screen] frame].size.height - ([self frame].origin.y) + 32.0) * -1) )); -} - - (BOOL)ignoresMouseEvents { return _reallyIgnoresEvents; @@ -149,46 +125,6 @@ static ITTransientStatusWindow *staticWindow = nil; _reallyIgnoresEvents = flag; } -- (void)orderFront:(id)sender -{ - if ( _exitMode == ITTransientStatusWindowExitAfterDelay ) { - // set the timer, and orderOut: when it lapses. - } - - if ( _entryEffect == ITTransientStatusWindowEffectNone ) { - [super orderFront:sender]; - } else { - [self performEffect]; - } -} - -- (void)makeKeyAndOrderFront:(id)sender -{ - if ( _exitMode == ITTransientStatusWindowExitAfterDelay ) { - // set the timer, and orderOut: when it lapses. - } - - if ( _entryEffect == ITTransientStatusWindowEffectNone ) { - [super makeKeyAndOrderFront:sender]; - } else { - [self performEffect]; - [self makeKeyWindow]; - } -} - -- (void)orderOut:(id)sender -{ - if ( _entryEffect == ITTransientStatusWindowEffectNone ) { - [super orderOut:sender]; - } else { - [self performEffect]; - } -} - -- (NSTimeInterval)animationResizeTime:(NSRect)newFrame -{ - return _effectTime; -} /* @@ -216,11 +152,51 @@ static ITTransientStatusWindow *staticWindow = nil; */ -- (ITTransientStatusWindowVisibilityState)visibilityState +- (IBAction)appear:(id)sender +{ + if ( _visibilityState == ITTransientStatusWindowHiddenState ) { + // Window is hidden. Appear as normal, and start the timer. + [_entryEffect performAppear]; + } else if ( _visibilityState == ITTransientStatusWindowVisibleState ) { + // Window is completely visible. Simply reset the timer. + [self startVanishTimer]; + } else if ( _visibilityState == ITTransientStatusWindowAppearingState ) { + // Window is on its way in. Do nothing. + } else if ( _visibilityState == ITTransientStatusWindowVanishingState ) { + // Window is on its way out. Cancel the vanish. + [_exitEffect cancelVanish]; + } +} + +- (IBAction)vanish:(id)sender +{ + if ( _visibilityState == ITTransientStatusWindowVisibleState ) { + // Window is totally visible. Perform exit effect. + [_exitEffect performVanish]; + } else if ( _visibilityState == ITTransientStatusWindowHiddenState ) { + // Window is hidden. Do nothing. + } else if ( _visibilityState == ITTransientStatusWindowAppearingState ) { + // Window is on its way in. Cancel appear. + [_entryEffect cancelAppear]; + } else if ( _visibilityState == ITTransientStatusWindowVanishingState ) { + // Window is on its way out. Do nothing. + } +} + +- (ITWindowVisibilityState)visibilityState { return _visibilityState; } +- (void)setVisibilityState:(ITWindowVisibilityState)newState +{ + _visibilityState = newState; + + if ( _visibilityState == ITTransientStatusWindowVisibleState ) { + [self startVanishTimer]; + } +} + - (ITTransientStatusWindowExitMode)exitMode { return _exitMode; @@ -254,44 +230,76 @@ static ITTransientStatusWindow *staticWindow = nil; _backgroundType = ITTransientStatusWindowRounded; } -- (ITTransientStatusWindowPosition)verticalPosition; +- (ITVerticalWindowPosition)verticalPosition; { return _verticalPosition; } -- (void)setVerticalPosition:(ITTransientStatusWindowPosition)newPosition; +- (void)setVerticalPosition:(ITVerticalWindowPosition)newPosition; { _verticalPosition = newPosition; } -- (ITTransientStatusWindowPosition)horizontalPosition; +- (ITHorizontalWindowPosition)horizontalPosition; { return _horizontalPosition; } -- (void)setHorizontalPosition:(ITTransientStatusWindowPosition)newPosition; +- (void)setHorizontalPosition:(ITHorizontalWindowPosition)newPosition; { _horizontalPosition = newPosition; } -- (ITTransientStatusWindowEffect)entryEffect +- (float)effectProgress +{ + return _effectProgress; +} + +- (void)setEffectProgress:(float)newProgress +{ + _effectProgress = newProgress; +} + +- (float)screenPadding +{ + return _screenPadding; +} + +- (void)setScreenPadding:(float)newPadding +{ + _screenPadding = newPadding; +} + +- (int)screenNumber +{ + return _screenNumber; +} + +- (void)setScreenNumber:(int)newNumber +{ + _screenNumber = newNumber; +} + +- (ITWindowEffect *)entryEffect { return _entryEffect; } -- (void)setEntryEffect:(ITTransientStatusWindowEffect)newEffect; +- (void)setEntryEffect:(ITWindowEffect *)newEffect { - _entryEffect = newEffect; + [_entryEffect autorelease]; + _entryEffect = [newEffect retain]; } -- (ITTransientStatusWindowEffect)exitEffect; +- (ITWindowEffect *)exitEffect { return _exitEffect; } -- (void)setExitEffect:(ITTransientStatusWindowEffect)newEffect; +- (void)setExitEffect:(ITWindowEffect *)newEffect { - _exitEffect = newEffect; + [_exitEffect autorelease]; + _exitEffect = [newEffect retain]; } @@ -318,53 +326,10 @@ static ITTransientStatusWindow *staticWindow = nil; } } -- (void)performEffect -{ - if ( _visibilityState == ITTransientStatusWindowHiddenState ) { - if ( _entryEffect == ITTransientStatusWindowEffectDissolve ) { - [self dissolveEffect:YES]; - } else if ( _entryEffect == ITTransientStatusWindowEffectSlideVertically ) { - [self slideVerticalEffect:YES]; - } else if ( _entryEffect == ITTransientStatusWindowEffectSlideHorizontally ) { - [self slideHorizontalEffect:YES]; - } - } else if ( _visibilityState == ITTransientStatusWindowVisibleState ) { - if ( _exitEffect == ITTransientStatusWindowEffectDissolve ) { - [self dissolveEffect:NO]; - } else if ( _exitEffect == ITTransientStatusWindowEffectSlideVertically ) { - [self slideVerticalEffect:NO]; - } else if ( _exitEffect == ITTransientStatusWindowEffectSlideHorizontally ) { - [self slideHorizontalEffect:NO]; - } - } -} - -- (void)dissolveEffect:(BOOL)entering -{ - if ( entering ) { - [super orderFront:self]; - } else { - [super orderOut:self]; - } -} - -- (void)slideVerticalEffect:(BOOL)entering -{ - if ( entering ) { - [super orderFront:self]; - } else { - [super orderOut:self]; - } -} - -- (void)slideHorizontalEffect:(BOOL)entering +- (void)startVanishTimer { - if ( entering ) { - [super orderFront:self]; - } else { - [super orderOut:self]; - } + // start timer, if appropriate + // if timer already exists, restart it. } - @end