Builds now. Also some moderate effect architecture changes.
[ITKit.git] / ITTransientStatusWindow.m
index 4182d57..f749278 100755 (executable)
@@ -1,18 +1,11 @@
 #import "ITTransientStatusWindow.h"
+#import "ITWindowEffect.h"
 #import <CoreGraphics/CoreGraphics.h>
 #import "ITCoreGraphicsHacks.h"
 #import "ITTextField.h"
 #import "ITGrayRoundedView.h"
 
-
-/*************************************************************************/
-#pragma mark -
-#pragma mark EVIL HACKERY
-/*************************************************************************/
-
-@interface NSApplication (HACKHACKHACKHACK)
-- (CGSConnectionID)contextID;
-@end
+#define EFFECT_FPS 30.0
 
 
 /*************************************************************************/
                  exitMode:(ITTransientStatusWindowExitMode)exitMode
            backgroundType:(ITTransientStatusWindowBackgroundType)backgroundType;
 - (void)rebuildWindow;
-- (void)performEffect;
-- (void)dissolveEffect:(BOOL)entering;
-- (void)slideVerticalEffect:(BOOL)entering;
-- (void)slideHorizontalEffect:(BOOL)entering;
+// - (void)performEffect;
 @end
 
 
@@ -69,10 +59,7 @@ static ITTransientStatusWindow *staticWindow = nil;
 {
     NSRect contentRect;
     
-    CGSValueObj         key;
-    CGSValueObj         ignore;
-
-    // If no Content View was provided, use a generic NSImageView with the app icon.
+    // If no Content View was provided, use a generic view.
     if ( ! (contentView) ) {
         contentView = [[[NSView alloc] initWithFrame:
             NSMakeRect(100.0, 100.0, 200.0, 200.0)] autorelease];
@@ -86,34 +73,26 @@ static ITTransientStatusWindow *staticWindow = nil;
                                      backing:NSBackingStoreBuffered
                                        defer:NO] ) ) {
                                     
-        _visibilityState    = ITTransientStatusWindowHiddenState;
-        _exitMode           = exitMode;
-        _exitDelay          = DEFAULT_EXIT_DELAY;
-        _backgroundType     = backgroundType;
-        _verticalPosition   = ITTransientStatusWindowPositionBottom;
-        _horizontalPosition = ITTransientStatusWindowPositionLeft;
-        _entryEffect        = ITTransientStatusWindowEffectNone;
-        _exitEffect         = ITTransientStatusWindowEffectDissolve;
-        
-        _delayTimer = nil;
-        _fadeTimer  = nil;
-
-//        if ( _backgroundType == ITTransientStatusWindowRounded ) {
-//            _contentSubView = contentView;
-//        } else {
-//            [self setContentView:contentView];
-//        }
-
-//      [self setIgnoresMouseEvents:YES];
-
-        key = CGSCreateCString("IgnoreForEvents");
-        ignore = CGSCreateBoolean(kCGSTrue);
-        
-        CGSSetWindowProperty([NSApp contextID], (CGSWindowID)[self windowNumber], key, ignore);
-
-        CGSReleaseObj(key);
-        CGSReleaseObj(ignore);
-        
+        _visibilityState     = ITTransientStatusWindowHiddenState;
+        _exitMode            = exitMode;
+        _exitDelay           = DEFAULT_EXIT_DELAY;
+        _backgroundType      = backgroundType;
+        _verticalPosition    = ITWindowPositionBottom;
+        _horizontalPosition  = ITWindowPositionLeft;
+        _screenPadding       = 32.0;
+        _screenNumber        = 0;
+        _entryEffect         = nil;
+        _exitEffect          = nil;
+        _reallyIgnoresEvents = YES;
+        _delayTimer          = nil;
+
+//      if ( _backgroundType == ITTransientStatusWindowRounded ) {
+//          _contentSubView = contentView;
+//      } else {
+//          [self setContentView:contentView];
+//      }
+
+        [self setIgnoresMouseEvents:YES];
         [self setLevel:NSScreenSaverWindowLevel];
         [self setContentView:contentView];
         [self rebuildWindow];
@@ -127,27 +106,49 @@ static ITTransientStatusWindow *staticWindow = nil;
 #pragma mark INSTANCE METHODS
 /*************************************************************************/
 
-- (void)orderFront:(id)sender
+- (BOOL)ignoresMouseEvents
 {
-    if ( _exitMode = ITTransientStatusWindowExitAfterDelay ) {
-        // set the timer, and orderOut: when it lapses.
-    }
+    return _reallyIgnoresEvents;
+}
+
+- (void)setIgnoresMouseEvents:(BOOL)flag
+{
+    CGSValueObj         key;
+    CGSValueObj         ignore;
+
+    key = CGSCreateCString("IgnoreForEvents");
+    ignore = CGSCreateBoolean( (flag ? kCGSTrue : kCGSFalse) );
+    CGSSetWindowProperty([NSApp contextID], (CGSWindowID)[self windowNumber], key, ignore);
+    CGSReleaseObj(key);
+    CGSReleaseObj(ignore);
+
+    _reallyIgnoresEvents = flag;
+}
+
+/*
 
-    if ( _entryEffect == ITTransientStatusWindowEffectNone ) {
+- (void)orderFront:(id)sender
+{
+    if ( _entryEffect == nil ) {
         [super orderFront:sender];
+        _visibilityState = ITTransientStatusWindowVisibleState;
     } else {
         [self performEffect];
     }
+    if ( _exitMode == ITTransientStatusWindowExitAfterDelay ) {
+        // set the timer, and orderOut: when it lapses.
+    }
 }
 
 - (void)makeKeyAndOrderFront:(id)sender
 {
-    if ( _exitMode = ITTransientStatusWindowExitAfterDelay ) {
+    if ( _exitMode == ITTransientStatusWindowExitAfterDelay ) {
         // set the timer, and orderOut: when it lapses.
     }
 
-    if ( _entryEffect == ITTransientStatusWindowEffectNone ) {
+    if ( _entryEffect == nil ) {
         [super makeKeyAndOrderFront:sender];
+        _visibilityState = ITTransientStatusWindowVisibleState;
     } else {
         [self performEffect];
         [self makeKeyWindow];
@@ -156,14 +157,18 @@ static ITTransientStatusWindow *staticWindow = nil;
 
 - (void)orderOut:(id)sender
 {
-    if ( _entryEffect == ITTransientStatusWindowEffectNone ) {
+    if ( _entryEffect == nil ) {
         [super orderOut:sender];
+        _visibilityState = ITTransientStatusWindowHiddenState;
     } else {
         [self performEffect];
     }
 }
 
-/*
+- (NSTimeInterval)animationResizeTime:(NSRect)newFrame
+{
+    return _resizeTime;
+}
 
 - (id)contentView
 {
@@ -189,12 +194,38 @@ 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;
 }
 
-- (ITTransientStatusWindowExitMode)ExitMode
+- (ITTransientStatusWindowExitMode)exitMode
 {
     return _exitMode;
 }
@@ -227,44 +258,66 @@ 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;
 }
 
-- (ITTransientStatusWindowEffect)entryEffect
+- (float)screenPadding
+{
+    return _screenPadding;
+}
+
+- (void)setScreenPadding:(float)newPadding
+{
+    _screenPadding = newPadding;
+}
+
+- (int)screenNumber
+{
+    return _screenNumber;
+}
+
+- (void)setScreenNumber:(int)newNumber
+{
+    _screenNumber = newNumber;
+}
+
+- (ITWindowEffect *)entryEffect
 {
     return _entryEffect;
 }
 
-- (void)setEntryEffect:(ITTransientStatusWindowEffect)newEffect;
+- (void)setEntryEffect:(ITWindowEffect *)newEffect
 {
-    _entryEffect = newEffect;
+    [_entryEffect autorelease];
+    _entryEffect = [newEffect retain];
 }
 
-- (ITTransientStatusWindowEffect)exitEffect;
+- (ITWindowEffect *)exitEffect
 {
     return _exitEffect;
 }
 
-- (void)setExitEffect:(ITTransientStatusWindowEffect)newEffect;
+- (void)setExitEffect:(ITWindowEffect *)newEffect
 {
-    _exitEffect = newEffect;
+    [_exitEffect autorelease];
+    _exitEffect = [newEffect retain];
 }
 
 
@@ -291,42 +344,30 @@ static ITTransientStatusWindow *staticWindow = nil;
     }
 }
 
+/*
+
 - (void)performEffect
 {
     if ( _visibilityState == ITTransientStatusWindowHiddenState ) {
-        if ( _entryEffect == ITTransientStatusWindowEffectDissolve ) {
-            [self dissolveEffect:YES];
-        } else if ( _entryEffect == ITTransientStatusWindowEffectSlideVertically ) {
-            [self slideEffect:YES];
-        } else if ( _entryEffect == ITTransientStatusWindowEffectSlideHorizontally ) {
-            [self slideEffect:YES];
-        }
+        _visibilityState = ITTransientStatusWindowEnteringState;
     } else if ( _visibilityState == ITTransientStatusWindowVisibleState ) {
-        if ( _exitEffect == ITTransientStatusWindowEffectDissolve ) {
-            [self dissolveEffect:NO];
-        } else if ( _exitEffect == ITTransientStatusWindowEffectSlideVertically ) {
-            [self slideEffect:NO];
-        } else if ( _exitEffect == ITTransientStatusWindowEffectSlideHorizontally ) {
-            [self slideEffect:NO];
-        }
+        _visibilityState = ITTransientStatusWindowExitingState;
+    } else {
+        return;
+    }
+        
+    if ( _entryEffect == ITTransientStatusWindowEffectDissolve ) {
+        [self dissolveEffect];
+    } else if ( _entryEffect == ITTransientStatusWindowEffectSlideVertically ) {
+        [self slideVerticalEffect];
+    } else if ( _entryEffect == ITTransientStatusWindowEffectSlideHorizontally ) {
+        [self slideHorizontalEffect];
+    } else if ( _entryEffect == ITTransientStatusWindowEffectPivot ) {
+        [self pivotEffect];
     }
 }
 
-- (void)dissolveEffect:(BOOL)entering
-{
-    
-    [super orderFront:self];
-}
-
-- (void)slideVerticalEffect:(BOOL)entering
-{
-    [super orderFront:self];
-}
-
-- (void)slideHorizontalEffect:(BOOL)entering
-{
-    [super orderFront:self];
-}
+*/
 
 
 @end