1 #import "ITPivotWindowEffect.h"
2 #import "ITCoreGraphicsHacks.h"
3 #import "ITTransientStatusWindow.h"
6 @interface ITPivotWindowEffect (Private)
7 - (void)setPivot:(float)angle;
13 @implementation ITPivotWindowEffect
17 // Cast so the compiler won't gripe
18 [(ITTransientStatusWindow *)_window setVisibilityState:ITTransientStatusWindowAppearingState];
19 [self setPivot:315.0];
20 _effectProgress = 0.0;
21 [_window setAlphaValue:0.0];
22 [_window orderFront:self];
23 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
25 selector:@selector(appearStep)
32 // Cast so the compiler won't gripe
33 [(ITTransientStatusWindow *)_window setVisibilityState:ITTransientStatusWindowVanishingState];
35 _effectProgress = 1.0;
36 [_window setAlphaValue:1.0];
37 [_window orderFront:self];
38 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
40 selector:@selector(vanishStep)
48 [_window orderOut:self];
50 [_window setAlphaValue:1.0];
51 // Cast so the compiler won't gripe
52 [(ITTransientStatusWindow *)_window setVisibilityState:ITTransientStatusWindowHiddenState];
59 [_window setAlphaValue:1.0];
60 [_window orderFront:self];
62 // Cast so the compiler won't gripe
63 [(ITTransientStatusWindow *)_window setVisibilityState:ITTransientStatusWindowVisibleState];
68 float interPivot = 0.0;
69 _effectProgress += (1.0 / (EFFECT_FPS * _effectTime));
70 _effectProgress = (_effectProgress < 1.0 ? _effectProgress : 1.0);
71 interPivot = (( sin((_effectProgress * pi) - (pi / 2)) + 1 ) / 2);
72 [self setPivot:((interPivot * 45) + 315)];
73 [_window setAlphaValue:interPivot];
75 if ( _effectProgress >= 1.0 ) {
82 float interPivot = 1.0;
83 _effectProgress -= (1.0 / (EFFECT_FPS * _effectTime));
84 _effectProgress = (_effectProgress > 0.0 ? _effectProgress : 0.0);
85 interPivot = (( sin((_effectProgress * pi) - (pi / 2)) + 1 ) / 2);
86 [self setPivot:((interPivot * 45) + 315)];
87 [_window setAlphaValue:interPivot];
89 if ( _effectProgress <= 0.0 ) {
96 [_effectTimer invalidate];
98 // Cast so the compiler won't gripe
99 [(ITTransientStatusWindow *)_window setVisibilityState:ITTransientStatusWindowVisibleState];
104 [_effectTimer invalidate];
106 // Cast so the compiler won't gripe
107 [(ITTransientStatusWindow *)_window setVisibilityState:ITTransientStatusWindowHiddenState];
110 - (void)setPivot:(float)angle
112 float degAngle = (angle * (pi / 180));
113 CGAffineTransform transform = CGAffineTransformMakeRotation(degAngle);
115 // Set pivot rotation point
116 transform.tx = -32.0;
117 transform.ty = [_window frame].size.height + 32.0;
119 CGSSetWindowTransform([NSApp contextID],
120 (CGSWindowID)[_window windowNumber],
121 CGAffineTransformTranslate(transform,
122 (([_window frame].origin.x - 32.0) * -1),
123 (([[_window screen] frame].size.height - ([_window frame].origin.y) + 32.0) * -1) ));