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];
41 /*************************************************************************/
43 #pragma mark APPEAR METHODS
44 /*************************************************************************/
48 CGAffineTransform transform;
52 //Set the location on the screen
53 if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionLeft ) {
54 appearPoint.x = -( 32.0 + [[_window screen] visibleFrame].origin.x );
55 } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionRight ) {
56 appearPoint.x = -(([[_window screen] visibleFrame].size.width + [[_window screen] visibleFrame].origin.x) - 32.0 - [_window frame].size.width);
57 } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionCenter ) {
58 appearPoint.x = ( [_window frame].size.width - [[_window screen] visibleFrame].size.width ) / 2;
61 if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionTop ) {
62 appearPoint.y = ( 64.0 + [[_window screen] visibleFrame].origin.y - [_window frame].size.height );
63 } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionBottom ) {
64 appearPoint.y = -( [[_window screen] frame].size.height - ( [_window frame].size.height + 32.0 + [[_window screen] visibleFrame].origin.y) );
65 } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionMiddle ) {
66 appearPoint.y = ( [_window frame].size.height - [[_window screen] visibleFrame].size.height) / 2;
69 transform = CGAffineTransformMakeTranslation(appearPoint.x, appearPoint.y);
70 CGSSetWindowTransform([NSApp contextID],
71 (CGSWindowID)[_window windowNumber],
74 [self setWindowVisibility:ITWindowAppearingState];
75 [self performAppearFromProgress:0.0 effectTime:_effectTime];
78 - (void)performAppearFromProgress:(float)progress effectTime:(float)time
80 [_window setEffectProgress:progress];
81 _effectSpeed = (1.0 / (EFFECT_FPS * time));
83 if ( progress == 0.0 ) {
84 [_window setAlphaValue:0.0];
87 [_window orderFront:self];
88 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
90 selector:@selector(appearStep)
97 float interFade = 0.0;
98 [_window setEffectProgress:([_window effectProgress] + _effectSpeed)];
99 [_window setEffectProgress:( ([_window effectProgress] < 1.0) ? [_window effectProgress] : 1.0)];
100 interFade = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
101 [_window setAlphaValue:interFade];
103 if ( [_window effectProgress] >= 1.0 ) {
110 [_effectTimer invalidate];
112 [self setWindowVisibility:ITWindowVisibleState];
116 if ( __shouldReleaseWhenIdle ) {
123 [self setWindowVisibility:ITWindowVanishingState];
125 [_effectTimer invalidate];
128 [self performVanishFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)];
132 /*************************************************************************/
134 #pragma mark VANISH METHODS
135 /*************************************************************************/
137 - (void)performVanish
141 [self setWindowVisibility:ITWindowVanishingState];
142 [self performVanishFromProgress:1.0 effectTime:_effectTime];
145 - (void)performVanishFromProgress:(float)progress effectTime:(float)time
147 [_window setEffectProgress:progress];
148 _effectSpeed = (1.0 / (EFFECT_FPS * time));
149 if ( progress == 1.0 ) {
150 [_window setAlphaValue:1.0];
153 [_window orderFront:self];
154 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
156 selector:@selector(vanishStep)
163 float interFade = 1.0;
164 [_window setEffectProgress:([_window effectProgress] - _effectSpeed)];
165 [_window setEffectProgress:( ([_window effectProgress] > 0.0) ? [_window effectProgress] : 0.0)];
166 interFade = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
167 [_window setAlphaValue:interFade];
169 if ( [_window effectProgress] <= 0.0 ) {
176 [_effectTimer invalidate];
178 [_window orderOut:self];
179 [_window setAlphaValue:1.0];
180 [self setWindowVisibility:ITWindowHiddenState];
184 if ( __shouldReleaseWhenIdle ) {
191 [self setWindowVisibility:ITWindowVanishingState];
193 [_effectTimer invalidate];
196 [self performAppearFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)];