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 /*************************************************************************/
29 [self setWindowVisibility:ITWindowAppearingState];
30 [self performAppearFromProgress:0.0 effectTime:_effectTime];
33 - (void)performAppearFromProgress:(float)progress effectTime:(float)time
35 [_window setEffectProgress:progress];
36 _effectSpeed = (1.0 / (EFFECT_FPS * time));
38 if ( progress == 0.0 ) {
39 [self setPivot:315.0];
40 [_window setAlphaValue:0.0];
43 [_window orderFront:self];
44 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
46 selector:@selector(appearStep)
53 float interPivot = 0.0;
54 [_window setEffectProgress:([_window effectProgress] + _effectSpeed)];
55 [_window setEffectProgress:( ([_window effectProgress] < 1.0) ? [_window effectProgress] : 1.0)];
56 interPivot = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
57 [self setPivot:((interPivot * 45) + 315)];
58 [_window setAlphaValue:interPivot];
60 if ( [_window effectProgress] >= 1.0 ) {
67 [_effectTimer invalidate];
69 [self setWindowVisibility:ITWindowVisibleState];
73 if ( __shouldReleaseWhenIdle ) {
80 [self setWindowVisibility:ITWindowVanishingState];
82 [_effectTimer invalidate];
85 [self performVanishFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)];
89 /*************************************************************************/
91 #pragma mark VANISH METHODS
92 /*************************************************************************/
98 [self setWindowVisibility:ITWindowVanishingState];
99 [self performVanishFromProgress:1.0 effectTime:_effectTime];
102 - (void)performVanishFromProgress:(float)progress effectTime:(float)time
104 [_window setEffectProgress:progress];
105 _effectSpeed = (1.0 / (EFFECT_FPS * time));
106 if ( progress == 1.0 ) {
108 [_window setAlphaValue:1.0];
111 [_window orderFront:self];
112 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
114 selector:@selector(vanishStep)
121 float interPivot = 1.0;
122 [_window setEffectProgress:([_window effectProgress] - _effectSpeed)];
123 [_window setEffectProgress:( ([_window effectProgress] > 0.0) ? [_window effectProgress] : 0.0)];
124 interPivot = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
125 [self setPivot:((interPivot * 45) + 315)];
126 [_window setAlphaValue:interPivot];
128 if ( [_window effectProgress] <= 0.0 ) {
135 [_effectTimer invalidate];
137 [_window orderOut:self];
138 [_window setAlphaValue:1.0];
140 [self setWindowVisibility:ITWindowHiddenState];
144 if ( __shouldReleaseWhenIdle ) {
151 [self setWindowVisibility:ITWindowAppearingState];
153 [_effectTimer invalidate];
156 [self performAppearFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)];
160 /*************************************************************************/
162 #pragma mark PRIVATE METHOD IMPLEMENTATIONS
163 /*************************************************************************/
165 - (void)setPivot:(float)angle
167 float degAngle = (angle * (pi / 180));
169 CGAffineTransform transform = CGAffineTransformMakeRotation(degAngle);
171 // Set pivot rotation point
172 transform.tx = -( 32.0 + [[_window screen] visibleFrame].origin.x );
173 transform.ty = ( [_window frame].size.height + 32.0 + [[_window screen] visibleFrame].origin.y );
175 CGSSetWindowTransform([NSApp contextID],
176 (CGSWindowID)[_window windowNumber],
177 CGAffineTransformTranslate( transform,
178 -( [_window frame].origin.x - (32.0 + [[_window screen] visibleFrame].origin.x) ),
179 -( [[_window screen] frame].size.height - ([_window frame].origin.y) + 32.0 + [[_window screen] visibleFrame].origin.y) ) );