1 #import "ITPivotWindowEffect.h"
2 #import "ITCoreGraphicsHacks.h"
4 @interface ITPivotWindowEffect (Private)
5 - (void)setPivot:(float)angle;
9 @implementation ITPivotWindowEffect
14 [self setPivot:315.0];
15 _effectProgress = 0.0;
16 [_window setAlphaValue:0.0];
17 [_window orderFront:self];
18 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
20 selector:@selector(appearStep)
28 _effectProgress = 1.0;
29 [_window setAlphaValue:1.0];
30 [_window orderFront:self];
31 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
33 selector:@selector(vanishStep)
41 [_window orderOut:self];
43 [_window setAlphaValue:1.0];
50 [_window setAlphaValue:1.0];
51 [_window orderFront:self];
57 float interPivot = 0.0;
58 _effectProgress += (1.0 / (EFFECT_FPS * _effectTime));
59 _effectProgress = (_effectProgress < 1.0 ? _effectProgress : 1.0);
60 interPivot = (( sin((_effectProgress * pi) - (pi / 2)) + 1 ) / 2);
61 [self setPivot:((interPivot * 45) + 315)];
62 [_window setAlphaValue:interPivot];
64 if ( _effectProgress >= 1.0 ) {
71 float interPivot = 1.0;
72 _effectProgress -= (1.0 / (EFFECT_FPS * _effectTime));
73 _effectProgress = (_effectProgress > 0.0 ? _effectProgress : 0.0);
74 interPivot = (( sin((_effectProgress * pi) - (pi / 2)) + 1 ) / 2);
75 [self setPivot:((interPivot * 45) + 315)];
76 [_window setAlphaValue:interPivot];
78 if ( _effectProgress <= 0.0 ) {
85 [_effectTimer invalidate];
90 - (void)setPivot:(float)angle
92 float degAngle = (angle * (pi / 180));
93 CGAffineTransform transform = CGAffineTransformMakeRotation(degAngle);
95 // Set pivot rotation point
97 transform.ty = [_window frame].size.height + 32.0;
99 CGSSetWindowTransform([NSApp contextID],
100 (CGSWindowID)[_window windowNumber],
101 CGAffineTransformTranslate(transform,
102 (([_window frame].origin.x - 32.0) * -1),
103 (([[_window screen] frame].size.height - ([_window frame].origin.y) + 32.0) * -1) ));