Incremental checkin. Updating the StatusWindow and WtatusWindowController objects...
[MenuTunes.git] / StatusWindowController.m
index d7bd2ff..49cbf89 100755 (executable)
+//
+//  StatusWindowController.m
+//  MenuTunes
+//
+//  Created by Matthew L. Judy on Thu Apr 17 2003.
+//  Copyright (c) 2003 NibFile.com. All rights reserved.
+//
+
 #import "StatusWindowController.h"
 #import "StatusWindow.h"
 
+#import <ITKit/ITWindowEffect.h>
+#import <ITKit/ITCutWindowEffect.h>
+#import <ITKit/ITDissolveWindowEffect.h>
+#import <ITKit/ITSlideHorizontallyWindowEffect.h>
+#import <ITKit/ITSlideVerticallyWindowEffect.h>
+#import <ITKit/ITPivotWindowEffect.h>
+
 @implementation StatusWindowController
 
-- (id)init
-{
-    if ( (self = [super init]) ) {
-        [NSBundle loadNibNamed:@"StatusWindow" owner:self];
-        [statusWindow center];
-    }
-    return self;
-}
 
-- (void)setUpcomingSongs:(NSString *)string
+- (id)init
 {
-    int size = 0, i;
-    NSArray *lines = [string componentsSeparatedByString:@"\n"];
+    if ( ( self = [super init] ) ) {
     
-    for (i = 0; i < [lines count]; i++) {
-        int temp = [[lines objectAtIndex:i] sizeWithAttributes:[NSDictionary dictionaryWithObject:[NSFont fontWithName:@"Lucida Grande" size:12] forKey:NSFontAttributeName]].width;
+        float exitDelay;
+        int entryTag;
+        int exitTag;
+        float entrySpeed;
+        float exitSpeed;
         
-        if (temp > size) {
-            size = temp;
+        ITWindowEffect *entryEffect;
+        ITWindowEffect *exitEffect;
+
+        _window = [[StatusWindow sharedWindow] retain];
+        df = [[NSUserDefaults standardUserDefaults] retain];
+
+        exitDelay  = [df floatForKey:@"statusWindowVanishDelay"];
+        entryTag   = [df integerForKey:@"statusWindowAppearanceEffect"];
+        exitTag    = [df integerForKey:@"statusWindowVanishEffect"];
+        entrySpeed = [df floatForKey:@"statusWindowAppearanceSpeed"];
+        exitSpeed  = [df floatForKey:@"statusWindowVanishSpeed"];
+
+        [_window setExitMode:ITTransientStatusWindowExitAfterDelay];
+        [_window setExitDelay:(exitDelay ? exitDelay : 4.0)];
+
+        if ( entryTag == 2101 ) {
+            entryEffect = [[[ITDissolveWindowEffect alloc] initWithWindow:_window] autorelease];
+        } else if ( entryTag == 2102 ) {
+            entryEffect = [[[ITSlideVerticallyWindowEffect alloc] initWithWindow:_window] autorelease];
+        } else if ( entryTag == 2103 ) {
+            entryEffect = [[[ITSlideHorizontallyWindowEffect alloc] initWithWindow:_window] autorelease];
+        } else if ( entryTag == 2104 ) {
+            entryEffect = [[[ITPivotWindowEffect alloc] initWithWindow:_window] autorelease];
+        } else {
+            entryEffect = [[[ITCutWindowEffect alloc] initWithWindow:_window] autorelease];
         }
+
+        [_window setEntryEffect:entryEffect];
+
+        if ( exitTag == 2100 ) {
+            exitEffect = [[[ITCutWindowEffect alloc] initWithWindow:_window] autorelease];
+        } else if ( exitTag == 2102 ) {
+            exitEffect = [[[ITSlideVerticallyWindowEffect alloc] initWithWindow:_window] autorelease];
+        } else if ( exitTag == 2103 ) {
+            exitEffect = [[[ITSlideHorizontallyWindowEffect alloc] initWithWindow:_window] autorelease];
+        } else if ( exitTag == 2104 ) {
+            exitEffect = [[[ITPivotWindowEffect alloc] initWithWindow:_window] autorelease];
+        } else {
+            exitEffect = [[[ITDissolveWindowEffect alloc] initWithWindow:_window] autorelease];
+        }
+
+        [_window setExitEffect:exitEffect];
+
+        [[_window entryEffect] setEffectTime:(entrySpeed ? entrySpeed : 0.8)];
+        [[_window exitEffect]  setEffectTime:(exitSpeed  ? exitSpeed  : 0.8)];
     }
     
-    if (size < 255) {
-        size = 255;
-    }
-    
-    [statusField setStringValue:string];
-    [statusWindow setFrame:NSMakeRect(0, 0, size + 45, 40 + ([lines count] * 17)) display:NO];
-    [statusWindow center];
-    [statusWindow makeKeyAndOrderFront:nil];
+    return self;
 }
 
-- (void)setTrackInfo:(NSString *)string
+- (void)dealloc
 {
-    int size = 0, i;
-    NSArray *lines = [string componentsSeparatedByString:@"\n"];
-    
-    for (i = 0; i < [lines count]; i++) {
-        int temp = [[lines objectAtIndex:i] sizeWithAttributes:[NSDictionary dictionaryWithObject:[NSFont fontWithName:@"Lucida Grande" size:12] forKey:NSFontAttributeName]].width;
-        
-        if (temp > size) {
-            size = temp;
-        }
-    }
-    
-    if (size < 285) {
-        size = 285;
-    }
-    
-    [statusField setStringValue:string];
-    [statusWindow setFrame:NSMakeRect(0, 0, size + 45, 40 + ([lines count] * 17)) display:NO];
-    [statusWindow center];
-    [statusWindow makeKeyAndOrderFront:nil];
+    [_window release];
+    [super dealloc];
 }
 
-- (void)fadeWindowOut
+- (void)showSongInfoWindowWithSource:(ITMTRemotePlayerSource)source
+                               title:            (NSString *)title
+                               album:            (NSString *)album
+                              artist:            (NSString *)artist
+                                time:            (NSString *)time  // FLOW: Should probably be NSDate or something.
+                         trackNumber:                   (int)trackNumber
+                          trackTotal:                      (int)trackTotal
+                              rating:                   (int)rating
 {
-    [NSThread detachNewThreadSelector:@selector(fadeOutAux) toTarget:self withObject:nil];
+    [_window setImage:[NSImage imageNamed:@"Library"]];
+    [_window buildTextWindowWithString:title];
+    [_window appear:self];
 }
 
-- (void)fadeOutAux
+- (void)showUpcomingSongsWindowWithTitles:(NSArray *)titleStrings
 {
-    NSAutoreleasePool *p00l = [[NSAutoreleasePool alloc] init];
-    float i;
-    for (i = 1.0; i > 0; i -= .003) {
-        [statusWindow setAlphaValue:i];
-    }
-    [statusWindow close];
-    [p00l release];
+
+}
+
+- (void)showVolumeWindowWithLevel:(float)level
+{
+    [_window setImage:[NSImage imageNamed:@"Volume"]];
+    [_window buildMeterWindowWithCharacter:[NSString stringWithUTF8String:"▊"]
+                                     count:10
+                                    active:( ceil(level * 100) / 10 )];
+    [_window appear:self];
+}
+
+- (void)showRatingWindowWithRating:(int)rating
+{
+
+}
+
+- (void)showShuffleWindow:(BOOL)shuffle
+{
+
+}
+
+- (void)showRepeatWindowWithMode:(StatusWindowRepeatMode)mode
+{
+
+}
+
+- (void)showSetupQueryWindow
+{
+
 }
 
-@end
+
+@end
\ No newline at end of file