Positioning Fixes. The window might still do some weirdness if you change its positi...
[ITKit.git] / ITSlideHorizontallyWindowEffect.m
index 2382cc4..1a26d1f 100755 (executable)
 @implementation ITSlideHorizontallyWindowEffect
 
 
++ (NSString *)effectName
+{
+    return @"Slide Horizontally";
+}
+
++ (NSDictionary *)supportedPositions
+{
+    return [NSDictionary dictionaryWithObjectsAndKeys:
+        [NSDictionary dictionaryWithObjectsAndKeys:
+            [NSNumber numberWithBool:YES], @"Left",
+            [NSNumber numberWithBool:NO], @"Center",
+            [NSNumber numberWithBool:YES], @"Right", nil] , @"Top" ,
+        [NSDictionary dictionaryWithObjectsAndKeys:
+            [NSNumber numberWithBool:YES], @"Left",
+            [NSNumber numberWithBool:NO], @"Center",
+            [NSNumber numberWithBool:YES], @"Right", nil] , @"Middle" ,
+        [NSDictionary dictionaryWithObjectsAndKeys:
+            [NSNumber numberWithBool:YES], @"Left",
+            [NSNumber numberWithBool:NO], @"Center",
+            [NSNumber numberWithBool:YES], @"Right", nil] , @"Bottom" , nil];
+}
+
+
++ (unsigned int)listOrder
+{
+    return 400;
+}
+
+
 /*************************************************************************/
 #pragma mark -
 #pragma mark APPEAR METHODS
 - (void)setSlide:(float)distance
 {
     CGAffineTransform transform;
-    float yPoint;
+    NSPoint translation;
     
-    if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionTop ) {
-        yPoint = ( 64.0 + [[_window screen] visibleFrame].origin.y - [_window frame].size.height );
-    } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionBottom ) {
-        yPoint = -( [[_window screen] frame].size.height - ( [_window frame].size.height + 32.0 + [[_window screen] visibleFrame].origin.y) );
-    } else if ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionMiddle ) {
-        yPoint = ( [_window frame].size.height - [[_window screen] visibleFrame].size.height) / 2;
+    if ( [_window horizontalPosition] == ITWindowPositionLeft ) {
+        translation.x = ( -([_window frame].origin.x) + distance ) ;
+    } else if ( [_window horizontalPosition] == ITWindowPositionRight ) {
+        translation.x = ( -([_window frame].origin.x) - distance ) ;
+    } else {
+        translation.x = ( -([_window frame].origin.x) ) ;
     }
     
-    /*if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionLeft ) {
-        transform = CGAffineTransformMakeTranslation((distance - (32.0 + [[_window screen] visibleFrame].origin.x)),
-                                                    ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionBottom ) ? -( [[_window screen] frame].size.height - ( [_window frame].size.height + 32.0 + [[_window screen] visibleFrame].origin.y) ) : ( 64.0 + [[_window screen] visibleFrame].origin.y - [_window frame].size.height ) );
-    } else if ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionRight ) {
-        transform = CGAffineTransformMakeTranslation(-((([[_window screen] visibleFrame].size.width + [[_window screen] visibleFrame].origin.x) + distance) - 32.0 - [_window frame].size.width),
-                                                    ( [(ITTransientStatusWindow *)_window verticalPosition] == ITWindowPositionBottom ) ? -( [[_window screen] frame].size.height - ( [_window frame].size.height + 32.0 + [[_window screen] visibleFrame].origin.y) ) : ( 64.0 + [[_window screen] visibleFrame].origin.y - [_window frame].size.height ) );
-    }*/
+    translation.y = -( [[_window screen] frame].size.height - [_window frame].origin.y - [_window frame].size.height );
     
-    transform = CGAffineTransformMakeTranslation( ( [(ITTransientStatusWindow *)_window horizontalPosition] == ITWindowPositionLeft ) ? (distance - (32.0 + [[_window screen] visibleFrame].origin.x)) : -((([[_window screen] visibleFrame].size.width + [[_window screen] visibleFrame].origin.x) + distance) - 32.0 - [_window frame].size.width),
-                                                 yPoint);
+    transform = CGAffineTransformMakeTranslation( translation.x, translation.y );
     
     CGSSetWindowTransform([NSApp contextID],
                           (CGSWindowID)[_window windowNumber],
                           transform);
 }
+
+
 @end