X-Git-Url: http://git.ithinksw.org/ITKit.git/blobdiff_plain/78553c25bacdbd190fd14591420cf4f7fa578617..7258eefd9885c903817ec277fe611aff4b0ff5c6:/ITTransientStatusWindow.m diff --git a/ITTransientStatusWindow.m b/ITTransientStatusWindow.m index 098bd2d..f749278 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)performEffect; @end @@ -71,10 +59,7 @@ static ITTransientStatusWindow *staticWindow = nil; { NSRect contentRect; - CGSValueObj key; - CGSValueObj ignore; - - // If no Content View was provided, use a generic NSImageView 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]; @@ -88,34 +73,26 @@ static ITTransientStatusWindow *staticWindow = nil; backing:NSBackingStoreBuffered defer:NO] ) ) { - _visibilityState = ITTransientStatusWindowHiddenState; - _exitMode = exitMode; - _exitDelay = DEFAULT_EXIT_DELAY; - _backgroundType = backgroundType; - _verticalPosition = ITTransientStatusWindowPositionBottom; - _horizontalPosition = ITTransientStatusWindowPositionLeft; - _entryEffect = ITTransientStatusWindowEffectNone; - _exitEffect = ITTransientStatusWindowEffectDissolve; - - _delayTimer = nil; - _fadeTimer = nil; - -// if ( _backgroundType == ITTransientStatusWindowRounded ) { -// _contentSubView = contentView; -// } else { -// [self setContentView:contentView]; -// } - -// [self setIgnoresMouseEvents:YES]; - - key = CGSCreateCString("IgnoreForEvents"); - ignore = CGSCreateBoolean(kCGSTrue); - - CGSSetWindowProperty([NSApp contextID], (CGSWindowID)[self windowNumber], key, ignore); - - CGSReleaseObj(key); - CGSReleaseObj(ignore); - + _visibilityState = ITTransientStatusWindowHiddenState; + _exitMode = exitMode; + _exitDelay = DEFAULT_EXIT_DELAY; + _backgroundType = backgroundType; + _verticalPosition = ITWindowPositionBottom; + _horizontalPosition = ITWindowPositionLeft; + _screenPadding = 32.0; + _screenNumber = 0; + _entryEffect = nil; + _exitEffect = nil; + _reallyIgnoresEvents = YES; + _delayTimer = nil; + +// if ( _backgroundType == ITTransientStatusWindowRounded ) { +// _contentSubView = contentView; +// } else { +// [self setContentView:contentView]; +// } + + [self setIgnoresMouseEvents:YES]; [self setLevel:NSScreenSaverWindowLevel]; [self setContentView:contentView]; [self rebuildWindow]; @@ -129,17 +106,38 @@ static ITTransientStatusWindow *staticWindow = nil; #pragma mark INSTANCE METHODS /*************************************************************************/ -- (void)orderFront:(id)sender +- (BOOL)ignoresMouseEvents { - if ( _exitMode == ITTransientStatusWindowExitAfterDelay ) { - // set the timer, and orderOut: when it lapses. - } + return _reallyIgnoresEvents; +} + +- (void)setIgnoresMouseEvents:(BOOL)flag +{ + CGSValueObj key; + CGSValueObj ignore; + + key = CGSCreateCString("IgnoreForEvents"); + ignore = CGSCreateBoolean( (flag ? kCGSTrue : kCGSFalse) ); + CGSSetWindowProperty([NSApp contextID], (CGSWindowID)[self windowNumber], key, ignore); + CGSReleaseObj(key); + CGSReleaseObj(ignore); + + _reallyIgnoresEvents = flag; +} + +/* - if ( _entryEffect == ITTransientStatusWindowEffectNone ) { +- (void)orderFront:(id)sender +{ + if ( _entryEffect == nil ) { [super orderFront:sender]; + _visibilityState = ITTransientStatusWindowVisibleState; } else { [self performEffect]; } + if ( _exitMode == ITTransientStatusWindowExitAfterDelay ) { + // set the timer, and orderOut: when it lapses. + } } - (void)makeKeyAndOrderFront:(id)sender @@ -148,8 +146,9 @@ static ITTransientStatusWindow *staticWindow = nil; // set the timer, and orderOut: when it lapses. } - if ( _entryEffect == ITTransientStatusWindowEffectNone ) { + if ( _entryEffect == nil ) { [super makeKeyAndOrderFront:sender]; + _visibilityState = ITTransientStatusWindowVisibleState; } else { [self performEffect]; [self makeKeyWindow]; @@ -158,14 +157,18 @@ static ITTransientStatusWindow *staticWindow = nil; - (void)orderOut:(id)sender { - if ( _entryEffect == ITTransientStatusWindowEffectNone ) { + if ( _entryEffect == nil ) { [super orderOut:sender]; + _visibilityState = ITTransientStatusWindowHiddenState; } else { [self performEffect]; } } -/* +- (NSTimeInterval)animationResizeTime:(NSRect)newFrame +{ + return _resizeTime; +} - (id)contentView { @@ -191,6 +194,32 @@ static ITTransientStatusWindow *staticWindow = nil; */ +- (void)appear +{ + if ( _entryEffect == nil ) { + [self orderFront:self]; + _visibilityState = ITTransientStatusWindowVisibleState; + } else { + _visibilityState = ITTransientStatusWindowAppearingState; + [_entryEffect performAppear]; + _visibilityState = ITTransientStatusWindowVisibleState; + } + if ( _exitMode == ITTransientStatusWindowExitAfterDelay ) { + // set the timer, and vanish when it lapses. + } +} + +- (void)vanish +{ + if ( _entryEffect == nil ) { + [self orderOut:self]; + _visibilityState = ITTransientStatusWindowHiddenState; + } else { + [_exitEffect performVanish]; + _visibilityState = ITTransientStatusWindowHiddenState; + } +} + - (ITTransientStatusWindowVisibilityState)visibilityState { return _visibilityState; @@ -229,44 +258,66 @@ 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)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]; } @@ -293,53 +344,30 @@ 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]; - } + _visibilityState = ITTransientStatusWindowEnteringState; } 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]; + _visibilityState = ITTransientStatusWindowExitingState; } else { - [super orderOut:self]; + return; } -} - -- (void)slideVerticalEffect:(BOOL)entering -{ - if ( entering ) { - [super orderFront:self]; - } else { - [super orderOut:self]; + + if ( _entryEffect == ITTransientStatusWindowEffectDissolve ) { + [self dissolveEffect]; + } else if ( _entryEffect == ITTransientStatusWindowEffectSlideVertically ) { + [self slideVerticalEffect]; + } else if ( _entryEffect == ITTransientStatusWindowEffectSlideHorizontally ) { + [self slideHorizontalEffect]; + } else if ( _entryEffect == ITTransientStatusWindowEffectPivot ) { + [self pivotEffect]; } } -- (void)slideHorizontalEffect:(BOOL)entering -{ - if ( entering ) { - [super orderFront:self]; - } else { - [super orderOut:self]; - } -} +*/ @end