From 7258eefd9885c903817ec277fe611aff4b0ff5c6 Mon Sep 17 00:00:00 2001 From: Matthew Judy Date: Thu, 20 Mar 2003 02:54:50 +0000 Subject: [PATCH] Builds now. Also some moderate effect architecture changes. --- ITCoreGraphicsHacks.h | 15 ++- ITDissolveWindowEffect.h | 1 + ITDissolveWindowEffect.m | 4 +- ITPivotWindowEffect.h | 1 + ITPivotWindowEffect.m | 68 ++++++++++- ITSlideHorizontallyWindowEffect.h | 1 + ITSlideHorizontallyWindowEffect.m | 4 +- ITSlideVerticallyWindowEffect.h | 1 + ITSlideVerticallyWindowEffect.m | 4 +- ITTransientStatusWindow.h | 36 ++---- ITTransientStatusWindow.m | 197 ++++++++++-------------------- ITWindowEffect.h | 12 +- ITWindowEffect.m | 36 ++++-- ITWindowPositioning.h | 41 +++++++ 14 files changed, 244 insertions(+), 177 deletions(-) create mode 100755 ITWindowPositioning.h diff --git a/ITCoreGraphicsHacks.h b/ITCoreGraphicsHacks.h index 3f51306..31bc676 100755 --- a/ITCoreGraphicsHacks.h +++ b/ITCoreGraphicsHacks.h @@ -11,9 +11,10 @@ * */ + /*************************************************************************/ #pragma mark - -#pragma mark CoreGraphics HACKS +#pragma mark CoreGraphics HACK HACK HACK /*************************************************************************/ typedef void * CGSGenericObj; @@ -47,3 +48,15 @@ extern CGError CGSSetWindowProperty(const CGSConnectionID cid, CGSWindowID w extern CGError CGSSetWindowWarp(const CGSConnectionID cid, CGSWindowID wid, int w,int h, float *mesh); extern CGError CGSSetWindowTransform(const CGSConnectionID cid, CGSWindowID wid, CGAffineTransform transform); + + +/*************************************************************************/ +#pragma mark - +#pragma mark NSApplication HACK HACK HACK +/*************************************************************************/ + +@interface NSApplication (HACKHACKHACKHACK) +- (CGSConnectionID)contextID; +@end + + diff --git a/ITDissolveWindowEffect.h b/ITDissolveWindowEffect.h index f1f8a0e..4455e73 100755 --- a/ITDissolveWindowEffect.h +++ b/ITDissolveWindowEffect.h @@ -13,6 +13,7 @@ #import +#import "ITWindowEffect.h" @interface ITDissolveWindowEffect : ITWindowEffect { diff --git a/ITDissolveWindowEffect.m b/ITDissolveWindowEffect.m index 26e43e8..2dda28d 100755 --- a/ITDissolveWindowEffect.m +++ b/ITDissolveWindowEffect.m @@ -6,12 +6,12 @@ - (void)performAppear { - NSLog("ITDissolveWindowEffect does not implement performAppear."); + NSLog(@"ITDissolveWindowEffect does not implement performAppear."); } - (void)performVanish { - NSLog("ITDissolveWindowEffect does not implement performVanish."); + NSLog(@"ITDissolveWindowEffect does not implement performVanish."); } diff --git a/ITPivotWindowEffect.h b/ITPivotWindowEffect.h index abe13e0..90be383 100755 --- a/ITPivotWindowEffect.h +++ b/ITPivotWindowEffect.h @@ -13,6 +13,7 @@ #import +#import "ITWindowEffect.h" @interface ITPivotWindowEffect : ITWindowEffect { diff --git a/ITPivotWindowEffect.m b/ITPivotWindowEffect.m index 7f0e627..81fb8ce 100755 --- a/ITPivotWindowEffect.m +++ b/ITPivotWindowEffect.m @@ -1,17 +1,79 @@ #import "ITPivotWindowEffect.h" - +#import "ITCoreGraphicsHacks.h" @implementation ITPivotWindowEffect - (void)performAppear { - NSLog("ITPivotWindowEffect does not implement performAppear."); + NSLog(@"ITPivotWindowEffect does not implement performAppear."); } - (void)performVanish { - NSLog("ITPivotWindowEffect does not implement performVanish."); + NSLog(@"ITPivotWindowEffect does not implement performVanish."); +} + +- (void)pivotEffect +{ + if ( YES ) { + [self setPivot:315.0]; + _effectProgress = 0.0; + [_window setAlphaValue:0.0]; + [_window orderFront:self]; + _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS) + target:self + selector:@selector(pivotStep) + userInfo:nil + repeats:YES]; + } else { + [_window orderOut:self]; + } +} + +- (void)pivotStep +{ + if ( YES ) { + float interPivot = 0.0; + _effectProgress += (1.0 / (EFFECT_FPS * _effectTime)); + _effectProgress = (_effectProgress < 1.0 ? _effectProgress : 1.0); + interPivot = (( sin((_effectProgress * pi) - (pi / 2)) + 1 ) / 2); + [self setPivot:((interPivot * 45) + 315)]; + [_window setAlphaValue:interPivot]; + if ( _effectProgress >= 1.0 ) { + [self pivotFinish]; + } + } else { + //backwards + } +} + +- (void)pivotFinish +{ + if ( YES ) { + [_effectTimer invalidate]; + _effectTimer = nil; + _effectProgress = 0.0; + } else { + //backwards + } +} + + +- (void)setPivot:(float)angle +{ + float degAngle = (angle * (pi / 180)); + CGAffineTransform transform = CGAffineTransformMakeRotation(degAngle); + + // Set pivot point + transform.tx = -32.0; + transform.ty = [_window frame].size.height + 32.0; + + CGSSetWindowTransform([NSApp contextID], + (CGSWindowID)[_window windowNumber], + CGAffineTransformTranslate(transform, + (([_window frame].origin.x - 32.0) * -1), + (([[_window screen] frame].size.height - ([_window frame].origin.y) + 32.0) * -1) )); } diff --git a/ITSlideHorizontallyWindowEffect.h b/ITSlideHorizontallyWindowEffect.h index e63bdd6..5b3047c 100755 --- a/ITSlideHorizontallyWindowEffect.h +++ b/ITSlideHorizontallyWindowEffect.h @@ -13,6 +13,7 @@ #import +#import "ITWindowEffect.h" @interface ITSlideHorizontallyWindowEffect : ITWindowEffect { diff --git a/ITSlideHorizontallyWindowEffect.m b/ITSlideHorizontallyWindowEffect.m index 5ba9550..74673d2 100755 --- a/ITSlideHorizontallyWindowEffect.m +++ b/ITSlideHorizontallyWindowEffect.m @@ -6,12 +6,12 @@ - (void)performAppear { - NSLog("ITSlideHorizontallyWindowEffect does not implement performAppear."); + NSLog(@"ITSlideHorizontallyWindowEffect does not implement performAppear."); } - (void)performVanish { - NSLog("ITSlideHorizontallyWindowEffect does not implement performVanish."); + NSLog(@"ITSlideHorizontallyWindowEffect does not implement performVanish."); } diff --git a/ITSlideVerticallyWindowEffect.h b/ITSlideVerticallyWindowEffect.h index fff3957..e267182 100755 --- a/ITSlideVerticallyWindowEffect.h +++ b/ITSlideVerticallyWindowEffect.h @@ -13,6 +13,7 @@ #import +#import "ITWindowEffect.h" @interface ITSlideVerticallyWindowEffect : ITWindowEffect { diff --git a/ITSlideVerticallyWindowEffect.m b/ITSlideVerticallyWindowEffect.m index 13fa2bc..8c27b42 100755 --- a/ITSlideVerticallyWindowEffect.m +++ b/ITSlideVerticallyWindowEffect.m @@ -6,12 +6,12 @@ - (void)performAppear { - NSLog("ITSlideVerticallyWindowEffect does not implement performAppear."); + NSLog(@"ITSlideVerticallyWindowEffect does not implement performAppear."); } - (void)performVanish { - NSLog("ITSlideVerticallyWindowEffect does not implement performVanish."); + NSLog(@"ITSlideVerticallyWindowEffect does not implement performVanish."); } diff --git a/ITTransientStatusWindow.h b/ITTransientStatusWindow.h index aa7e5f6..52e96d7 100755 --- a/ITTransientStatusWindow.h +++ b/ITTransientStatusWindow.h @@ -16,10 +16,10 @@ #import +#import "ITWindowPositioning.h" #define DEFAULT_EXIT_DELAY 3.0 -#define DEFAULT_EFFECT_TIME 0.75 @class ITTextField; @@ -29,9 +29,9 @@ typedef enum { ITTransientStatusWindowHiddenState, - ITTransientStatusWindowEnteringState, + ITTransientStatusWindowAppearingState, ITTransientStatusWindowVisibleState, - ITTransientStatusWindowExitingState + ITTransientStatusWindowVanishingState } ITTransientStatusWindowVisibilityState; typedef enum { @@ -48,17 +48,7 @@ typedef enum { ITTransientStatusWindowAquaUtility } ITTransientStatusWindowBackgroundType; -typedef enum { - ITTransientStatusWindowPositionTop, - ITTransientStatusWindowPositionMiddle, - ITTransientStatusWindowPositionBottom, - ITTransientStatusWindowPositionLeft, - ITTransientStatusWindowPositionCenter, - ITTransientStatusWindowPositionRight, - ITTransientStatusWindowOther -} ITTransientStatusWindowPosition; - -@interface ITTransientStatusWindow : NSWindow { +@interface ITTransientStatusWindow : NSWindow { ITTransientStatusWindowVisibilityState _visibilityState; ITTransientStatusWindowExitMode _exitMode; @@ -66,16 +56,14 @@ typedef enum { ITTransientStatusWindowBackgroundType _backgroundType; ITWindowEffect *_entryEffect; ITWindowEffect *_exitEffect; - float _effectTime; - double _effectProgress; - ITTransientStatusWindowPosition _verticalPosition; - ITTransientStatusWindowPosition _horizontalPosition; - int _screenPadding; + ITVerticalWindowPosition _verticalPosition; + ITHorizontalWindowPosition _horizontalPosition; + float _screenPadding; + int _screenNumber; BOOL _reallyIgnoresEvents; NSTimer *_delayTimer; - NSTimer *_effectTimer; // NSView *_contentSubView; } @@ -97,11 +85,11 @@ typedef enum { - (ITTransientStatusWindowBackgroundType)backgroundType; - (void)setBackgroundType:(ITTransientStatusWindowBackgroundType)newType; -- (ITTransientStatusWindowPosition)verticalPosition; -- (void)setVerticalPosition:(ITTransientStatusWindowPosition)newPosition; +- (ITVerticalWindowPosition)verticalPosition; +- (void)setVerticalPosition:(ITVerticalWindowPosition)newPosition; -- (ITTransientStatusWindowPosition)horizontalPosition; -- (void)setHorizontalPosition:(ITTransientStatusWindowPosition)newPosition; +- (ITHorizontalWindowPosition)horizontalPosition; +- (void)setHorizontalPosition:(ITHorizontalWindowPosition)newPosition; - (ITWindowEffect *)entryEffect; - (void)setEntryEffect:(ITWindowEffect *)newEffect; diff --git a/ITTransientStatusWindow.m b/ITTransientStatusWindow.m index 004396a..f749278 100755 --- a/ITTransientStatusWindow.m +++ b/ITTransientStatusWindow.m @@ -1,23 +1,13 @@ #import "ITTransientStatusWindow.h" +#import "ITWindowEffect.h" #import #import "ITCoreGraphicsHacks.h" #import "ITTextField.h" #import "ITGrayRoundedView.h" - #define EFFECT_FPS 30.0 -/*************************************************************************/ -#pragma mark - -#pragma mark EVIL HACKERY -/*************************************************************************/ - -@interface NSApplication (HACKHACKHACKHACK) -- (CGSConnectionID)contextID; -@end - - /*************************************************************************/ #pragma mark - #pragma mark PRIVATE METHOD DECLARATIONS @@ -28,14 +18,7 @@ exitMode:(ITTransientStatusWindowExitMode)exitMode backgroundType:(ITTransientStatusWindowBackgroundType)backgroundType; - (void)rebuildWindow; -- (void)performEffect; -- (void)dissolveEffect; -- (void)slideVerticalEffect; -- (void)slideHorizontalEffect; -- (void)pivotEffect; -- (void)pivotStep; -- (void)pivotFinish; -- (void)setPivot:(float)angle; +// - (void)performEffect; @end @@ -94,16 +77,14 @@ static ITTransientStatusWindow *staticWindow = nil; _exitMode = exitMode; _exitDelay = DEFAULT_EXIT_DELAY; _backgroundType = backgroundType; - _verticalPosition = ITTransientStatusWindowPositionBottom; - _horizontalPosition = ITTransientStatusWindowPositionLeft; + _verticalPosition = ITWindowPositionBottom; + _horizontalPosition = ITWindowPositionLeft; _screenPadding = 32.0; - _entryEffect = ITTransientStatusWindowEffectNone; - _exitEffect = ITTransientStatusWindowEffectDissolve; - _effectTime = DEFAULT_EFFECT_TIME; - _effectProgress = 0.00; + _screenNumber = 0; + _entryEffect = nil; + _exitEffect = nil; _reallyIgnoresEvents = YES; _delayTimer = nil; - _effectTimer = nil; // if ( _backgroundType == ITTransientStatusWindowRounded ) { // _contentSubView = contentView; @@ -144,9 +125,11 @@ static ITTransientStatusWindow *staticWindow = nil; _reallyIgnoresEvents = flag; } +/* + - (void)orderFront:(id)sender { - if ( _entryEffect == ITTransientStatusWindowEffectNone ) { + if ( _entryEffect == nil ) { [super orderFront:sender]; _visibilityState = ITTransientStatusWindowVisibleState; } else { @@ -163,7 +146,7 @@ static ITTransientStatusWindow *staticWindow = nil; // set the timer, and orderOut: when it lapses. } - if ( _entryEffect == ITTransientStatusWindowEffectNone ) { + if ( _entryEffect == nil ) { [super makeKeyAndOrderFront:sender]; _visibilityState = ITTransientStatusWindowVisibleState; } else { @@ -174,7 +157,7 @@ static ITTransientStatusWindow *staticWindow = nil; - (void)orderOut:(id)sender { - if ( _entryEffect == ITTransientStatusWindowEffectNone ) { + if ( _entryEffect == nil ) { [super orderOut:sender]; _visibilityState = ITTransientStatusWindowHiddenState; } else { @@ -184,11 +167,9 @@ static ITTransientStatusWindow *staticWindow = nil; - (NSTimeInterval)animationResizeTime:(NSRect)newFrame { - return _effectTime; + return _resizeTime; } -/* - - (id)contentView { if ( _backgroundType == ITTransientStatusWindowRounded ) { @@ -213,6 +194,32 @@ static ITTransientStatusWindow *staticWindow = nil; */ +- (void)appear +{ + if ( _entryEffect == nil ) { + [self orderFront:self]; + _visibilityState = ITTransientStatusWindowVisibleState; + } else { + _visibilityState = ITTransientStatusWindowAppearingState; + [_entryEffect performAppear]; + _visibilityState = ITTransientStatusWindowVisibleState; + } + if ( _exitMode == ITTransientStatusWindowExitAfterDelay ) { + // set the timer, and vanish when it lapses. + } +} + +- (void)vanish +{ + if ( _entryEffect == nil ) { + [self orderOut:self]; + _visibilityState = ITTransientStatusWindowHiddenState; + } else { + [_exitEffect performVanish]; + _visibilityState = ITTransientStatusWindowHiddenState; + } +} + - (ITTransientStatusWindowVisibilityState)visibilityState { return _visibilityState; @@ -251,26 +258,46 @@ static ITTransientStatusWindow *staticWindow = nil; _backgroundType = ITTransientStatusWindowRounded; } -- (ITTransientStatusWindowPosition)verticalPosition; +- (ITVerticalWindowPosition)verticalPosition; { return _verticalPosition; } -- (void)setVerticalPosition:(ITTransientStatusWindowPosition)newPosition; +- (void)setVerticalPosition:(ITVerticalWindowPosition)newPosition; { _verticalPosition = newPosition; } -- (ITTransientStatusWindowPosition)horizontalPosition; +- (ITHorizontalWindowPosition)horizontalPosition; { return _horizontalPosition; } -- (void)setHorizontalPosition:(ITTransientStatusWindowPosition)newPosition; +- (void)setHorizontalPosition:(ITHorizontalWindowPosition)newPosition; { _horizontalPosition = newPosition; } +- (float)screenPadding +{ + return _screenPadding; +} + +- (void)setScreenPadding:(float)newPadding +{ + _screenPadding = newPadding; +} + +- (int)screenNumber +{ + return _screenNumber; +} + +- (void)setScreenNumber:(int)newNumber +{ + _screenNumber = newNumber; +} + - (ITWindowEffect *)entryEffect { return _entryEffect; @@ -317,6 +344,8 @@ static ITTransientStatusWindow *staticWindow = nil; } } +/* + - (void)performEffect { if ( _visibilityState == ITTransientStatusWindowHiddenState ) { @@ -338,101 +367,7 @@ static ITTransientStatusWindow *staticWindow = nil; } } -- (void)dissolveEffect -{ - if ( _visibilityState == ITTransientStatusWindowEnteringState ) { - [super orderFront:self]; - _visibilityState = ITTransientStatusWindowVisibleState; - } else { - [super orderOut:self]; - _visibilityState = ITTransientStatusWindowHiddenState; - } -} - -- (void)slideVerticalEffect -{ - if ( _visibilityState == ITTransientStatusWindowEnteringState ) { - [super orderFront:self]; - _visibilityState = ITTransientStatusWindowVisibleState; - } else { - [super orderOut:self]; - _visibilityState = ITTransientStatusWindowHiddenState; - } -} - -- (void)slideHorizontalEffect -{ - if ( _visibilityState == ITTransientStatusWindowEnteringState ) { - [super orderFront:self]; - _visibilityState = ITTransientStatusWindowVisibleState; - } else { - [super orderOut:self]; - _visibilityState = ITTransientStatusWindowHiddenState; - } -} - -- (void)pivotEffect -{ - if ( _visibilityState == ITTransientStatusWindowEnteringState ) { - [self setPivot:315.0]; - _effectProgress = 0.0; - [self setAlphaValue:0.0]; - [super orderFront:self]; - _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS) - target:self - selector:@selector(pivotStep) - userInfo:nil - repeats:YES]; - } else { - [super orderOut:self]; - _visibilityState = ITTransientStatusWindowHiddenState; - } -} - -- (void)pivotStep -{ - if ( _visibilityState == ITTransientStatusWindowEnteringState ) { - float interPivot = 0.0; - _effectProgress += (1.0 / (EFFECT_FPS * _effectTime)); - _effectProgress = (_effectProgress < 1.0 ? _effectProgress : 1.0); - interPivot = (( sin((_effectProgress * pi) - (pi / 2)) + 1 ) / 2); - [self setPivot:((interPivot * 45) + 315)]; - [self setAlphaValue:interPivot]; - if ( _effectProgress >= 1.0 ) { - [self pivotFinish]; - } - } else { - //backwards - } -} - -- (void)pivotFinish -{ - if ( _visibilityState == ITTransientStatusWindowEnteringState ) { - [_effectTimer invalidate]; - _effectTimer = nil; - _effectProgress = 0.0; - _visibilityState = ITTransientStatusWindowVisibleState; - } else { - //backwards - } -} - +*/ -- (void)setPivot:(float)angle -{ - float degAngle = (angle * (pi / 180)); - CGAffineTransform transform = CGAffineTransformMakeRotation(degAngle); - - // Set pivot point - transform.tx = -32.0; - transform.ty = [self frame].size.height + 32.0; - - CGSSetWindowTransform([NSApp contextID], - (CGSWindowID)[self windowNumber], - CGAffineTransformTranslate(transform, - (([self frame].origin.x - 32.0) * -1), - (([[self screen] frame].size.height - ([self frame].origin.y) + 32.0) * -1) )); -} @end diff --git a/ITWindowEffect.h b/ITWindowEffect.h index bb1c3b8..df4578b 100755 --- a/ITWindowEffect.h +++ b/ITWindowEffect.h @@ -13,6 +13,11 @@ #import +#import "ITWindowPositioning.h" + + +#define EFFECT_FPS 30.0 +#define DEFAULT_EFFECT_TIME 0.75 @protocol ITWindowEffect @@ -25,7 +30,12 @@ @interface ITWindowEffect : NSObject { - NSWindow *_window; + NSWindow *_window; + float _effectTime; + double _effectProgress; + ITVerticalWindowPosition _verticalPosition; + ITHorizontalWindowPosition _horizontalPosition; + NSTimer *_effectTimer; } // Designated initializer diff --git a/ITWindowEffect.m b/ITWindowEffect.m index 5c32fb4..bb7cfed 100755 --- a/ITWindowEffect.m +++ b/ITWindowEffect.m @@ -1,11 +1,3 @@ -// -// ITWindowEffect.m -// ITKit -// -// Created by Matt L. Judy on Sat Mar 01 2003. -// Copyright (c) 2003 NibFile.com. All rights reserved. -// - #import "ITWindowEffect.h" @@ -14,7 +6,23 @@ - (id)initWithWindow:(NSWindow *)window { - _window = window; + if ( (self = [super init]) ) { + + _window = [window retain]; + _effectTime = DEFAULT_EFFECT_TIME; + _effectProgress = 0.00; + _effectTimer = nil; + + if ( [window conformsToProtocol:@protocol(ITWindowPositioning)] ) { + _verticalPosition = (ITVerticalWindowPosition)[window verticalPosition]; + _horizontalPosition = (ITHorizontalWindowPosition)[window horizontalPosition]; + } else { + NSLog(@"ITWindowEffect - initWithWindow: - window does not conform to ITWindowPositioning."); + _verticalPosition = ITWindowPositionBottom; + _horizontalPosition = ITWindowPositionLeft; + } + } + return self; } - (NSWindow *)window @@ -29,12 +37,18 @@ - (void)performAppear { - NSLog("ITWindowEffect does not implement performAppear."); + NSLog(@"ITWindowEffect does not implement performAppear."); } - (void)performVanish { - NSLog("ITWindowEffect does not implement performVanish."); + NSLog(@"ITWindowEffect does not implement performVanish."); +} + +- (void)dealloc +{ + [_window release]; + [super dealloc]; } diff --git a/ITWindowPositioning.h b/ITWindowPositioning.h new file mode 100755 index 0000000..61095c7 --- /dev/null +++ b/ITWindowPositioning.h @@ -0,0 +1,41 @@ +/* + * ITKit + * ITWindowPositioning + * Protocol which defines methods for window positioning presets. + * + * Original Author : Kent Sutherland + * Original Author : Matt Judy + * Responsibility : Matt Judy + * Responsibility : Joseph Spiros + * + * Copyright (c) 2002 - 2003 iThink Software. + * All Rights Reserved + * + */ + + +typedef enum { + ITWindowPositionLeft, + ITWindowPositionCenter, + ITWindowPositionRight, +} ITHorizontalWindowPosition; + +typedef enum { + ITWindowPositionTop, + ITWindowPositionMiddle, + ITWindowPositionBottom, +} ITVerticalWindowPosition; + + +@protocol ITWindowPositioning + +- (ITVerticalWindowPosition)verticalPosition; +- (void)setVerticalPosition:(ITVerticalWindowPosition)newPosition; +- (ITHorizontalWindowPosition)horizontalPosition; +- (void)setHorizontalPosition:(ITHorizontalWindowPosition)newPosition; +- (float)screenPadding; +- (void)setScreenPadding:(float)newPadding; +- (int)screenNumber; +- (void)setScreenNumber:(int)newNumber; + +@end -- 2.20.1