1 #import "ITDissolveWindowEffect.h"
2 #import "ITTransientStatusWindow.h"
3 #import "ITCoreGraphicsHacks.h"
5 @interface ITDissolveWindowEffect (Private)
6 - (void)performAppearFromProgress:(float)progress effectTime:(float)time;
9 - (void)performVanishFromProgress:(float)progress effectTime:(float)time;
15 @implementation ITDissolveWindowEffect
18 + (NSString *)effectName
23 + (NSDictionary *)supportedPositions
25 return [NSDictionary dictionaryWithObjectsAndKeys:
26 [NSDictionary dictionaryWithObjectsAndKeys:
27 [NSNumber numberWithBool:YES], @"Left",
28 [NSNumber numberWithBool:YES], @"Center",
29 [NSNumber numberWithBool:YES], @"Right", nil] , @"Top" ,
30 [NSDictionary dictionaryWithObjectsAndKeys:
31 [NSNumber numberWithBool:YES], @"Left",
32 [NSNumber numberWithBool:YES], @"Center",
33 [NSNumber numberWithBool:YES], @"Right", nil] , @"Middle" ,
34 [NSDictionary dictionaryWithObjectsAndKeys:
35 [NSNumber numberWithBool:YES], @"Left",
36 [NSNumber numberWithBool:YES], @"Center",
37 [NSNumber numberWithBool:YES], @"Right", nil] , @"Bottom" , nil];
40 + (unsigned int)listOrder
46 /*************************************************************************/
48 #pragma mark APPEAR METHODS
49 /*************************************************************************/
53 CGAffineTransform transform;
57 //Set the location on the screen
58 if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionLeft ) {
59 appearPoint.x = -( 32.0 + [[_window screen] visibleFrame].origin.x );
60 } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionRight ) {
61 appearPoint.x = -(([[_window screen] visibleFrame].size.width + [[_window screen] visibleFrame].origin.x) - 32.0 - [_window frame].size.width);
62 } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionCenter ) {
63 appearPoint.x = ( [_window frame].size.width - [[_window screen] visibleFrame].size.width ) / 2;
66 if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionTop ) {
67 appearPoint.y = ( 64.0 + [[_window screen] visibleFrame].origin.y - [_window frame].size.height );
68 } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionBottom ) {
69 appearPoint.y = -( [[_window screen] frame].size.height - ( [_window frame].size.height + 32.0 + [[_window screen] visibleFrame].origin.y) );
70 } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionMiddle ) {
71 appearPoint.y = ( [_window frame].size.height - [[_window screen] visibleFrame].size.height) / 2;
74 transform = CGAffineTransformMakeTranslation(appearPoint.x, appearPoint.y);
75 CGSSetWindowTransform([NSApp contextID],
76 (CGSWindowID)[_window windowNumber],
79 [self setWindowVisibility:ITWindowAppearingState];
80 [self performAppearFromProgress:0.0 effectTime:_effectTime];
83 - (void)performAppearFromProgress:(float)progress effectTime:(float)time
85 [_window setEffectProgress:progress];
86 _effectSpeed = (1.0 / (EFFECT_FPS * time));
88 if ( progress == 0.0 ) {
89 [_window setAlphaValue:0.0];
92 [_window orderFront:self];
93 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
95 selector:@selector(appearStep)
102 float interFade = 0.0;
103 [_window setEffectProgress:([_window effectProgress] + _effectSpeed)];
104 [_window setEffectProgress:( ([_window effectProgress] < 1.0) ? [_window effectProgress] : 1.0)];
105 interFade = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
106 [_window setAlphaValue:interFade];
108 if ( [_window effectProgress] >= 1.0 ) {
115 [_effectTimer invalidate];
117 [self setWindowVisibility:ITWindowVisibleState];
121 if ( __shouldReleaseWhenIdle ) {
128 [self setWindowVisibility:ITWindowVanishingState];
130 [_effectTimer invalidate];
133 [self performVanishFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)];
137 /*************************************************************************/
139 #pragma mark VANISH METHODS
140 /*************************************************************************/
142 - (void)performVanish
146 [self setWindowVisibility:ITWindowVanishingState];
147 [self performVanishFromProgress:1.0 effectTime:_effectTime];
150 - (void)performVanishFromProgress:(float)progress effectTime:(float)time
152 [_window setEffectProgress:progress];
153 _effectSpeed = (1.0 / (EFFECT_FPS * time));
154 if ( progress == 1.0 ) {
155 [_window setAlphaValue:1.0];
158 [_window orderFront:self];
159 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
161 selector:@selector(vanishStep)
168 float interFade = 1.0;
169 [_window setEffectProgress:([_window effectProgress] - _effectSpeed)];
170 [_window setEffectProgress:( ([_window effectProgress] > 0.0) ? [_window effectProgress] : 0.0)];
171 interFade = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
172 [_window setAlphaValue:interFade];
174 if ( [_window effectProgress] <= 0.0 ) {
181 [_effectTimer invalidate];
183 [_window orderOut:self];
184 [_window setAlphaValue:1.0];
185 [self setWindowVisibility:ITWindowHiddenState];
189 if ( __shouldReleaseWhenIdle ) {
196 [self setWindowVisibility:ITWindowVanishingState];
198 [_effectTimer invalidate];
201 [self performAppearFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)];