New zoom effect.
authorKent Sutherland <ksuther@ithinksw.com>
Tue, 29 Jun 2004 05:30:37 +0000 (05:30 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Tue, 29 Jun 2004 05:30:37 +0000 (05:30 +0000)
ITKit.xcode/project.pbxproj
ITWindowEffect.m
ITZoomWindowEffect.h [new file with mode: 0755]
ITZoomWindowEffect.m [new file with mode: 0755]
Showcase/Controller.h
Showcase/Controller.m
Showcase/English.lproj/MainMenu.nib/classes.nib
Showcase/English.lproj/MainMenu.nib/info.nib
Showcase/English.lproj/MainMenu.nib/keyedobjects.nib

index 7beefb5..e0c00c0 100755 (executable)
                                );
                        };
                };
+               372C5812068FE72F00CEF54A = {
+                       fileEncoding = 30;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.objc;
+                       path = ITZoomWindowEffect.m;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               372C5813068FE72F00CEF54A = {
+                       fileEncoding = 30;
+                       isa = PBXFileReference;
+                       lastKnownFileType = sourcecode.c.h;
+                       path = ITZoomWindowEffect.h;
+                       refType = 4;
+                       sourceTree = "<group>";
+               };
+               372C5814068FE72F00CEF54A = {
+                       fileRef = 372C5812068FE72F00CEF54A;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
+               372C5815068FE72F00CEF54A = {
+                       fileRef = 372C5813068FE72F00CEF54A;
+                       isa = PBXBuildFile;
+                       settings = {
+                       };
+               };
 //370
 //371
 //372
                                7C992DEA054F5179000B93EA,
                                7C992DE7054F5179000B93EA,
                                7C992DE8054F5179000B93EA,
+                               372C5813068FE72F00CEF54A,
+                               372C5812068FE72F00CEF54A,
                        );
                        isa = PBXGroup;
                        name = Effects;
                                2AC8319D056D037700A7D7E2,
                                3710912805C0825900ED0F36,
                                7C4BBADC05F98C9900734027,
+                               372C5815068FE72F00CEF54A,
                        );
                        isa = PBXHeadersBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
                                2AC8319E056D037700A7D7E2,
                                3710912305C0821000ED0F36,
                                7C4BBADD05F98C9900734027,
+                               372C5814068FE72F00CEF54A,
                        );
                        isa = PBXSourcesBuildPhase;
                        runOnlyForDeploymentPostprocessing = 0;
index 231dc76..576d6d1 100755 (executable)
@@ -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 (executable)
index 0000000..9fc920e
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ *     ITKit
+ *  ITZoomWindowEffect
+ *    Effect subclass which zooms (expands/shrinks) a window into position on the screen.
+ *
+ *  Original Author : Kent Sutherland <ksutherland@ithinksw.com>
+ *   Responsibility : Kent Sutherland <ksutherland@ithinksw.com>
+ *
+ *  Copyright (c) 2002 - 2004 iThink Software.
+ *  All Rights Reserved
+ *
+ */
+
+
+#import <Cocoa/Cocoa.h>
+#import "ITWindowEffect.h"
+
+
+@interface ITZoomWindowEffect : ITWindowEffect <ITWindowEffect> {
+
+}
+
+@end
diff --git a/ITZoomWindowEffect.m b/ITZoomWindowEffect.m
new file mode 100755 (executable)
index 0000000..e80735f
--- /dev/null
@@ -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
index 399b3c9..490bec0 100755 (executable)
@@ -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;
index ba9c278..ac02c52 100755 (executable)
@@ -9,6 +9,7 @@
 #import "ITSlideHorizontallyWindowEffect.h"
 #import "ITSlideVerticallyWindowEffect.h"
 #import "ITPivotWindowEffect.h"
+#import "ITZoomWindowEffect.h"
 #import "ITMultilineTextFieldCell.h"
 
 
     [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];
     
 #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];
     } 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 ) {
         } else if ( [sender indexOfSelectedItem] == 2 ) {
             [(ITTSWBackgroundView *)[statusWindow contentView] setBackgroundMode:ITTSWBackgroundColored];
         }
-        
     } else if ( [sender tag] == 3100 ) {
         [(ITTSWBackgroundView *)[statusWindow contentView] setBackgroundColor:[sender color]];
     }
index 512782e..c083aec 100755 (executable)
@@ -22,6 +22,8 @@
             OUTLETS = {
                 bevelView = ITBevelView; 
                 button = ITButton; 
+                entryEffectPopup = NSPopUpButton; 
+                exitEffectPopup = NSPopUpButton; 
                 showImageCheckBox = NSButton; 
                 showStatusItemCheckBox = NSButton; 
                 showTitleCheckBox = NSButton; 
index 03db0ad..2f4c012 100755 (executable)
@@ -7,18 +7,18 @@
        <key>IBEditorPositions</key>
        <dict>
                <key>197</key>
-               <string>624 471 153 118 0 0 1152 842 </string>
+               <string>624 409 153 118 0 0 1152 746 </string>
                <key>29</key>
                <string>1 271 349 44 0 0 1056 770 </string>
        </dict>
        <key>IBFramework Version</key>
-       <string>349.0</string>
+       <string>364.0</string>
        <key>IBOpenObjects</key>
        <array>
                <integer>21</integer>
                <integer>197</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>7D24</string>
+       <string>7H63</string>
 </dict>
 </plist>
index a0b1e18..e3a07fa 100755 (executable)
Binary files a/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib and b/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib differ