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 /*************************************************************************/
55 [self setWindowVisibility:ITWindowAppearingState];
56 [self performAppearFromProgress:0.0 effectTime:_effectTime];
59 - (void)performAppearFromProgress:(float)progress effectTime:(float)time
61 [_window setEffectProgress:progress];
62 _effectSpeed = (1.0 / (EFFECT_FPS * time));
64 if ( progress == 0.0 ) {
65 [_window setAlphaValue:0.0];
68 [_window orderFront:self];
69 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
71 selector:@selector(appearStep)
78 float interFade = 0.0;
79 [_window setEffectProgress:([_window effectProgress] + _effectSpeed)];
80 [_window setEffectProgress:( ([_window effectProgress] < 1.0) ? [_window effectProgress] : 1.0)];
81 interFade = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
82 [_window setAlphaValue:interFade];
84 if ( [_window effectProgress] >= 1.0 ) {
91 [_effectTimer invalidate];
93 [self setWindowVisibility:ITWindowVisibleState];
97 if ( __shouldReleaseWhenIdle ) {
104 [self setWindowVisibility:ITWindowVanishingState];
106 [_effectTimer invalidate];
109 [self performVanishFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)];
113 /*************************************************************************/
115 #pragma mark VANISH METHODS
116 /*************************************************************************/
118 - (void)performVanish
122 [self setWindowVisibility:ITWindowVanishingState];
123 [self performVanishFromProgress:1.0 effectTime:_effectTime];
126 - (void)performVanishFromProgress:(float)progress effectTime:(float)time
128 [_window setEffectProgress:progress];
129 _effectSpeed = (1.0 / (EFFECT_FPS * time));
130 if ( progress == 1.0 ) {
131 [_window setAlphaValue:1.0];
134 [_window orderFront:self];
135 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
137 selector:@selector(vanishStep)
144 float interFade = 1.0;
145 [_window setEffectProgress:([_window effectProgress] - _effectSpeed)];
146 [_window setEffectProgress:( ([_window effectProgress] > 0.0) ? [_window effectProgress] : 0.0)];
147 interFade = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
148 [_window setAlphaValue:interFade];
150 if ( [_window effectProgress] <= 0.0 ) {
157 [_effectTimer invalidate];
159 [_window orderOut:self];
160 [_window setAlphaValue:1.0];
161 [self setWindowVisibility:ITWindowHiddenState];
165 if ( __shouldReleaseWhenIdle ) {
172 [self setWindowVisibility:ITWindowVanishingState];
174 [_effectTimer invalidate];
177 [self performAppearFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)];