From: Kent Sutherland Date: Tue, 29 Jun 2004 05:30:37 +0000 (+0000) Subject: New zoom effect. X-Git-Tag: v1.0~18 X-Git-Url: http://git.ithinksw.org/ITKit.git/commitdiff_plain/ee17fc263ed710648cfc5950a5bd603f8acacda2 New zoom effect. --- diff --git a/ITKit.xcode/project.pbxproj b/ITKit.xcode/project.pbxproj index 7beefb5..e0c00c0 100755 --- a/ITKit.xcode/project.pbxproj +++ b/ITKit.xcode/project.pbxproj @@ -509,6 +509,34 @@ ); }; }; + 372C5812068FE72F00CEF54A = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = ITZoomWindowEffect.m; + refType = 4; + sourceTree = ""; + }; + 372C5813068FE72F00CEF54A = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = ITZoomWindowEffect.h; + refType = 4; + sourceTree = ""; + }; + 372C5814068FE72F00CEF54A = { + fileRef = 372C5812068FE72F00CEF54A; + isa = PBXBuildFile; + settings = { + }; + }; + 372C5815068FE72F00CEF54A = { + fileRef = 372C5813068FE72F00CEF54A; + isa = PBXBuildFile; + settings = { + }; + }; //370 //371 //372 @@ -1807,6 +1835,8 @@ 7C992DEA054F5179000B93EA, 7C992DE7054F5179000B93EA, 7C992DE8054F5179000B93EA, + 372C5813068FE72F00CEF54A, + 372C5812068FE72F00CEF54A, ); isa = PBXGroup; name = Effects; @@ -2161,6 +2191,7 @@ 2AC8319D056D037700A7D7E2, 3710912805C0825900ED0F36, 7C4BBADC05F98C9900734027, + 372C5815068FE72F00CEF54A, ); isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -2221,6 +2252,7 @@ 2AC8319E056D037700A7D7E2, 3710912305C0821000ED0F36, 7C4BBADD05F98C9900734027, + 372C5814068FE72F00CEF54A, ); isa = PBXSourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; diff --git a/ITWindowEffect.m b/ITWindowEffect.m index 231dc76..576d6d1 100755 --- a/ITWindowEffect.m +++ b/ITWindowEffect.m @@ -12,6 +12,7 @@ NSClassFromString(@"ITSlideHorizontallyWindowEffect"), NSClassFromString(@"ITSlideVerticallyWindowEffect"), NSClassFromString(@"ITPivotWindowEffect"), + NSClassFromString(@"ITZoomWindowEffect"), nil]; return classes; diff --git a/ITZoomWindowEffect.h b/ITZoomWindowEffect.h new file mode 100755 index 0000000..9fc920e --- /dev/null +++ b/ITZoomWindowEffect.h @@ -0,0 +1,23 @@ +/* + * ITKit + * ITZoomWindowEffect + * Effect subclass which zooms (expands/shrinks) a window into position on the screen. + * + * Original Author : Kent Sutherland + * Responsibility : Kent Sutherland + * + * Copyright (c) 2002 - 2004 iThink Software. + * All Rights Reserved + * + */ + + +#import +#import "ITWindowEffect.h" + + +@interface ITZoomWindowEffect : ITWindowEffect { + +} + +@end diff --git a/ITZoomWindowEffect.m b/ITZoomWindowEffect.m new file mode 100755 index 0000000..e80735f --- /dev/null +++ b/ITZoomWindowEffect.m @@ -0,0 +1,224 @@ +#import "ITZoomWindowEffect.h" +#import "ITCoreGraphicsHacks.h" +#import "ITTransientStatusWindow.h" + + +@interface ITZoomWindowEffect (Private) +- (void)performAppearFromProgress:(float)progress effectTime:(float)time; +- (void)appearStep; +- (void)appearFinish; +- (void)performVanishFromProgress:(float)progress effectTime:(float)time; +- (void)vanishStep; +- (void)vanishFinish; +- (void)setZoom:(float)Zoom; +@end + + +@implementation ITZoomWindowEffect + + ++ (NSString *)effectName +{ + return @"Zoom"; +} + ++ (NSDictionary *)supportedPositions +{ + return [NSDictionary dictionaryWithObjectsAndKeys: + [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:YES], @"Left", + [NSNumber numberWithBool:YES], @"Center", + [NSNumber numberWithBool:YES], @"Right", nil] , @"Top" , + [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:YES], @"Left", + [NSNumber numberWithBool:YES], @"Center", + [NSNumber numberWithBool:YES], @"Right", nil] , @"Middle" , + [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:YES], @"Left", + [NSNumber numberWithBool:YES], @"Center", + [NSNumber numberWithBool:YES], @"Right", nil] , @"Bottom" , nil]; +} + + ++ (unsigned int)listOrder +{ + return 600; +} + + +/*************************************************************************/ +#pragma mark - +#pragma mark APPEAR METHODS +/*************************************************************************/ + +- (void)performAppear +{ + __idle = NO; + + [self setWindowVisibility:ITWindowAppearingState]; + [self performAppearFromProgress:0.0 effectTime:_effectTime]; +} + +- (void)performAppearFromProgress:(float)progress effectTime:(float)time +{ + [_window setEffectProgress:progress]; + _effectSpeed = (1.0 / (EFFECT_FPS * time)); + + if ( progress == 0.0 ) { + [self setZoom:0.0]; + [_window setAlphaValue:0.0]; + } + + [_window orderFront:self]; + _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS) + target:self + selector:@selector(appearStep) + userInfo:nil + repeats:YES]; +} + +- (void)appearStep +{ + float interZoom = 0.0; + [_window setEffectProgress:([_window effectProgress] + _effectSpeed)]; + [_window setEffectProgress:( ([_window effectProgress] < 1.0) ? [_window effectProgress] : 1.0)]; + interZoom = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2); + [self setZoom:interZoom]; + [_window setAlphaValue:interZoom]; + + if ( [_window effectProgress] >= 1.0 ) { + [self appearFinish]; + } +} + +- (void)appearFinish +{ + [_effectTimer invalidate]; + _effectTimer = nil; + [self setWindowVisibility:ITWindowVisibleState]; + + __idle = YES; + + if ( __shouldReleaseWhenIdle ) { + [self release]; + } +} + +- (void)cancelAppear +{ + [self setWindowVisibility:ITWindowVanishingState]; + + [_effectTimer invalidate]; + _effectTimer = nil; + + [self performVanishFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)]; +} + + +/*************************************************************************/ +#pragma mark - +#pragma mark VANISH METHODS +/*************************************************************************/ + +- (void)performVanish +{ + __idle = NO; + + [self setWindowVisibility:ITWindowVanishingState]; + [self performVanishFromProgress:1.0 effectTime:_effectTime]; +} + +- (void)performVanishFromProgress:(float)progress effectTime:(float)time +{ + [_window setEffectProgress:progress]; + _effectSpeed = (1.0 / (EFFECT_FPS * time)); + if ( progress == 1.0 ) { + [self setZoom:0.0]; + [_window setAlphaValue:1.0]; + } + + [_window orderFront:self]; + _effectTimer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / EFFECT_FPS) + target:self + selector:@selector(vanishStep) + userInfo:nil + repeats:YES]; +} + +- (void)vanishStep +{ + float interZoom = 1.0; + [_window setEffectProgress:([_window effectProgress] - _effectSpeed)]; + [_window setEffectProgress:( ([_window effectProgress] > 0.0) ? [_window effectProgress] : 0.0)]; + interZoom = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2); + [self setZoom:interZoom]; + [_window setAlphaValue:interZoom]; + + if ( [_window effectProgress] <= 0.0 ) { + [self vanishFinish]; + } +} + +- (void)vanishFinish +{ + [_effectTimer invalidate]; + _effectTimer = nil; + [_window orderOut:self]; + [_window setAlphaValue:1.0]; + [self setZoom:0.0]; + [self setWindowVisibility:ITWindowHiddenState]; + + __idle = YES; + + if ( __shouldReleaseWhenIdle ) { + [self release]; + } +} + +- (void)cancelVanish +{ + [self setWindowVisibility:ITWindowAppearingState]; + + [_effectTimer invalidate]; + _effectTimer = nil; + + [self performAppearFromProgress:[_window effectProgress] effectTime:(_effectTime / 3.5)]; +} + + +/*************************************************************************/ +#pragma mark - +#pragma mark PRIVATE METHOD IMPLEMENTATIONS +/*************************************************************************/ + +- (void)setZoom:(float)Zoom +{ + 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); + 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) { + 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 ); + + transform = CGAffineTransformTranslate(transform, translation.x, translation.y); + + CGSSetWindowTransform([NSApp contextID], + (CGSWindowID)[_window windowNumber], + transform); +} + +@end diff --git a/Showcase/Controller.h b/Showcase/Controller.h index 399b3c9..490bec0 100755 --- a/Showcase/Controller.h +++ b/Showcase/Controller.h @@ -26,6 +26,8 @@ IBOutlet ITTextField *testTextField; // ITTransientStatusWindow Support + IBOutlet NSPopUpButton *entryEffectPopup; + IBOutlet NSPopUpButton *exitEffectPopup; ITIconAndTextStatusWindow *statusWindow; IBOutlet NSTextView *swSampleTextView; IBOutlet NSPopUpButton *swVanishModePopup; @@ -50,6 +52,7 @@ - (IBAction)toggleCastsShadow:(id)sender; // ITTransientStatusWindow Support +- (void)populateEffectPopups; - (IBAction)buildStatusWindow:(id)sender; - (IBAction)toggleStatusWindow:(id)sender; - (IBAction)changeWindowSetting:(id)sender; diff --git a/Showcase/Controller.m b/Showcase/Controller.m index ba9c278..ac02c52 100755 --- a/Showcase/Controller.m +++ b/Showcase/Controller.m @@ -9,6 +9,7 @@ #import "ITSlideHorizontallyWindowEffect.h" #import "ITSlideVerticallyWindowEffect.h" #import "ITPivotWindowEffect.h" +#import "ITZoomWindowEffect.h" #import "ITMultilineTextFieldCell.h" @@ -40,9 +41,10 @@ [bevelView setBevelDepth:10]; statusWindow = [ITIconAndTextStatusWindow sharedWindow]; [statusWindow setEntryEffect:[[ITCutWindowEffect alloc] initWithWindow:statusWindow]]; - [statusWindow setExitEffect:[[ITDissolveWindowEffect alloc] initWithWindow:statusWindow]]; + [statusWindow setExitEffect:[[ITCutWindowEffect alloc] initWithWindow:statusWindow]]; [[statusWindow entryEffect] setEffectTime:[swEntrySpeedSlider floatValue]]; [[statusWindow exitEffect] setEffectTime:[swExitSpeedSlider floatValue]]; + [self populateEffectPopups]; // [tabView setAllowsDragging:YES]; [[NSColorPanel sharedColorPanel] setShowsAlpha:YES]; @@ -152,6 +154,21 @@ #pragma mark ITTransientStatusWindow SUPPORT /*************************************************************************/ +- (void)populateEffectPopups +{ + NSArray *effects = [ITWindowEffect effectClasses]; + int i; + [entryEffectPopup removeAllItems]; + [exitEffectPopup removeAllItems]; + for (i = 0; i < [effects count]; i++) { + id anItem = [effects objectAtIndex:i]; + [entryEffectPopup addItemWithTitle:[anItem effectName]]; + [exitEffectPopup addItemWithTitle:[anItem effectName]]; + [[entryEffectPopup lastItem] setRepresentedObject:anItem]; + [[exitEffectPopup lastItem] setRepresentedObject:anItem]; + } +} + - (IBAction)buildStatusWindow:(id)sender { NSImage *image = [NSImage imageNamed:SW_IMAGE]; @@ -194,39 +211,12 @@ } else if ( [sender tag] == 3061 ) { [[statusWindow exitEffect] setEffectTime:[sender floatValue]]; } else if ( [sender tag] == 3070 ) { - - if ( [sender indexOfSelectedItem] == 0 ) { - [statusWindow setEntryEffect:[[[ITCutWindowEffect alloc] initWithWindow:statusWindow] autorelease]]; - } else if ( [sender indexOfSelectedItem] == 1 ) { - [statusWindow setEntryEffect:[[[ITDissolveWindowEffect alloc] initWithWindow:statusWindow] autorelease]]; - } else if ( [sender indexOfSelectedItem] == 2 ) { - [statusWindow setEntryEffect:[[[ITSlideVerticallyWindowEffect alloc] initWithWindow:statusWindow] autorelease]]; - } else if ( [sender indexOfSelectedItem] == 3 ) { - [statusWindow setEntryEffect:[[[ITSlideHorizontallyWindowEffect alloc] initWithWindow:statusWindow] autorelease]]; - } else if ( [sender indexOfSelectedItem] == 4 ) { - [statusWindow setEntryEffect:[[[ITPivotWindowEffect alloc] initWithWindow:statusWindow] autorelease]]; - } - + [statusWindow setEntryEffect:[[[[[sender selectedItem] representedObject] alloc] initWithWindow:statusWindow] autorelease]]; [[statusWindow entryEffect] setEffectTime:[swEntrySpeedSlider floatValue]]; - } else if ( [sender tag] == 3080 ) { - - if ( [sender indexOfSelectedItem] == 0 ) { - [statusWindow setExitEffect:[[ITCutWindowEffect alloc] initWithWindow:statusWindow]]; - } else if ( [sender indexOfSelectedItem] == 1 ) { - [statusWindow setExitEffect:[[ITDissolveWindowEffect alloc] initWithWindow:statusWindow]]; - } else if ( [sender indexOfSelectedItem] == 2 ) { - [statusWindow setExitEffect:[[ITSlideVerticallyWindowEffect alloc] initWithWindow:statusWindow]]; - } else if ( [sender indexOfSelectedItem] == 3 ) { - [statusWindow setExitEffect:[[ITSlideHorizontallyWindowEffect alloc] initWithWindow:statusWindow]]; - } else if ( [sender indexOfSelectedItem] == 4 ) { - [statusWindow setExitEffect:[[ITPivotWindowEffect alloc] initWithWindow:statusWindow]]; - } - + [statusWindow setExitEffect:[[[[[sender selectedItem] representedObject] alloc] initWithWindow:statusWindow] autorelease]]; [[statusWindow exitEffect] setEffectTime:[swExitSpeedSlider floatValue]]; - } else if ( [sender tag] == 3090 ) { - if ( [sender indexOfSelectedItem] == 0 ) { [(ITTSWBackgroundView *)[statusWindow contentView] setBackgroundMode:ITTSWBackgroundApple]; } else if ( [sender indexOfSelectedItem] == 1 ) { @@ -234,7 +224,6 @@ } else if ( [sender indexOfSelectedItem] == 2 ) { [(ITTSWBackgroundView *)[statusWindow contentView] setBackgroundMode:ITTSWBackgroundColored]; } - } else if ( [sender tag] == 3100 ) { [(ITTSWBackgroundView *)[statusWindow contentView] setBackgroundColor:[sender color]]; } diff --git a/Showcase/English.lproj/MainMenu.nib/classes.nib b/Showcase/English.lproj/MainMenu.nib/classes.nib index 512782e..c083aec 100755 --- a/Showcase/English.lproj/MainMenu.nib/classes.nib +++ b/Showcase/English.lproj/MainMenu.nib/classes.nib @@ -22,6 +22,8 @@ OUTLETS = { bevelView = ITBevelView; button = ITButton; + entryEffectPopup = NSPopUpButton; + exitEffectPopup = NSPopUpButton; showImageCheckBox = NSButton; showStatusItemCheckBox = NSButton; showTitleCheckBox = NSButton; diff --git a/Showcase/English.lproj/MainMenu.nib/info.nib b/Showcase/English.lproj/MainMenu.nib/info.nib index 03db0ad..2f4c012 100755 --- a/Showcase/English.lproj/MainMenu.nib/info.nib +++ b/Showcase/English.lproj/MainMenu.nib/info.nib @@ -7,18 +7,18 @@ IBEditorPositions 197 - 624 471 153 118 0 0 1152 842 + 624 409 153 118 0 0 1152 746 29 1 271 349 44 0 0 1056 770 IBFramework Version - 349.0 + 364.0 IBOpenObjects 21 197 IBSystem Version - 7D24 + 7H63 diff --git a/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib b/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib index a0b1e18..e3a07fa 100755 Binary files a/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib and b/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib differ