FINALLY got CVS working. Fixed another elusive menu bug that hated me.
authorKent Sutherland <ksuther@ithinksw.com>
Fri, 10 Jan 2003 01:11:25 +0000 (01:11 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Fri, 10 Jan 2003 01:11:25 +0000 (01:11 +0000)
Status windows have variable length depending on the amount of text.

English.lproj/StatusWindow.nib/info.nib
English.lproj/StatusWindow.nib/objects.nib
MenuTunes.m
StatusWindowController.h
StatusWindowController.m

index 93c48ef..5363aec 100755 (executable)
@@ -3,12 +3,12 @@
 <plist version="1.0">
 <dict>
        <key>IBFramework Version</key>
-       <string>286.0</string>
+       <string>291.0</string>
        <key>IBOpenObjects</key>
        <array>
                <integer>5</integer>
        </array>
        <key>IBSystem Version</key>
-       <string>6F21</string>
+       <string>6G30</string>
 </dict>
 </plist>
index 6ea0e70..6de9479 100755 (executable)
Binary files a/English.lproj/StatusWindow.nib/objects.nib and b/English.lproj/StatusWindow.nib/objects.nib differ
index b2f6e9e..98748eb 100755 (executable)
@@ -275,16 +275,17 @@ Things to do:
                 if ([defaults boolForKey:@"showName"]) {
                     [menu removeItemAtIndex:index + 1];
                 }
-                if (didHaveAlbumName) {
+                if (didHaveAlbumName && [defaults boolForKey:@"showAlbum"]) {
                     [menu removeItemAtIndex:index + 1];
                 }
-                if (didHaveArtistName) {
+                if (didHaveArtistName && [defaults boolForKey:@"showArtist"]) {
                     [menu removeItemAtIndex:index + 1];
                 }
                 if ([defaults boolForKey:@"showTime"]) {
                     [menu removeItemAtIndex:index + 1];
                 }
             }
+            
             if (!isPlayingRadio) {
                 if ([defaults boolForKey:@"showTime"]) {
                     menuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithFormat:@"  %@", [self runScriptAndReturnResult:@"return time of current track"]]
@@ -350,11 +351,11 @@ Things to do:
         }
         
         if ([defaults boolForKey:@"showArtist"]) {
-            didHaveAlbumName = (([curArtistName length] > 0) ? YES : NO);
+            didHaveArtistName = (([curArtistName length] > 0) ? YES : NO);
         }
             
         if ([defaults boolForKey:@"showAlbum"]) {
-            didHaveArtistName = (([curAlbumName length] > 0) ? YES : NO);
+            didHaveAlbumName = (([curAlbumName length] > 0) ? YES : NO);
         }
     }
 }
@@ -754,7 +755,6 @@ isEqualToString:@"rewinding"]) {
     if (!statusController && [trackName length]) {
         NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
         NSString *stringToShow = @"";
-        int lines = 1;
         
         if ([defaults boolForKey:@"showName"]) {
             if ([defaults boolForKey:@"showArtist"]) {
@@ -763,10 +763,6 @@ isEqualToString:@"rewinding"]) {
             }
             stringToShow = [stringToShow stringByAppendingString:trackName];
             stringToShow = [stringToShow stringByAppendingString:@"\n"];
-            if ([trackName length] > 38) {
-                lines++;
-            }
-            lines++;
         }
         
         if ([defaults boolForKey:@"showAlbum"]) {
@@ -774,7 +770,6 @@ isEqualToString:@"rewinding"]) {
             if ([trackAlbum length]) {
                 stringToShow = [stringToShow stringByAppendingString:trackAlbum];
                 stringToShow = [stringToShow stringByAppendingString:@"\n"];
-                lines++;
             }
         }
         
@@ -782,7 +777,6 @@ isEqualToString:@"rewinding"]) {
             NSString *trackTime = [self runScriptAndReturnResult:@"return time of current track"];
             if ([trackTime length]) {
                 stringToShow = [NSString stringWithFormat:@"%@Total Time: %@\n", stringToShow, trackTime];
-                lines++;
             }
         }
         
@@ -799,7 +793,7 @@ isEqualToString:@"rewinding"]) {
         }
         
         statusController = [[StatusWindowController alloc] init];
-        [statusController setTrackInfo:stringToShow lines:lines];
+        [statusController setTrackInfo:stringToShow];
         [NSTimer scheduledTimerWithTimeInterval:3.0
                                     target:self
                                     selector:@selector(fadeAndCloseStatusWindow)
@@ -828,7 +822,7 @@ isEqualToString:@"rewinding"]) {
                     songs = [songs stringByAppendingString:@"\n"];
                 }
             }
-            [statusController setUpcomingSongs:songs numSongs:numSongsInAdvance];
+            [statusController setUpcomingSongs:songs];
             [NSTimer scheduledTimerWithTimeInterval:3.0
                                              target:self
                                            selector:@selector(fadeAndCloseStatusWindow)
index 826a372..1b32e4a 100755 (executable)
@@ -21,7 +21,7 @@
     IBOutlet NSTextField *statusField;
     IBOutlet StatusWindow *statusWindow;
 }
-- (void)setUpcomingSongs:(NSString *)string numSongs:(int)songs;
-- (void)setTrackInfo:(NSString *)string lines:(int)lines;
+- (void)setUpcomingSongs:(NSString *)string;
+- (void)setTrackInfo:(NSString *)string;
 - (void)fadeWindowOut;
 @end
index c6a2397..d7bd2ff 100755 (executable)
     return self;
 }
 
-- (void)setUpcomingSongs:(NSString *)string numSongs:(int)songs
+- (void)setUpcomingSongs:(NSString *)string
 {
+    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 < 255) {
+        size = 255;
+    }
+    
     [statusField setStringValue:string];
-    [statusWindow setFrame:NSMakeRect(0, 0, 300, 40 + (songs * 17)) display:NO];
+    [statusWindow setFrame:NSMakeRect(0, 0, size + 45, 40 + ([lines count] * 17)) display:NO];
     [statusWindow center];
     [statusWindow makeKeyAndOrderFront:nil];
 }
 
-- (void)setTrackInfo:(NSString *)string lines:(int)lines
+- (void)setTrackInfo:(NSString *)string
 {
+    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, 316, 40 + (lines * 17)) display:NO];
+    [statusWindow setFrame:NSMakeRect(0, 0, size + 45, 40 + ([lines count] * 17)) display:NO];
     [statusWindow center];
     [statusWindow makeKeyAndOrderFront:nil];
 }