1 #import "ITSlideVerticallyWindowEffect.h"
2 #import "ITCoreGraphicsHacks.h"
3 #import "ITTransientStatusWindow.h"
6 @interface ITSlideVerticallyWindowEffect (Private)
7 - (void)performAppearFromProgress:(float)progress effectTime:(float)time;
10 - (void)performVanishFromProgress:(float)progress effectTime:(float)time;
13 - (void)setSlide:(float)distance;
17 @implementation ITSlideVerticallyWindowEffect
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:(interSlide * [_window frame].size.height)];
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:(interSlide * [_window frame].size.height)];
124 [_window setAlphaValue:interSlide];
126 if ( [_window effectProgress] <= 0.0 ) {
133 [_effectTimer invalidate];
135 [_window orderOut:self];
136 [_window setAlphaValue:1.0];
137 [self setSlide:[_window frame].size.height];
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;
162 if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionLeft ) {
163 xPoint = -( 32.0 + [[_window screen] visibleFrame].origin.x );
164 } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionRight ) {
165 xPoint = -(([[_window screen] visibleFrame].size.width + [[_window screen] visibleFrame].origin.x) - 32.0 - [_window frame].size.width);
166 } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionCenter ) {
167 xPoint = ( [_window frame].size.width - [[_window screen] visibleFrame].size.width ) / 2;
170 /*if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionBottom ) {
171 transform = CGAffineTransformMakeTranslation( ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionLeft ) ? -( 32.0 + [[_window screen] visibleFrame].origin.x ) : -(([[_window screen] visibleFrame].size.width + [[_window screen] visibleFrame].origin.x) - 32.0 - [_window frame].size.width),
172 -( [[_window screen] frame].size.height - ( distance + 32.0 + [[_window screen] visibleFrame].origin.y ) ) );
173 } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionTop ) {
174 transform = CGAffineTransformMakeTranslation( ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionLeft ) ? -( 32.0 + [[_window screen] visibleFrame].origin.x ) : -(([[_window screen] visibleFrame].size.width + [[_window screen] visibleFrame].origin.x) - 32.0 - [_window frame].size.width),
175 [[_window screen] visibleFrame].origin.y - distance + 64.0 );
178 transform = CGAffineTransformMakeTranslation(xPoint,
179 ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionTop ) ? ( [[_window screen] visibleFrame].origin.y - distance + 64.0 ) : -( [[_window screen] frame].size.height - ( distance + 32.0 + [[_window screen] visibleFrame].origin.y ) ) );
181 CGSSetWindowTransform([NSApp contextID],
182 (CGSWindowID)[_window windowNumber],