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 /*************************************************************************/
20 #pragma mark APPEAR METHODS
21 /*************************************************************************/
25 CGAffineTransform transform;
29 //Set the location on the screen
30 if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionLeft ) {
31 appearPoint.x = -( 32.0 + [[_window screen] visibleFrame].origin.x );
32 } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionRight ) {
33 appearPoint.x = -(([[_window screen] visibleFrame].size.width + [[_window screen] visibleFrame].origin.x) - 32.0 - [_window frame].size.width);
34 } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionCenter ) {
35 appearPoint.x = ( [_window frame].size.width - [[_window screen] visibleFrame].size.width ) / 2;
38 if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionTop ) {
39 appearPoint.y = ( 64.0 + [[_window screen] visibleFrame].origin.y - [_window frame].size.height );
40 } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionBottom ) {
41 appearPoint.y = -( [[_window screen] frame].size.height - ( [_window frame].size.height + 32.0 + [[_window screen] visibleFrame].origin.y) );
42 } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionMiddle ) {
43 appearPoint.y = ( [_window frame].size.height - [[_window screen] visibleFrame].size.height) / 2;
46 transform = CGAffineTransformMakeTranslation(appearPoint.x, appearPoint.y);
47 CGSSetWindowTransform([NSApp contextID],
48 (CGSWindowID)[_window windowNumber],
51 [self setWindowVisibility:ITWindowAppearingState];
52 [self performAppearFromProgress:0.0 effectTime:_effectTime];
55 - (void)performAppearFromProgress:(float)progress effectTime:(float)time
57 [_window setEffectProgress:progress];
58 _effectSpeed = (1.0 / (EFFECT_FPS * time));
60 if ( progress == 0.0 ) {
61 [_window setAlphaValue:0.0];
64 [_window orderFront:self];
65 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
67 selector:@selector(appearStep)
74 float interFade = 0.0;
75 [_window setEffectProgress:([_window effectProgress] + _effectSpeed)];
76 [_window setEffectProgress:( ([_window effectProgress] < 1.0) ? [_window effectProgress] : 1.0)];
77 interFade = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
78 [_window setAlphaValue:interFade];
80 if ( [_window effectProgress] >= 1.0 ) {
87 [_effectTimer invalidate];
89 [self setWindowVisibility:ITWindowVisibleState];
93 if ( __shouldReleaseWhenIdle ) {
100 [self setWindowVisibility:ITWindowVanishingState];
102 [_effectTimer invalidate];
105 [self performVanishFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)];
109 /*************************************************************************/
111 #pragma mark VANISH METHODS
112 /*************************************************************************/
114 - (void)performVanish
118 [self setWindowVisibility:ITWindowVanishingState];
119 [self performVanishFromProgress:1.0 effectTime:_effectTime];
122 - (void)performVanishFromProgress:(float)progress effectTime:(float)time
124 [_window setEffectProgress:progress];
125 _effectSpeed = (1.0 / (EFFECT_FPS * time));
126 if ( progress == 1.0 ) {
127 [_window setAlphaValue:1.0];
130 [_window orderFront:self];
131 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
133 selector:@selector(vanishStep)
140 float interFade = 1.0;
141 [_window setEffectProgress:([_window effectProgress] - _effectSpeed)];
142 [_window setEffectProgress:( ([_window effectProgress] > 0.0) ? [_window effectProgress] : 0.0)];
143 interFade = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
144 [_window setAlphaValue:interFade];
146 if ( [_window effectProgress] <= 0.0 ) {
153 [_effectTimer invalidate];
155 [_window orderOut:self];
156 [_window setAlphaValue:1.0];
157 [self setWindowVisibility:ITWindowHiddenState];
161 if ( __shouldReleaseWhenIdle ) {
168 [self setWindowVisibility:ITWindowVanishingState];
170 [_effectTimer invalidate];
173 [self performAppearFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)];