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 + (NSString *)effectName
22 return @"Slide Vertically";
25 + (NSDictionary *)supportedPositions
27 return [NSDictionary dictionaryWithObjectsAndKeys:
28 [NSDictionary dictionaryWithObjectsAndKeys:
29 [NSNumber numberWithBool:YES], @"Left",
30 [NSNumber numberWithBool:YES], @"Center",
31 [NSNumber numberWithBool:YES], @"Right", nil] , @"Top" ,
32 [NSDictionary dictionaryWithObjectsAndKeys:
33 [NSNumber numberWithBool:NO], @"Left",
34 [NSNumber numberWithBool:NO], @"Center",
35 [NSNumber numberWithBool:NO], @"Right", nil] , @"Middle" ,
36 [NSDictionary dictionaryWithObjectsAndKeys:
37 [NSNumber numberWithBool:YES], @"Left",
38 [NSNumber numberWithBool:YES], @"Center",
39 [NSNumber numberWithBool:YES], @"Right", nil] , @"Bottom" , nil];
43 + (unsigned int)listOrder
49 /*************************************************************************/
51 #pragma mark APPEAR METHODS
52 /*************************************************************************/
58 [self setWindowVisibility:ITWindowAppearingState];
59 [self performAppearFromProgress:0.0 effectTime:_effectTime];
62 - (void)performAppearFromProgress:(float)progress effectTime:(float)time
64 [_window setEffectProgress:progress];
65 _effectSpeed = (1.0 / (EFFECT_FPS * time));
67 if ( progress == 0.0 ) {
68 [_window setAlphaValue:0.0];
71 [_window orderFront:self];
72 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
74 selector:@selector(appearStep)
81 float interSlide = 0.0;
82 [_window setEffectProgress:([_window effectProgress] + _effectSpeed)];
83 [_window setEffectProgress:( ([_window effectProgress] < 1.0) ? [_window effectProgress] : 1.0)];
84 interSlide = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
85 [self setSlide:(interSlide * [_window frame].size.height)];
86 [_window setAlphaValue:interSlide];
88 if ( [_window effectProgress] >= 1.0 ) {
95 [_effectTimer invalidate];
97 [self setWindowVisibility:ITWindowVisibleState];
101 if ( __shouldReleaseWhenIdle ) {
108 [self setWindowVisibility:ITWindowVanishingState];
110 [_effectTimer invalidate];
113 [self performVanishFromProgress:[_window effectProgress] effectTime:(_effectTime / 4.0)];
117 /*************************************************************************/
119 #pragma mark VANISH METHODS
120 /*************************************************************************/
122 - (void)performVanish
126 [self setWindowVisibility:ITWindowVanishingState];
127 [self performVanishFromProgress:1.0 effectTime:_effectTime];
130 - (void)performVanishFromProgress:(float)progress effectTime:(float)time
132 [_window setEffectProgress:progress];
133 _effectSpeed = (1.0 / (EFFECT_FPS * time));
134 if ( progress == 1.0 ) {
135 [_window setAlphaValue:1.0];
138 [_window orderFront:self];
139 _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS)
141 selector:@selector(vanishStep)
148 float interSlide = 1.0;
149 [_window setEffectProgress:([_window effectProgress] - _effectSpeed)];
150 [_window setEffectProgress:( ([_window effectProgress] > 0.0) ? [_window effectProgress] : 0.0)];
151 interSlide = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2);
152 [self setSlide:(interSlide * [_window frame].size.height)];
153 [_window setAlphaValue:interSlide];
155 if ( [_window effectProgress] <= 0.0 ) {
162 [_effectTimer invalidate];
164 [_window orderOut:self];
165 [_window setAlphaValue:1.0];
166 [self setSlide:[_window frame].size.height];
167 [self setWindowVisibility:ITWindowHiddenState];
171 if ( __shouldReleaseWhenIdle ) {
178 [self setWindowVisibility:ITWindowAppearingState];
180 [_effectTimer invalidate];
183 [self performAppearFromProgress:[_window effectProgress] effectTime:(_effectTime / 4.0)];
186 - (void)setSlide:(float)distance
188 CGAffineTransform transform;
191 if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionLeft ) {
192 xPoint = -( 32.0 + [[_window screen] visibleFrame].origin.x );
193 } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionRight ) {
194 xPoint = -(([[_window screen] visibleFrame].size.width + [[_window screen] visibleFrame].origin.x) - 32.0 - [_window frame].size.width);
195 } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionCenter ) {
196 xPoint = ( [_window frame].size.width - [[_window screen] visibleFrame].size.width ) / 2;
199 /*if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionBottom ) {
200 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),
201 -( [[_window screen] frame].size.height - ( distance + 32.0 + [[_window screen] visibleFrame].origin.y ) ) );
202 } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionTop ) {
203 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),
204 [[_window screen] visibleFrame].origin.y - distance + 64.0 );
207 transform = CGAffineTransformMakeTranslation(xPoint,
208 ( [(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 ) ) );
210 CGSSetWindowTransform([NSApp contextID],
211 (CGSWindowID)[_window windowNumber],