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;
9 - (void)performVanishFromProgress:(float)progress effectTime:(float)time;
15 @implementation ITPivotWindowEffect
19 [self setWindowVisibility:ITTransientStatusWindowAppearingState];
20 [self performAppearFromProgress:0.0 effectTime:_effectTime];
23 - (void)performAppearFromProgress:(float)progress effectTime:(float)time
25 _effectProgress = progress;
26 _effectSpeed = (1.0 / (EFFECT_FPS * time));
28 if ( progress == 0.0 ) {
29 [self setPivot:315.0];
30 [_window setAlphaValue:0.0];
33 [_window orderFront:self];
34 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
36 selector:@selector(appearStep)
43 [self setWindowVisibility:ITTransientStatusWindowVanishingState];
44 [self performVanishFromProgress:1.0 effectTime:_effectTime];
47 - (void)performVanishFromProgress:(float)progress effectTime:(float)time
49 _effectProgress = progress;
50 _effectSpeed = (1.0 / (EFFECT_FPS * time));
51 if ( progress == 1.0 ) {
53 [_window setAlphaValue:1.0];
56 [_window orderFront:self];
57 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
59 selector:@selector(vanishStep)
66 [self setWindowVisibility:ITTransientStatusWindowVanishingState];
68 [_effectTimer invalidate];
71 [self performVanishFromProgress:_effectProgress effectTime:(_effectTime / 3.5)];
76 [self setWindowVisibility:ITTransientStatusWindowAppearingState];
78 [_effectTimer invalidate];
81 [self performAppearFromProgress:_effectProgress effectTime:(_effectTime / 3.5)];
86 float interPivot = 0.0;
87 _effectProgress += _effectSpeed;
88 _effectProgress = (_effectProgress < 1.0 ? _effectProgress : 1.0);
89 interPivot = (( sin((_effectProgress * pi) - (pi / 2)) + 1 ) / 2);
90 [self setPivot:((interPivot * 45) + 315)];
91 [_window setAlphaValue:interPivot];
93 if ( _effectProgress >= 1.0 ) {
100 float interPivot = 1.0;
101 _effectProgress -= _effectSpeed;
102 _effectProgress = (_effectProgress > 0.0 ? _effectProgress : 0.0);
103 interPivot = (( sin((_effectProgress * pi) - (pi / 2)) + 1 ) / 2);
104 [self setPivot:((interPivot * 45) + 315)];
105 [_window setAlphaValue:interPivot];
107 if ( _effectProgress <= 0.0 ) {
114 [_effectTimer invalidate];
116 [self setWindowVisibility:ITTransientStatusWindowVisibleState];
121 [_effectTimer invalidate];
123 [self setWindowVisibility:ITTransientStatusWindowHiddenState];
126 - (void)setPivot:(float)angle
128 float degAngle = (angle * (pi / 180));
130 CGAffineTransform transform = CGAffineTransformMakeRotation(degAngle);
132 // Set pivot rotation point
133 transform.tx = -32.0;
134 transform.ty = [_window frame].size.height + 32.0;
136 CGSSetWindowTransform([NSApp contextID],
137 (CGSWindowID)[_window windowNumber],
138 CGAffineTransformTranslate(transform,
139 (([_window frame].origin.x - 32.0) * -1),
140 (([[_window screen] frame].size.height - ([_window frame].origin.y) + 32.0) * -1) ));