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 [self setWindowVisibility:ITTransientStatusWindowAppearingState];
18 [self setPivot:315.0];
19 _effectProgress = 0.0;
20 [_window setAlphaValue:0.0];
21 [_window orderFront:self];
22 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
24 selector:@selector(appearStep)
31 [self setWindowVisibility:ITTransientStatusWindowVanishingState];
33 _effectProgress = 1.0;
34 [_window setAlphaValue:1.0];
35 [_window orderFront:self];
36 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
38 selector:@selector(vanishStep)
46 [_window orderOut:self];
48 [_window setAlphaValue:1.0];
49 [self setWindowVisibility:ITTransientStatusWindowHiddenState];
56 [_window setAlphaValue:1.0];
57 [_window orderFront:self];
59 [self setWindowVisibility:ITTransientStatusWindowVisibleState];
64 float interPivot = 0.0;
65 _effectProgress += (1.0 / (EFFECT_FPS * _effectTime));
66 _effectProgress = (_effectProgress < 1.0 ? _effectProgress : 1.0);
67 interPivot = (( sin((_effectProgress * pi) - (pi / 2)) + 1 ) / 2);
68 [self setPivot:((interPivot * 45) + 315)];
69 [_window setAlphaValue:interPivot];
71 if ( _effectProgress >= 1.0 ) {
78 float interPivot = 1.0;
79 _effectProgress -= (1.0 / (EFFECT_FPS * _effectTime));
80 _effectProgress = (_effectProgress > 0.0 ? _effectProgress : 0.0);
81 interPivot = (( sin((_effectProgress * pi) - (pi / 2)) + 1 ) / 2);
82 [self setPivot:((interPivot * 45) + 315)];
83 [_window setAlphaValue:interPivot];
85 if ( _effectProgress <= 0.0 ) {
92 [_effectTimer invalidate];
94 [self setWindowVisibility:ITTransientStatusWindowVisibleState];
99 [_effectTimer invalidate];
101 [self setWindowVisibility:ITTransientStatusWindowHiddenState];
104 - (void)setPivot:(float)angle
106 float degAngle = (angle * (pi / 180));
107 CGAffineTransform transform = CGAffineTransformMakeRotation(degAngle);
109 // Set pivot rotation point
110 transform.tx = -32.0;
111 transform.ty = [_window frame].size.height + 32.0;
113 CGSSetWindowTransform([NSApp contextID],
114 (CGSWindowID)[_window windowNumber],
115 CGAffineTransformTranslate(transform,
116 (([_window frame].origin.x - 32.0) * -1),
117 (([[_window screen] frame].size.height - ([_window frame].origin.y) + 32.0) * -1) ));