From: Matthew Judy Date: Mon, 14 Apr 2003 12:31:41 +0000 (+0000) Subject: HUGE ITTSW Checkin. For those only interested in the short version, it is as X-Git-Tag: v0.1~46 X-Git-Url: http://git.ithinksw.org/ITKit.git/commitdiff_plain/e873f11d0bb398c460817aa1dd4061572f5a1d09 HUGE ITTSW Checkin. For those only interested in the short version, it is as follows: ITTransientStatusWindow is now feature complete except for positioning. All currently planned effects work, and you can use the Showcase to play with them. - Renamed the visibility state constants, removing the string "StatusWindow" from them, since window visibility is a protocol not limited to ITTSW. - Implemented ITSlideHorizontallyWindowEffect and ITSlideVerticallyWindowEffect. This completes the 1.0 planned suite. - Implemented a heuristic for effects to be able to release themselves when idle, so that an effect can finish a transition smoothly, and release gracefully, instead of crashing. - Made all effects return the window to normal after vanish, so that they don't have to worry about doing so when they appear. Some do anyway. - Implemented timed exit, and the various logic to make the two exit modes work seamlessly. - Modified the Showcase Controller and nib to allow use and testing of all ITTSW's features. Unavailable features are disabled. Removed the switch/case block and used an if/else block instead. Switch/case sucks. Hard. - Decided against a separate cancelVanishEffect. I like our way better, and I think it's a better UE than Apple's, so... fuck Apple. Fuck them in their stupid asses. REMAINING: ---------- - Positioning - MT Status Window Controller. Should be able to complete at least one of those tomorrow. Positioning comes first. --- diff --git a/ITCutWindowEffect.m b/ITCutWindowEffect.m index a42fcc8..79381cb 100755 --- a/ITCutWindowEffect.m +++ b/ITCutWindowEffect.m @@ -13,7 +13,7 @@ - (void)performAppear { [_window orderFront:self]; - [self setWindowVisibility:ITTransientStatusWindowVisibleState]; + [self setWindowVisibility:ITWindowVisibleState]; } - (void)cancelAppear @@ -30,7 +30,7 @@ - (void)performVanish { [_window orderOut:self]; - [self setWindowVisibility:ITTransientStatusWindowHiddenState]; + [self setWindowVisibility:ITWindowHiddenState]; } - (void)cancelVanish diff --git a/ITDissolveWindowEffect.m b/ITDissolveWindowEffect.m index fc2bd38..147840d 100755 --- a/ITDissolveWindowEffect.m +++ b/ITDissolveWindowEffect.m @@ -22,7 +22,9 @@ - (void)performAppear { - [self setWindowVisibility:ITTransientStatusWindowAppearingState]; + __idle = NO; + + [self setWindowVisibility:ITWindowAppearingState]; [self performAppearFromProgress:0.0 effectTime:_effectTime]; } @@ -60,12 +62,18 @@ { [_effectTimer invalidate]; _effectTimer = nil; - [self setWindowVisibility:ITTransientStatusWindowVisibleState]; + [self setWindowVisibility:ITWindowVisibleState]; + + __idle = YES; + + if ( __shouldReleaseWhenIdle ) { + [self release]; + } } - (void)cancelAppear { - [self setWindowVisibility:ITTransientStatusWindowVanishingState]; + [self setWindowVisibility:ITWindowVanishingState]; [_effectTimer invalidate]; _effectTimer = nil; @@ -81,7 +89,9 @@ - (void)performVanish { - [self setWindowVisibility:ITTransientStatusWindowVanishingState]; + __idle = NO; + + [self setWindowVisibility:ITWindowVanishingState]; [self performVanishFromProgress:1.0 effectTime:_effectTime]; } @@ -120,12 +130,18 @@ _effectTimer = nil; [_window orderOut:self]; [_window setAlphaValue:1.0]; - [self setWindowVisibility:ITTransientStatusWindowHiddenState]; + [self setWindowVisibility:ITWindowHiddenState]; + + __idle = YES; + + if ( __shouldReleaseWhenIdle ) { + [self release]; + } } - (void)cancelVanish { - [self setWindowVisibility:ITTransientStatusWindowVanishingState]; + [self setWindowVisibility:ITWindowVanishingState]; [_effectTimer invalidate]; _effectTimer = nil; diff --git a/ITPivotWindowEffect.m b/ITPivotWindowEffect.m index 95c1040..25e21d4 100755 --- a/ITPivotWindowEffect.m +++ b/ITPivotWindowEffect.m @@ -24,7 +24,9 @@ - (void)performAppear { - [self setWindowVisibility:ITTransientStatusWindowAppearingState]; + __idle = NO; + + [self setWindowVisibility:ITWindowAppearingState]; [self performAppearFromProgress:0.0 effectTime:_effectTime]; } @@ -64,12 +66,18 @@ { [_effectTimer invalidate]; _effectTimer = nil; - [self setWindowVisibility:ITTransientStatusWindowVisibleState]; + [self setWindowVisibility:ITWindowVisibleState]; + + __idle = YES; + + if ( __shouldReleaseWhenIdle ) { + [self release]; + } } - (void)cancelAppear { - [self setWindowVisibility:ITTransientStatusWindowVanishingState]; + [self setWindowVisibility:ITWindowVanishingState]; [_effectTimer invalidate]; _effectTimer = nil; @@ -85,7 +93,9 @@ - (void)performVanish { - [self setWindowVisibility:ITTransientStatusWindowVanishingState]; + __idle = NO; + + [self setWindowVisibility:ITWindowVanishingState]; [self performVanishFromProgress:1.0 effectTime:_effectTime]; } @@ -126,12 +136,19 @@ _effectTimer = nil; [_window orderOut:self]; [_window setAlphaValue:1.0]; - [self setWindowVisibility:ITTransientStatusWindowHiddenState]; + [self setPivot:0.0]; + [self setWindowVisibility:ITWindowHiddenState]; + + __idle = YES; + + if ( __shouldReleaseWhenIdle ) { + [self release]; + } } - (void)cancelVanish { - [self setWindowVisibility:ITTransientStatusWindowAppearingState]; + [self setWindowVisibility:ITWindowAppearingState]; [_effectTimer invalidate]; _effectTimer = nil; diff --git a/ITSlideHorizontallyWindowEffect.m b/ITSlideHorizontallyWindowEffect.m index c5f3fba..ac302ff 100755 --- a/ITSlideHorizontallyWindowEffect.m +++ b/ITSlideHorizontallyWindowEffect.m @@ -1,28 +1,166 @@ #import "ITSlideHorizontallyWindowEffect.h" +#import "ITCoreGraphicsHacks.h" +#import "ITTransientStatusWindow.h" + + +@interface ITSlideHorizontallyWindowEffect (Private) +- (void)performAppearFromProgress:(float)progress effectTime:(float)time; +- (void)appearStep; +- (void)appearFinish; +- (void)performVanishFromProgress:(float)progress effectTime:(float)time; +- (void)vanishStep; +- (void)vanishFinish; +- (void)setSlide:(float)distance; +@end @implementation ITSlideHorizontallyWindowEffect +/*************************************************************************/ +#pragma mark - +#pragma mark APPEAR METHODS +/*************************************************************************/ + - (void)performAppear { - NSLog(@"ITSlideHorizontallyWindowEffect does not implement performAppear."); + __idle = NO; + + [self setWindowVisibility:ITWindowAppearingState]; + [self performAppearFromProgress:0.0 effectTime:_effectTime]; } -- (void)performVanish +- (void)performAppearFromProgress:(float)progress effectTime:(float)time { - NSLog(@"ITSlideHorizontallyWindowEffect does not implement performVanish."); + [_window setEffectProgress:progress]; + _effectSpeed = (1.0 / (EFFECT_FPS * time)); + + if ( progress == 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 interSlide = 0.0; + [_window setEffectProgress:([_window effectProgress] + _effectSpeed)]; + [_window setEffectProgress:( ([_window effectProgress] < 1.0) ? [_window effectProgress] : 1.0)]; + interSlide = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2); + [self setSlide:( [_window frame].size.width - (interSlide * [_window frame].size.width) )]; + [_window setAlphaValue:interSlide]; + + if ( [_window effectProgress] >= 1.0 ) { + [self appearFinish]; + } +} + +- (void)appearFinish +{ + [_effectTimer invalidate]; + _effectTimer = nil; + [self setWindowVisibility:ITWindowVisibleState]; + + __idle = YES; + + if ( __shouldReleaseWhenIdle ) { + [self release]; + } } - (void)cancelAppear { - NSLog(@"ITSlideHorizontallyWindowEffect does not implement cancelAppear."); + [self setWindowVisibility:ITWindowVanishingState]; + + [_effectTimer invalidate]; + _effectTimer = nil; + + [self performVanishFromProgress:[_window effectProgress] effectTime:(_effectTime / 4.0)]; +} + + +/*************************************************************************/ +#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 ) { + [_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 interSlide = 1.0; + [_window setEffectProgress:([_window effectProgress] - _effectSpeed)]; + [_window setEffectProgress:( ([_window effectProgress] > 0.0) ? [_window effectProgress] : 0.0)]; + interSlide = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2); + [self setSlide:( [_window frame].size.width - (interSlide * [_window frame].size.width) )]; + [_window setAlphaValue:interSlide]; + + if ( [_window effectProgress] <= 0.0 ) { + [self vanishFinish]; + } +} + +- (void)vanishFinish +{ + [_effectTimer invalidate]; + _effectTimer = nil; + [_window orderOut:self]; + [_window setAlphaValue:1.0]; + [self setSlide:0.0]; + [self setWindowVisibility:ITWindowHiddenState]; + + __idle =YES; + + if ( __shouldReleaseWhenIdle ) { + [self release]; + } } - (void)cancelVanish { - NSLog(@"ITSlideHorizontallyWindowEffect does not implement cancelVanish."); + [self setWindowVisibility:ITWindowAppearingState]; + + [_effectTimer invalidate]; + _effectTimer = nil; + + [self performAppearFromProgress:[_window effectProgress] effectTime:(_effectTime / 4.0)]; } +- (void)setSlide:(float)distance +{ + CGAffineTransform transform = CGAffineTransformMakeTranslation((distance - 32.0), + -( [[_window screen] frame].size.height - ( [_window frame].size.height + 32.0) ) ); + CGSSetWindowTransform([NSApp contextID], + (CGSWindowID)[_window windowNumber], + transform); +} @end diff --git a/ITSlideVerticallyWindowEffect.m b/ITSlideVerticallyWindowEffect.m index 143e079..d5b1b6f 100755 --- a/ITSlideVerticallyWindowEffect.m +++ b/ITSlideVerticallyWindowEffect.m @@ -1,28 +1,166 @@ #import "ITSlideVerticallyWindowEffect.h" +#import "ITCoreGraphicsHacks.h" +#import "ITTransientStatusWindow.h" + + +@interface ITSlideVerticallyWindowEffect (Private) +- (void)performAppearFromProgress:(float)progress effectTime:(float)time; +- (void)appearStep; +- (void)appearFinish; +- (void)performVanishFromProgress:(float)progress effectTime:(float)time; +- (void)vanishStep; +- (void)vanishFinish; +- (void)setSlide:(float)distance; +@end @implementation ITSlideVerticallyWindowEffect +/*************************************************************************/ +#pragma mark - +#pragma mark APPEAR METHODS +/*************************************************************************/ + - (void)performAppear { - NSLog(@"ITSlideVerticallyWindowEffect does not implement performAppear."); + __idle = NO; + + [self setWindowVisibility:ITWindowAppearingState]; + [self performAppearFromProgress:0.0 effectTime:_effectTime]; } -- (void)performVanish +- (void)performAppearFromProgress:(float)progress effectTime:(float)time +{ + [_window setEffectProgress:progress]; + _effectSpeed = (1.0 / (EFFECT_FPS * time)); + + if ( progress == 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 { - NSLog(@"ITSlideVerticallyWindowEffect does not implement performVanish."); + float interSlide = 0.0; + [_window setEffectProgress:([_window effectProgress] + _effectSpeed)]; + [_window setEffectProgress:( ([_window effectProgress] < 1.0) ? [_window effectProgress] : 1.0)]; + interSlide = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2); + [self setSlide:(interSlide * [_window frame].size.height)]; + [_window setAlphaValue:interSlide]; + + if ( [_window effectProgress] >= 1.0 ) { + [self appearFinish]; + } +} + +- (void)appearFinish +{ + [_effectTimer invalidate]; + _effectTimer = nil; + [self setWindowVisibility:ITWindowVisibleState]; + + __idle = YES; + + if ( __shouldReleaseWhenIdle ) { + [self release]; + } } - (void)cancelAppear { - NSLog(@"ITSlideVerticallyWindowEffect does not implement cancelAppear."); + [self setWindowVisibility:ITWindowVanishingState]; + + [_effectTimer invalidate]; + _effectTimer = nil; + + [self performVanishFromProgress:[_window effectProgress] effectTime:(_effectTime / 4.0)]; } -- (void)cancelVanish + +/*************************************************************************/ +#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 ) { + [_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 interSlide = 1.0; + [_window setEffectProgress:([_window effectProgress] - _effectSpeed)]; + [_window setEffectProgress:( ([_window effectProgress] > 0.0) ? [_window effectProgress] : 0.0)]; + interSlide = (( sin(([_window effectProgress] * pi) - (pi / 2)) + 1 ) / 2); + [self setSlide:(interSlide * [_window frame].size.height)]; + [_window setAlphaValue:interSlide]; + + if ( [_window effectProgress] <= 0.0 ) { + [self vanishFinish]; + } +} + +- (void)vanishFinish { - NSLog(@"ITSlideVerticallyWindowEffect does not implement cancelVanish."); + [_effectTimer invalidate]; + _effectTimer = nil; + [_window orderOut:self]; + [_window setAlphaValue:1.0]; + [self setSlide:[_window frame].size.height]; + [self setWindowVisibility:ITWindowHiddenState]; + + __idle = YES; + + if ( __shouldReleaseWhenIdle ) { + [self release]; + } } +- (void)cancelVanish +{ + [self setWindowVisibility:ITWindowAppearingState]; + + [_effectTimer invalidate]; + _effectTimer = nil; + + [self performAppearFromProgress:[_window effectProgress] effectTime:(_effectTime / 4.0)]; +} +- (void)setSlide:(float)distance +{ + CGAffineTransform transform = CGAffineTransformMakeTranslation( -32.0, + -( [[_window screen] frame].size.height - ( distance + 32.0) ) ); + + CGSSetWindowTransform([NSApp contextID], + (CGSWindowID)[_window windowNumber], + transform); +} @end diff --git a/ITTransientStatusWindow.h b/ITTransientStatusWindow.h index dcbe360..9fbd1fc 100755 --- a/ITTransientStatusWindow.h +++ b/ITTransientStatusWindow.h @@ -59,7 +59,7 @@ typedef enum { BOOL _reallyIgnoresEvents; - NSTimer *_delayTimer; + NSTimer *_exitTimer; // NSView *_contentSubView; } diff --git a/ITTransientStatusWindow.m b/ITTransientStatusWindow.m index 6cb33a3..bae7b53 100755 --- a/ITTransientStatusWindow.m +++ b/ITTransientStatusWindow.m @@ -19,6 +19,7 @@ backgroundType:(ITTransientStatusWindowBackgroundType)backgroundType; - (void)rebuildWindow; - (void)startVanishTimer; +- (void)stopVanishTimer; @end @@ -73,7 +74,7 @@ static ITTransientStatusWindow *staticWindow = nil; backing:NSBackingStoreBuffered defer:NO] ) ) { - _visibilityState = ITTransientStatusWindowHiddenState; + _visibilityState = ITWindowHiddenState; _exitMode = exitMode; _exitDelay = DEFAULT_EXIT_DELAY; _backgroundType = backgroundType; @@ -84,7 +85,7 @@ static ITTransientStatusWindow *staticWindow = nil; _entryEffect = nil; _exitEffect = nil; _reallyIgnoresEvents = YES; - _delayTimer = nil; + _exitTimer = nil; // if ( _backgroundType == ITTransientStatusWindowRounded ) { // _contentSubView = contentView; @@ -154,15 +155,15 @@ static ITTransientStatusWindow *staticWindow = nil; - (IBAction)appear:(id)sender { - if ( _visibilityState == ITTransientStatusWindowHiddenState ) { + if ( _visibilityState == ITWindowHiddenState ) { // Window is hidden. Appear as normal, and start the timer. [_entryEffect performAppear]; - } else if ( _visibilityState == ITTransientStatusWindowVisibleState ) { + } else if ( _visibilityState == ITWindowVisibleState ) { // Window is completely visible. Simply reset the timer. [self startVanishTimer]; - } else if ( _visibilityState == ITTransientStatusWindowAppearingState ) { + } else if ( _visibilityState == ITWindowAppearingState ) { // Window is on its way in. Do nothing. - } else if ( _visibilityState == ITTransientStatusWindowVanishingState ) { + } else if ( _visibilityState == ITWindowVanishingState ) { // Window is on its way out. Cancel the vanish. [_exitEffect cancelVanish]; } @@ -170,15 +171,15 @@ static ITTransientStatusWindow *staticWindow = nil; - (IBAction)vanish:(id)sender { - if ( _visibilityState == ITTransientStatusWindowVisibleState ) { + if ( _visibilityState == ITWindowVisibleState ) { // Window is totally visible. Perform exit effect. [_exitEffect performVanish]; - } else if ( _visibilityState == ITTransientStatusWindowHiddenState ) { + } else if ( _visibilityState == ITWindowHiddenState ) { // Window is hidden. Do nothing. - } else if ( _visibilityState == ITTransientStatusWindowAppearingState ) { + } else if ( _visibilityState == ITWindowAppearingState ) { // Window is on its way in. Cancel appear. [_entryEffect cancelAppear]; - } else if ( _visibilityState == ITTransientStatusWindowVanishingState ) { + } else if ( _visibilityState == ITWindowVanishingState ) { // Window is on its way out. Do nothing. } } @@ -192,7 +193,7 @@ static ITTransientStatusWindow *staticWindow = nil; { _visibilityState = newState; - if ( _visibilityState == ITTransientStatusWindowVisibleState ) { + if ( _visibilityState == ITWindowVisibleState ) { [self startVanishTimer]; } } @@ -205,6 +206,14 @@ static ITTransientStatusWindow *staticWindow = nil; - (void)setExitMode:(ITTransientStatusWindowExitMode)newMode { _exitMode = newMode; + + if ( _visibilityState == ITWindowVisibleState ) { + if ( _exitMode == ITTransientStatusWindowExitOnCommand ) { + [self stopVanishTimer]; + } else if ( _exitMode == ITTransientStatusWindowExitAfterDelay ) { + [self startVanishTimer]; + } + } } - (float)exitDelay @@ -287,7 +296,7 @@ static ITTransientStatusWindow *staticWindow = nil; - (void)setEntryEffect:(ITWindowEffect *)newEffect { - [_entryEffect autorelease]; + [_entryEffect releaseWhenIdle]; _entryEffect = [newEffect retain]; } @@ -298,7 +307,7 @@ static ITTransientStatusWindow *staticWindow = nil; - (void)setExitEffect:(ITWindowEffect *)newEffect { - [_exitEffect autorelease]; + [_exitEffect releaseWhenIdle]; _exitEffect = [newEffect retain]; } @@ -328,8 +337,28 @@ static ITTransientStatusWindow *staticWindow = nil; - (void)startVanishTimer { - // start timer, if appropriate - // if timer already exists, restart it. + if ( _exitMode == ITTransientStatusWindowExitAfterDelay) { + [self stopVanishTimer]; + _exitTimer = [NSTimer scheduledTimerWithTimeInterval:_exitDelay + target:self + selector:@selector(doDelayedExit) + userInfo:nil + repeats:NO]; + } +} + +- (void)doDelayedExit +{ + [self vanish:self]; + _exitTimer = nil; +} + +- (void)stopVanishTimer +{ + if ( _exitTimer ) { + [_exitTimer invalidate]; + _exitTimer = nil; + } } @end diff --git a/ITWindowEffect.h b/ITWindowEffect.h index 71852e2..9ce6fcf 100755 --- a/ITWindowEffect.h +++ b/ITWindowEffect.h @@ -22,10 +22,10 @@ typedef enum { - ITTransientStatusWindowHiddenState, - ITTransientStatusWindowAppearingState, - ITTransientStatusWindowVisibleState, - ITTransientStatusWindowVanishingState + ITWindowHiddenState, + ITWindowAppearingState, + ITWindowVisibleState, + ITWindowVanishingState } ITWindowVisibilityState; @@ -53,6 +53,8 @@ typedef enum { ITVerticalWindowPosition _verticalPosition; ITHorizontalWindowPosition _horizontalPosition; NSTimer *_effectTimer; + BOOL __idle; + BOOL __shouldReleaseWhenIdle; } // Designated initializer @@ -67,4 +69,6 @@ typedef enum { - (float)effectTime; - (void)setEffectTime:(float)newTime; +- (void)releaseWhenIdle; + @end diff --git a/ITWindowEffect.m b/ITWindowEffect.m index 752742b..c1bdf0e 100755 --- a/ITWindowEffect.m +++ b/ITWindowEffect.m @@ -9,9 +9,11 @@ { if ( (self = [super init]) ) { - _window = [window retain]; - _effectTime = DEFAULT_EFFECT_TIME; - _effectTimer = nil; + _window = [window retain]; + _effectTime = DEFAULT_EFFECT_TIME; + _effectTimer = nil; + __shouldReleaseWhenIdle = NO; + __idle = YES; if ( [window conformsToProtocol:@protocol(ITWindowPositioning)] ) { // Casts so the compiler won't gripe @@ -77,6 +79,15 @@ NSLog(@"ITWindowEffect does not implement cancelVanish."); } +- (void)releaseWhenIdle; +{ + if ( __idle ) { + [self release]; + } else { + __shouldReleaseWhenIdle = YES; + } +} + - (void)dealloc { [_window release]; diff --git a/Showcase/Controller.h b/Showcase/Controller.h index 8f96266..f8b3b6d 100755 --- a/Showcase/Controller.h +++ b/Showcase/Controller.h @@ -26,6 +26,7 @@ IBOutlet NSPopUpButton *swBackgroundTypePopup; IBOutlet NSPopUpButton *swDefinedPositionPopup; IBOutlet NSTextField *swVanishDelay; + IBOutlet NSSlider *swSpeedSlider; } // ITStatusItem Support diff --git a/Showcase/Controller.m b/Showcase/Controller.m index f2680bd..80fc5f1 100755 --- a/Showcase/Controller.m +++ b/Showcase/Controller.m @@ -1,9 +1,12 @@ #import "Controller.h" #import "ITTransientStatusWindow.h" #import "ITTextField.h" -#import "ITPivotWindowEffect.h" -#import "ITDissolveWindowEffect.h" #import "ITCutWindowEffect.h" +#import "ITDissolveWindowEffect.h" +#import "ITSlideHorizontallyWindowEffect.h" +#import "ITSlideVerticallyWindowEffect.h" +#import "ITPivotWindowEffect.h" + #define SW_PAD 24.0 #define SW_SPACE 24.0 @@ -11,6 +14,7 @@ #define SW_BORDER 32.0 #define SW_IMAGE @"Library" + @interface Controller (ITStatusItemSupport) - (void)createStatusItem; - (void)removeStatusItem; @@ -25,7 +29,12 @@ [testTextField setCastsShadow:YES]; [tabView setAllowsDragging:YES]; statusWindow = [ITTransientStatusWindow sharedWindow]; + [statusWindow setEntryEffect:[[ITCutWindowEffect alloc] initWithWindow:statusWindow]]; + [statusWindow setExitEffect:[[ITDissolveWindowEffect alloc] initWithWindow:statusWindow]]; + [[statusWindow entryEffect] setEffectTime:[swSpeedSlider floatValue]]; + [[statusWindow exitEffect] setEffectTime:[swSpeedSlider floatValue]]; // [tabView setAllowsDragging:YES]; + } /*************************************************************************/ @@ -201,17 +210,12 @@ [[statusWindow contentView] addSubview:textField]; [[statusWindow contentView] setNeedsDisplay:YES]; - -// [statusWindow setEntryEffect:[[ITPivotWindowEffect alloc] initWithWindow:statusWindow]]; -// [statusWindow setExitEffect:[[ITPivotWindowEffect alloc] initWithWindow:statusWindow]]; - [statusWindow setEntryEffect:[[ITCutWindowEffect alloc] initWithWindow:statusWindow]]; - [statusWindow setExitEffect: [[ITDissolveWindowEffect alloc] initWithWindow:statusWindow]]; } - (IBAction)toggleStatusWindow:(id)sender { - if ( ([statusWindow visibilityState] == ITTransientStatusWindowHiddenState) || - ([statusWindow visibilityState] == ITTransientStatusWindowVanishingState) ) { + if ( ([statusWindow visibilityState] == ITWindowHiddenState) || + ([statusWindow visibilityState] == ITWindowVanishingState) ) { [[statusWindow contentView] setNeedsDisplay:YES]; [statusWindow appear:self]; } else { @@ -221,29 +225,57 @@ - (IBAction)changeWindowSetting:(id)sender { - switch ( [sender tag] ) - { - case 3010: // Not yet supported. - break; - case 3020: // Not yet supported. - break; - case 3030: // Change vanish delay - [statusWindow setExitDelay:[sender floatValue]]; - break; - case 3040: // Change vertical position - [statusWindow setVerticalPosition:[sender indexOfSelectedItem]]; - break; - case 3050: // Change horizontal position - [statusWindow setHorizontalPosition:[sender indexOfSelectedItem]]; - break; - case 3060: // Change effect speed - [[statusWindow entryEffect] setEffectTime:[sender floatValue]]; - [[statusWindow exitEffect] setEffectTime:[sender floatValue]]; - break; - case 3070: // Change entry effect - break; - case 3080: // Change exit effect - break; + if ( [sender tag] == 3010 ) { + + if ( [sender indexOfSelectedItem] == 0) { + [statusWindow setExitMode:ITTransientStatusWindowExitAfterDelay]; + } else if ( [sender indexOfSelectedItem] == 1) { + [statusWindow setExitMode:ITTransientStatusWindowExitOnCommand]; + } + + } else if ( [sender tag] == 3020 ) { + // Not yet supported + } else if ( [sender tag] == 3030 ) { + [statusWindow setExitDelay:[sender floatValue]]; + } else if ( [sender tag] == 3040 ) { + [statusWindow setVerticalPosition:[sender indexOfSelectedItem]]; + } else if ( [sender tag] == 3050 ) { + [statusWindow setHorizontalPosition:[sender indexOfSelectedItem]]; + } else if ( [sender tag] == 3060 ) { + [[statusWindow entryEffect] setEffectTime:[sender floatValue]]; + [[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 entryEffect] setEffectTime:[swSpeedSlider 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 exitEffect] setEffectTime:[swSpeedSlider floatValue]]; + } } diff --git a/Showcase/English.lproj/MainMenu.nib/classes.nib b/Showcase/English.lproj/MainMenu.nib/classes.nib index a953fe1..cd76fd0 100755 --- a/Showcase/English.lproj/MainMenu.nib/classes.nib +++ b/Showcase/English.lproj/MainMenu.nib/classes.nib @@ -26,6 +26,7 @@ swBackgroundTypePopup = NSPopUpButton; swDefinedPositionPopup = NSPopUpButton; swSampleTextView = NSTextView; + swSpeedSlider = NSSlider; swVanishDelay = NSTextField; swVanishModePopup = NSPopUpButton; tabView = ITTabView; diff --git a/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib b/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib index 276577d..dd63502 100755 Binary files a/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib and b/Showcase/English.lproj/MainMenu.nib/keyedobjects.nib differ