1 #import "ITSlideHorizontallyWindowEffect.h"
2 #import "ITCoreGraphicsHacks.h"
3 #import "ITTransientStatusWindow.h"
6 @interface ITSlideHorizontallyWindowEffect (Private)
7 - (void)performAppearFromProgress:(float)progress effectTime:(float)time;
10 - (void)performVanishFromProgress:(float)progress effectTime:(float)time;
13 - (void)setSlide:(float)distance;
17 @implementation ITSlideHorizontallyWindowEffect
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 [_window setAlphaValue:0.0];
42 [_window orderFront:self];
43 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
45 selector:@selector(appearStep)
52 float interSlide = 0.0;
53 [_window setEffectProgress:([_window effectProgress] + _effectSpeed)];
54 [_window setEffectProgress:( ([_window effectProgress] < 1.0) ? [_window effectProgress] : 1.0)];
55 interSlide = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
56 [self setSlide:( [_window frame].size.width - (interSlide * [_window frame].size.width) )];
57 [_window setAlphaValue:interSlide];
59 if ( [_window effectProgress] >= 1.0 ) {
66 [_effectTimer invalidate];
68 [self setWindowVisibility:ITWindowVisibleState];
72 if ( __shouldReleaseWhenIdle ) {
79 [self setWindowVisibility:ITWindowVanishingState];
81 [_effectTimer invalidate];
84 [self performVanishFromProgress:[_window effectProgress] effectTime:(_effectTime / 4.0)];
88 /*************************************************************************/
90 #pragma mark VANISH METHODS
91 /*************************************************************************/
97 [self setWindowVisibility:ITWindowVanishingState];
98 [self performVanishFromProgress:1.0 effectTime:_effectTime];
101 - (void)performVanishFromProgress:(float)progress effectTime:(float)time
103 [_window setEffectProgress:progress];
104 _effectSpeed = (1.0 / (EFFECT_FPS * time));
105 if ( progress == 1.0 ) {
106 [_window setAlphaValue:1.0];
109 [_window orderFront:self];
110 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
112 selector:@selector(vanishStep)
119 float interSlide = 1.0;
120 [_window setEffectProgress:([_window effectProgress] - _effectSpeed)];
121 [_window setEffectProgress:( ([_window effectProgress] > 0.0) ? [_window effectProgress] : 0.0)];
122 interSlide = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
123 [self setSlide:( [_window frame].size.width - (interSlide * [_window frame].size.width) )];
124 [_window setAlphaValue:interSlide];
126 if ( [_window effectProgress] <= 0.0 ) {
133 [_effectTimer invalidate];
135 [_window orderOut:self];
136 [_window setAlphaValue:1.0];
138 [self setWindowVisibility:ITWindowHiddenState];
142 if ( __shouldReleaseWhenIdle ) {
149 [self setWindowVisibility:ITWindowAppearingState];
151 [_effectTimer invalidate];
154 [self performAppearFromProgress:[_window effectProgress] effectTime:(_effectTime / 4.0)];
157 - (void)setSlide:(float)distance
159 CGAffineTransform transform;
160 if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionLeft ) {
161 NSLog(@"%f", (distance - (32.0 + [[_window screen] visibleFrame].origin.x)));
162 transform = CGAffineTransformMakeTranslation((distance - (32.0 + [[_window screen] visibleFrame].origin.x)),
163 -( [[_window screen] frame].size.height - ( [_window frame].size.height + 32.0 + [[_window screen] visibleFrame].origin.y) ) );
164 } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionRight ) {
165 NSLog(@"%f", [[_window screen] visibleFrame].size.width - ([_window frame].size.width - distance));
166 transform = CGAffineTransformMakeTranslation((32.0 - (([[_window screen] visibleFrame].size.width / 2) + distance)),
167 -( [[_window screen] frame].size.height - ( [_window frame].size.height + 32.0 + [[_window screen] visibleFrame].origin.y) ) );
170 CGSSetWindowTransform([NSApp contextID],
171 (CGSWindowID)[_window windowNumber],