From 3055b035aa851467097d35d886890f272dc90ee7 Mon Sep 17 00:00:00 2001 From: Kent Sutherland Date: Wed, 1 Dec 2004 02:37:14 +0000 Subject: [PATCH] Fixing the effects so they work on multiple monitors where the screen origin isn't going to always be zero. Added a setScreen and overrode -screen to the status window class. --- ITSpinAndZoomWindowEffect.m | 14 +++++++------- ITSpinWindowEffect.m | 14 +++++++------- ITTransientStatusWindow.h | 3 +++ ITTransientStatusWindow.m | 17 +++++++++++++++++ ITZoomWindowEffect.m | 16 ++++++++-------- 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/ITSpinAndZoomWindowEffect.m b/ITSpinAndZoomWindowEffect.m index 8369fc2..cbbf44c 100755 --- a/ITSpinAndZoomWindowEffect.m +++ b/ITSpinAndZoomWindowEffect.m @@ -193,28 +193,28 @@ - (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]; - 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); - 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.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], diff --git a/ITSpinWindowEffect.m b/ITSpinWindowEffect.m index ad1b8aa..ef8aaf6 100755 --- a/ITSpinWindowEffect.m +++ b/ITSpinWindowEffect.m @@ -193,27 +193,27 @@ - (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]; - 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); - 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.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], diff --git a/ITTransientStatusWindow.h b/ITTransientStatusWindow.h index 04f13ab..c93f0a6 100755 --- a/ITTransientStatusWindow.h +++ b/ITTransientStatusWindow.h @@ -62,6 +62,7 @@ typedef enum { ITTransientStatusWindowSizing _sizing; float _screenPadding; // int _screenNumber; + NSScreen *_screen; BOOL _reallyIgnoresEvents; @@ -79,6 +80,8 @@ typedef enum { - (void)appear:(id)sender; - (void)vanish:(id)sender; +- (void)setScreen:(NSScreen *)newScreen; + - (void)setSizing:(ITTransientStatusWindowSizing)newSizing; - (ITTransientStatusWindowSizing)sizing; diff --git a/ITTransientStatusWindow.m b/ITTransientStatusWindow.m index 3f01c35..44a0b90 100755 --- a/ITTransientStatusWindow.m +++ b/ITTransientStatusWindow.m @@ -86,6 +86,7 @@ static ITTransientStatusWindow *staticWindow = nil; _exitEffect = nil; _reallyIgnoresEvents = YES; _exitTimer = nil; + [self setScreen:[NSScreen mainScreen]]; // if ( _backgroundType == ITTransientStatusWindowRounded ) { // _contentSubView = contentView; @@ -101,6 +102,11 @@ static ITTransientStatusWindow *staticWindow = nil; return self; } +- (void)dealloc +{ + [_screen release]; + [super dealloc]; +} /*************************************************************************/ #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; diff --git a/ITZoomWindowEffect.m b/ITZoomWindowEffect.m index e80735f..b4a0778 100755 --- a/ITZoomWindowEffect.m +++ b/ITZoomWindowEffect.m @@ -54,7 +54,7 @@ - (void)performAppear { __idle = NO; - + [self setWindowVisibility:ITWindowAppearingState]; [self performAppearFromProgress:0.0 effectTime:_effectTime]; } @@ -193,26 +193,26 @@ - (void)setZoom:(float)Zoom { - int hPos = [_window horizontalPosition]; + //int hPos = [_window horizontalPosition]; 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); - 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.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); -- 2.20.1