Fixing the effects so they work on multiple monitors where the screen
authorKent Sutherland <ksuther@ithinksw.com>
Wed, 1 Dec 2004 02:37:14 +0000 (02:37 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Wed, 1 Dec 2004 02:37:14 +0000 (02:37 +0000)
origin isn't going to always be zero.
Added a setScreen and overrode -screen to the status window class.

ITSpinAndZoomWindowEffect.m
ITSpinWindowEffect.m
ITTransientStatusWindow.h
ITTransientStatusWindow.m
ITZoomWindowEffect.m

index 8369fc2..cbbf44c 100755 (executable)
 
 - (void)setScale:(float)scale angle:(float)angle
 {
 
 - (void)setScale:(float)scale angle:(float)angle
 {
-    int hPos = [_window horizontalPosition];
+    //int hPos = [_window horizontalPosition];
     float radAngle = (angle * 4 * pi);
     CGAffineTransform transform;
     NSPoint translation;
     NSRect screenFrame = [[_window screen] frame];
     
     float radAngle = (angle * 4 * pi);
     CGAffineTransform transform;
     NSPoint translation;
     NSRect screenFrame = [[_window screen] frame];
     
-    translation.x = screenFrame.origin.x + ([_window frame].size.width / 2.0);
-    translation.y = screenFrame.origin.y + ([_window frame].size.height / 2.0);
+    translation.x = /*screenFrame.origin.x + */([_window frame].size.width / 2.0);
+    translation.y = /*screenFrame.origin.y + */([_window frame].size.height / 2.0);
     transform = CGAffineTransformMakeTranslation(translation.x, translation.y);
     transform = CGAffineTransformScale(transform, 1.0 / scale, 1.0 / scale);
     transform = CGAffineTransformRotate(transform, radAngle);
     transform = CGAffineTransformTranslate(transform, -translation.x, -translation.y);
     
     transform = CGAffineTransformMakeTranslation(translation.x, translation.y);
     transform = CGAffineTransformScale(transform, 1.0 / scale, 1.0 / scale);
     transform = CGAffineTransformRotate(transform, radAngle);
     transform = CGAffineTransformTranslate(transform, -translation.x, -translation.y);
     
-    if (hPos == ITWindowPositionLeft) {
+    /*if (hPos == ITWindowPositionLeft) {
         translation.x = -[_window frame].origin.x;
     } else if (hPos == ITWindowPositionRight) {
         translation.x = -[_window frame].origin.x;
     } else {
         translation.x = -[_window frame].origin.x;
         translation.x = -[_window frame].origin.x;
     } else if (hPos == ITWindowPositionRight) {
         translation.x = -[_window frame].origin.x;
     } else {
         translation.x = -[_window frame].origin.x;
-    }
-    
-    translation.y = -( [[_window screen] frame].size.height - [_window frame].origin.y - [_window frame].size.height );
+    }*/
+    translation.x = -[_window frame].origin.x;
+    translation.y = -( screenFrame.size.height - [_window frame].origin.y - [_window frame].size.height );
     
     transform = CGAffineTransformTranslate(transform, translation.x, translation.y);
     CGSSetWindowTransform([NSApp contextID],
     
     transform = CGAffineTransformTranslate(transform, translation.x, translation.y);
     CGSSetWindowTransform([NSApp contextID],
index ad1b8aa..ef8aaf6 100755 (executable)
 
 - (void)setSpin:(float)progress
 {
 
 - (void)setSpin:(float)progress
 {
-    int hPos = [_window horizontalPosition];
+    //int hPos = [_window horizontalPosition];
     float radAngle = (progress * 4 * pi);
     CGAffineTransform transform;
     NSPoint translation;
     NSRect screenFrame = [[_window screen] frame];
     
     float radAngle = (progress * 4 * pi);
     CGAffineTransform transform;
     NSPoint translation;
     NSRect screenFrame = [[_window screen] frame];
     
-    translation.x = screenFrame.origin.x + ([_window frame].size.width / 2.0);
-    translation.y = screenFrame.origin.y + ([_window frame].size.height / 2.0);
+    translation.x = /*screenFrame.origin.x + */([_window frame].size.width / 2.0);
+    translation.y = /*screenFrame.origin.y + */([_window frame].size.height / 2.0);
     transform = CGAffineTransformMakeTranslation(translation.x, translation.y);
     transform = CGAffineTransformRotate(transform, radAngle);
     transform = CGAffineTransformTranslate(transform, -translation.x, -translation.y);
     
     transform = CGAffineTransformMakeTranslation(translation.x, translation.y);
     transform = CGAffineTransformRotate(transform, radAngle);
     transform = CGAffineTransformTranslate(transform, -translation.x, -translation.y);
     
-    if (hPos == ITWindowPositionLeft) {
+    /*if (hPos == ITWindowPositionLeft) {
         translation.x = -[_window frame].origin.x;
     } else if (hPos == ITWindowPositionRight) {
         translation.x = -[_window frame].origin.x;
     } else {
         translation.x = -[_window frame].origin.x;
         translation.x = -[_window frame].origin.x;
     } else if (hPos == ITWindowPositionRight) {
         translation.x = -[_window frame].origin.x;
     } else {
         translation.x = -[_window frame].origin.x;
-    }
-    
-    translation.y = -( [[_window screen] frame].size.height - [_window frame].origin.y - [_window frame].size.height );
+    }*/
+    translation.x = -[_window frame].origin.x;
+    translation.y = -( screenFrame.size.height - [_window frame].origin.y - [_window frame].size.height );
     
     transform = CGAffineTransformTranslate(transform, translation.x, translation.y);
     CGSSetWindowTransform([NSApp contextID],
     
     transform = CGAffineTransformTranslate(transform, translation.x, translation.y);
     CGSSetWindowTransform([NSApp contextID],
index 04f13ab..c93f0a6 100755 (executable)
@@ -62,6 +62,7 @@ typedef enum {
     ITTransientStatusWindowSizing          _sizing;
     float                                  _screenPadding;
 //    int                                    _screenNumber;
     ITTransientStatusWindowSizing          _sizing;
     float                                  _screenPadding;
 //    int                                    _screenNumber;
+       NSScreen *_screen;
 
     BOOL _reallyIgnoresEvents;
     
 
     BOOL _reallyIgnoresEvents;
     
@@ -79,6 +80,8 @@ typedef enum {
 - (void)appear:(id)sender;
 - (void)vanish:(id)sender;
 
 - (void)appear:(id)sender;
 - (void)vanish:(id)sender;
 
+- (void)setScreen:(NSScreen *)newScreen;
+
 - (void)setSizing:(ITTransientStatusWindowSizing)newSizing;
 - (ITTransientStatusWindowSizing)sizing;
 
 - (void)setSizing:(ITTransientStatusWindowSizing)newSizing;
 - (ITTransientStatusWindowSizing)sizing;
 
index 3f01c35..44a0b90 100755 (executable)
@@ -86,6 +86,7 @@ static ITTransientStatusWindow *staticWindow = nil;
         _exitEffect          = nil;
         _reallyIgnoresEvents = YES;
         _exitTimer           = nil;
         _exitEffect          = nil;
         _reallyIgnoresEvents = YES;
         _exitTimer           = nil;
+               [self setScreen:[NSScreen mainScreen]];
 
 //      if ( _backgroundType == ITTransientStatusWindowRounded ) {
 //          _contentSubView = contentView;
 
 //      if ( _backgroundType == ITTransientStatusWindowRounded ) {
 //          _contentSubView = contentView;
@@ -101,6 +102,11 @@ static ITTransientStatusWindow *staticWindow = nil;
     return self;
 }
 
     return self;
 }
 
+- (void)dealloc
+{
+       [_screen release];
+       [super dealloc];
+}
 
 /*************************************************************************/
 #pragma mark -
 
 /*************************************************************************/
 #pragma mark -
@@ -183,6 +189,17 @@ static ITTransientStatusWindow *staticWindow = nil;
     }
 }
 
     }
 }
 
+- (void)setScreen:(NSScreen *)newScreen
+{
+       [_screen release];
+       _screen = [newScreen retain];
+}
+
+- (NSScreen *)screen
+{
+       return _screen;
+}
+
 - (void)setSizing:(ITTransientStatusWindowSizing)newSizing
 {
     _sizing = newSizing;
 - (void)setSizing:(ITTransientStatusWindowSizing)newSizing
 {
     _sizing = newSizing;
index e80735f..b4a0778 100755 (executable)
@@ -54,7 +54,7 @@
 - (void)performAppear
 {
     __idle = NO;
 - (void)performAppear
 {
     __idle = NO;
-    
+       
     [self setWindowVisibility:ITWindowAppearingState];
     [self performAppearFromProgress:0.0 effectTime:_effectTime];
 }
     [self setWindowVisibility:ITWindowAppearingState];
     [self performAppearFromProgress:0.0 effectTime:_effectTime];
 }
 
 - (void)setZoom:(float)Zoom
 {
 
 - (void)setZoom:(float)Zoom
 {
-    int hPos = [_window horizontalPosition];
+    //int hPos = [_window horizontalPosition];
     CGAffineTransform transform;
     NSPoint translation;
     NSRect screenFrame = [[_window screen] frame];
     
     CGAffineTransform transform;
     NSPoint translation;
     NSRect screenFrame = [[_window screen] frame];
     
-    translation.x = screenFrame.origin.x + ([_window frame].size.width / 2.0);
-    translation.y = screenFrame.origin.y + ([_window frame].size.height / 2.0);
+    translation.x = /*screenFrame.origin.x + */([_window frame].size.width / 2.0);
+    translation.y = /*screenFrame.origin.y + */([_window frame].size.height / 2.0);
     transform = CGAffineTransformMakeTranslation(translation.x, translation.y);
     transform = CGAffineTransformScale(transform, 1.0 / Zoom, 1.0 / Zoom);
     transform = CGAffineTransformTranslate(transform, -translation.x, -translation.y);
     
     transform = CGAffineTransformMakeTranslation(translation.x, translation.y);
     transform = CGAffineTransformScale(transform, 1.0 / Zoom, 1.0 / Zoom);
     transform = CGAffineTransformTranslate(transform, -translation.x, -translation.y);
     
-    if (hPos == ITWindowPositionLeft) {
+    /*if (hPos == ITWindowPositionLeft) {
         translation.x = -[_window frame].origin.x;
     } else if (hPos == ITWindowPositionRight) {
         translation.x = -[_window frame].origin.x;
     } else {
         translation.x = -[_window frame].origin.x;
         translation.x = -[_window frame].origin.x;
     } else if (hPos == ITWindowPositionRight) {
         translation.x = -[_window frame].origin.x;
     } else {
         translation.x = -[_window frame].origin.x;
-    }
-    
-    translation.y = -( [[_window screen] frame].size.height - [_window frame].origin.y - [_window frame].size.height );
+    }*/
+       translation.x = -[_window frame].origin.x;
+    translation.y = -( screenFrame.size.height - [_window frame].origin.y - [_window frame].size.height );
     
     transform = CGAffineTransformTranslate(transform, translation.x, translation.y);
     
     
     transform = CGAffineTransformTranslate(transform, translation.x, translation.y);