1 #import "ITPivotWindowEffect.h"
2 #import "ITCoreGraphicsHacks.h"
3 #import "ITTransientStatusWindow.h"
6 @interface ITPivotWindowEffect (Private)
7 - (void)setPivot:(float)angle;
8 - (void)performAppearFromProgress:(float)progress effectTime:(float)time;
11 - (void)performVanishFromProgress:(float)progress effectTime:(float)time;
17 @implementation ITPivotWindowEffect
20 /*************************************************************************/
22 #pragma mark APPEAR METHODS
23 /*************************************************************************/
27 [self setWindowVisibility:ITTransientStatusWindowAppearingState];
28 [self performAppearFromProgress:0.0 effectTime:_effectTime];
31 - (void)performAppearFromProgress:(float)progress effectTime:(float)time
33 [_window setEffectProgress:progress];
34 _effectSpeed = (1.0 / (EFFECT_FPS * time));
36 if ( progress == 0.0 ) {
37 [self setPivot:315.0];
38 [_window setAlphaValue:0.0];
41 [_window orderFront:self];
42 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
44 selector:@selector(appearStep)
51 float interPivot = 0.0;
52 [_window setEffectProgress:([_window effectProgress] + _effectSpeed)];
53 [_window setEffectProgress:( ([_window effectProgress] < 1.0) ? [_window effectProgress] : 1.0)];
54 interPivot = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
55 [self setPivot:((interPivot * 45) + 315)];
56 [_window setAlphaValue:interPivot];
58 if ( [_window effectProgress] >= 1.0 ) {
65 [_effectTimer invalidate];
67 [self setWindowVisibility:ITTransientStatusWindowVisibleState];
72 [self setWindowVisibility:ITTransientStatusWindowVanishingState];
74 [_effectTimer invalidate];
77 [self performVanishFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)];
81 /*************************************************************************/
83 #pragma mark VANISH METHODS
84 /*************************************************************************/
88 [self setWindowVisibility:ITTransientStatusWindowVanishingState];
89 [self performVanishFromProgress:1.0 effectTime:_effectTime];
92 - (void)performVanishFromProgress:(float)progress effectTime:(float)time
94 [_window setEffectProgress:progress];
95 _effectSpeed = (1.0 / (EFFECT_FPS * time));
96 if ( progress == 1.0 ) {
98 [_window setAlphaValue:1.0];
101 [_window orderFront:self];
102 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
104 selector:@selector(vanishStep)
111 float interPivot = 1.0;
112 [_window setEffectProgress:([_window effectProgress] - _effectSpeed)];
113 [_window setEffectProgress:( ([_window effectProgress] > 0.0) ? [_window effectProgress] : 0.0)];
114 interPivot = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
115 [self setPivot:((interPivot * 45) + 315)];
116 [_window setAlphaValue:interPivot];
118 if ( [_window effectProgress] <= 0.0 ) {
125 [_effectTimer invalidate];
127 [_window orderOut:self];
128 [_window setAlphaValue:1.0];
129 [self setWindowVisibility:ITTransientStatusWindowHiddenState];
134 [self setWindowVisibility:ITTransientStatusWindowAppearingState];
136 [_effectTimer invalidate];
139 [self performAppearFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)];
143 /*************************************************************************/
145 #pragma mark PRIVATE METHOD IMPLEMENTATIONS
146 /*************************************************************************/
148 - (void)setPivot:(float)angle
150 float degAngle = (angle * (pi / 180));
152 CGAffineTransform transform = CGAffineTransformMakeRotation(degAngle);
154 // Set pivot rotation point
155 transform.tx = -32.0;
156 transform.ty = [_window frame].size.height + 32.0;
158 CGSSetWindowTransform([NSApp contextID],
159 (CGSWindowID)[_window windowNumber],
160 CGAffineTransformTranslate(transform,
161 (([_window frame].origin.x - 32.0) * -1),
162 (([[_window screen] frame].size.height - ([_window frame].origin.y) + 32.0) * -1) ));