- (void)setupCustomizationTables;
- (void)setupMenuItems;
- (void)setupUI;
-- (NSArray *)effectNamesFromDictionary:(NSDictionary *)infoDict;
+- (void)setStatusWindowEntryEffect:(Class)effectClass;
+- (void)setStatusWindowExitEffect:(Class)effectClass;
- (void)setCustomColor:(NSColor *)color updateWell:(BOOL)update;
+- (void)repopulateEffectPopupsForVerticalPosition:(ITVerticalWindowPosition)vPos horizontalPosition:(ITHorizontalWindowPosition)hPos;
+- (BOOL)effect:(Class)effectClass supportsVerticalPosition:(ITVerticalWindowPosition)vPos withHorizontalPosition:(ITHorizontalWindowPosition)hPos;
- (IBAction)changeMenus:(id)sender;
- (void)setLaunchesAtLogin:(BOOL)flag;
@end
if ( (self = [super init]) ) {
ITDebugLog(@"Preferences initialized.");
df = [[NSUserDefaults standardUserDefaults] retain];
+
+ effectClasses = [[ITWindowEffect effectClasses] retain];
+
hotKeysArray = [[NSArray alloc] initWithObjects:@"PlayPause",
@"NextTrack",
@"PrevTrack",
NS_ENDHANDLER
}
+ [self resetRemotePlayerTextFields];
[window center];
[NSApp activateIgnoringOtherApps:YES];
[window performSelector:@selector(makeKeyAndOrderFront:) withObject:self afterDelay:0.0];
[controller setServerStatus:state]; //Set server status
} else if ( [sender tag] == 5015 ) {
[df setObject:[sender stringValue] forKey:@"sharedPlayerName"];
+ [[NetworkController sharedController] resetServerName];
} else if ( [sender tag] == 5020 ) {
[df setBool:SENDER_STATE forKey:@"enableSharingPassword"];
} else if ( [sender tag] == 5030 ) {
{
StatusWindow *sw = [StatusWindow sharedWindow];
ITDebugLog(@"Changing status window setting of tag %i", [sender tag]);
+
if ( [sender tag] == 2010) {
+
+ BOOL entryEffectValid = YES;
+ BOOL exitEffectValid = YES;
+
[df setInteger:[sender selectedRow] forKey:@"statusWindowVerticalPosition"];
[df setInteger:[sender selectedColumn] forKey:@"statusWindowHorizontalPosition"];
- [sw setHorizontalPosition:[sender selectedColumn]];
[sw setVerticalPosition:[sender selectedRow]];
- // update the window's position here
+ [sw setHorizontalPosition:[sender selectedColumn]];
+
+ // Enable/disable the items in the popups.
+ [self repopulateEffectPopupsForVerticalPosition:[sw verticalPosition]
+ horizontalPosition:[sw horizontalPosition]];
+
+ // Make sure the effects support the new position.
+ entryEffectValid = ( [self effect:[[sw entryEffect] class]
+ supportsVerticalPosition:[sw verticalPosition]
+ withHorizontalPosition:[sw horizontalPosition]] );
+ exitEffectValid = ( [self effect:[[sw exitEffect] class]
+ supportsVerticalPosition:[sw verticalPosition]
+ withHorizontalPosition:[sw horizontalPosition]] );
+
+ if ( ! entryEffectValid ) {
+ [appearanceEffectPopup selectItemAtIndex:[[appearanceEffectPopup menu] indexOfItemWithRepresentedObject:NSClassFromString(@"ITCutWindowEffect")]];
+ [self setStatusWindowEntryEffect:NSClassFromString(@"ITCutWindowEffect")];
+ } else {
+ [appearanceEffectPopup selectItemAtIndex:[[appearanceEffectPopup menu] indexOfItemWithRepresentedObject:[[sw entryEffect] class]]];
+ }
+
+ if ( ! exitEffectValid ) {
+ [vanishEffectPopup selectItemAtIndex:[[vanishEffectPopup menu] indexOfItemWithRepresentedObject:NSClassFromString(@"ITDissolveWindowEffect")]];
+ [self setStatusWindowExitEffect:NSClassFromString(@"ITDissolveWindowEffect")];
+ } else {
+ [vanishEffectPopup selectItemAtIndex:[[vanishEffectPopup menu] indexOfItemWithRepresentedObject:[[sw exitEffect] class]]];
+ }
+
+ [(MainController *)controller showCurrentTrackInfo];
+
} else if ( [sender tag] == 2020) {
- // update screen selection
+
+ // Update screen selection.
+
} else if ( [sender tag] == 2030) {
- int effectTag = [[sender selectedItem] tag];
- float time = ([df floatForKey:@"statusWindowAppearanceSpeed"] ? [df floatForKey:@"statusWindowAppearanceSpeed"] : 0.8);
- [df setInteger:effectTag forKey:@"statusWindowAppearanceEffect"];
-
- if ( effectTag == 2100 ) {
- [sw setEntryEffect:[[[ITCutWindowEffect alloc] initWithWindow:sw] autorelease]];
- } else if ( effectTag == 2101 ) {
- [sw setEntryEffect:[[[ITDissolveWindowEffect alloc] initWithWindow:sw] autorelease]];
- } else if ( effectTag == 2102 ) {
- [sw setEntryEffect:[[[ITSlideVerticallyWindowEffect alloc] initWithWindow:sw] autorelease]];
- } else if ( effectTag == 2103 ) {
- [sw setEntryEffect:[[[ITSlideHorizontallyWindowEffect alloc] initWithWindow:sw] autorelease]];
- } else if ( effectTag == 2104 ) {
- [sw setEntryEffect:[[[ITPivotWindowEffect alloc] initWithWindow:sw] autorelease]];
- }
-
- [[sw entryEffect] setEffectTime:time];
+
+ [self setStatusWindowEntryEffect:[[sender selectedItem] representedObject]];
} else if ( [sender tag] == 2040) {
- int effectTag = [[sender selectedItem] tag];
- float time = ([df floatForKey:@"statusWindowVanishSpeed"] ? [df floatForKey:@"statusWindowVanishSpeed"] : 0.8);
-
- [df setInteger:[[sender selectedItem] tag] forKey:@"statusWindowVanishEffect"];
+
+ [self setStatusWindowExitEffect:[[sender selectedItem] representedObject]];
- if ( effectTag == 2100 ) {
- [sw setExitEffect:[[[ITCutWindowEffect alloc] initWithWindow:sw] autorelease]];
- } else if ( effectTag == 2101 ) {
- [sw setExitEffect:[[[ITDissolveWindowEffect alloc] initWithWindow:sw] autorelease]];
- } else if ( effectTag == 2102 ) {
- [sw setExitEffect:[[[ITSlideVerticallyWindowEffect alloc] initWithWindow:sw] autorelease]];
- } else if ( effectTag == 2103 ) {
- [sw setExitEffect:[[[ITSlideHorizontallyWindowEffect alloc] initWithWindow:sw] autorelease]];
- } else if ( effectTag == 2104 ) {
- [sw setExitEffect:[[[ITPivotWindowEffect alloc] initWithWindow:sw] autorelease]];
- }
-
- [[sw exitEffect] setEffectTime:time];
-
} else if ( [sender tag] == 2050) {
- float newTime = (-([sender floatValue]));
+ float newTime = ( -([sender floatValue]) );
[df setFloat:newTime forKey:@"statusWindowAppearanceSpeed"];
[[sw entryEffect] setEffectTime:newTime];
} else if ( [sender tag] == 2060) {
- float newTime = (-([sender floatValue]));
+ float newTime = ( -([sender floatValue]) );
[df setFloat:newTime forKey:@"statusWindowVanishSpeed"];
[[sw exitEffect] setEffectTime:newTime];
} else if ( [sender tag] == 2070) {
}
} else if ( [sender tag] == 2095) {
- [sw vanish:self];
[df setInteger:[sender indexOfSelectedItem] forKey:@"statusWindowSizing"];
+ [(MainController *)controller showCurrentTrackInfo];
}
[df synchronize];
}
-- (void)setCustomColor:(NSColor *)color updateWell:(BOOL)update
-{
- [(ITTSWBackgroundView *)[[StatusWindow sharedWindow] contentView] setBackgroundColor:color];
- [df setObject:[NSArchiver archivedDataWithRootObject:color] forKey:@"statusWindowBackgroundColor"];
-
- if ( update ) {
- [backgroundColorWell setColor:color];
- }
-}
-
- (void)registerDefaults
{
BOOL found = NO;
- (void)setupUI
{
NSMutableDictionary *loginwindow;
- NSMutableArray *loginarray;
+ NSMutableArray *loginarray;
NSEnumerator *loginEnum;
NSEnumerator *keyArrayEnum;
NSString *serverName;
NSData *colorData;
- NSArray *effectClasses = [ITWindowEffect effectClasses];
-// NSEnumerator *effectEnum = [effectList objectEnumerator];
int selectedBGStyle;
id anItem;
[launchPlayerAtLaunchCheckbox setState:[df boolForKey:@"LaunchPlayerWithMT"] ? NSOnState : NSOffState];
// Setup the positioning controls
+ [positionMatrix selectCellAtRow:[df integerForKey:@"statusWindowVerticalPosition"]
+ column:[df integerForKey:@"statusWindowHorizontalPosition"]];
// Setup effects controls
// Populate the effects popups
- [appearanceEffectPopup removeItemAtIndex:0];
- [vanishEffectPopup removeItemAtIndex:0];
- [appearanceEffectPopup addItemsWithTitles:[[effectList allValues] objectsForKey:@"Name"]]; // category method
- [vanishEffectPopup addItemsWithTitles:[[effectList allValues] objectsForKey:@"Name"]]; // category method
+ [appearanceEffectPopup setAutoenablesItems:NO];
+ [vanishEffectPopup setAutoenablesItems:NO];
+ [self repopulateEffectPopupsForVerticalPosition:[df integerForKey:@"statusWindowVerticalPosition"]
+ horizontalPosition:[df integerForKey:@"statusWindowHorizontalPosition"]];
// Attempt to find the pref'd effect in the list.
// If it's not there, use cut/dissolve.
-
+ if ( [effectClasses containsObject:NSClassFromString([df stringForKey:@"statusWindowAppearanceEffect"])] ) {
+ [appearanceEffectPopup selectItemAtIndex:[effectClasses indexOfObject:NSClassFromString([df stringForKey:@"statusWindowAppearanceEffect"])]];
+ } else {
+ [appearanceEffectPopup selectItemAtIndex:[effectClasses indexOfObject:NSClassFromString(@"ITCutWindowEffect")]];
+ }
- [appearanceEffectPopup selectItem:[appearanceEffectPopup itemAtIndex:[appearanceEffectPopup indexOfItemWithTag:[df integerForKey:@"statusWindowAppearanceEffect"]]]];
- [vanishEffectPopup selectItem:[vanishEffectPopup itemAtIndex:[vanishEffectPopup indexOfItemWithTag:[df integerForKey:@"statusWindowVanishEffect"]]]];
- [appearanceSpeedSlider setFloatValue:-([df floatForKey:@"statusWindowAppearanceSpeed"])];
- [vanishSpeedSlider setFloatValue:-([df floatForKey:@"statusWindowVanishSpeed"])];
+ if ( [effectClasses containsObject:NSClassFromString([df stringForKey:@"statusWindowVanishEffect"])] ) {
+ [vanishEffectPopup selectItemAtIndex:[effectClasses indexOfObject:NSClassFromString([df stringForKey:@"statusWindowVanishEffect"])]];
+ } else {
+ [vanishEffectPopup selectItemAtIndex:[effectClasses indexOfObject:NSClassFromString(@"ITCutWindowEffect")]];
+ }
+
+ [appearanceSpeedSlider setFloatValue:( -([df floatForKey:@"statusWindowAppearanceSpeed"]) )];
+ [vanishSpeedSlider setFloatValue:( -([df floatForKey:@"statusWindowVanishSpeed"]) )];
[vanishDelaySlider setFloatValue:[df floatForKey:@"statusWindowVanishDelay"]];
// Setup General Controls
}
}
-- (NSArray *)effectNamesFromDictionary:(NSDictionary *)infoDict
+- (void)setStatusWindowEntryEffect:(Class)effectClass
+{
+ StatusWindow *sw = [StatusWindow sharedWindow];
+
+ float time = ([df floatForKey:@"statusWindowAppearanceSpeed"] ? [df floatForKey:@"statusWindowAppearanceSpeed"] : 0.8);
+ [df setObject:NSStringFromClass(effectClass) forKey:@"statusWindowAppearanceEffect"];
+
+ [sw setEntryEffect:[[[effectClass alloc] initWithWindow:sw] autorelease]];
+ [[sw entryEffect] setEffectTime:time];
+}
+
+- (void)setStatusWindowExitEffect:(Class)effectClass
+{
+ StatusWindow *sw = [StatusWindow sharedWindow];
+
+ float time = ([df floatForKey:@"statusWindowVanishSpeed"] ? [df floatForKey:@"statusWindowVanishSpeed"] : 0.8);
+ [df setObject:NSStringFromClass(effectClass) forKey:@"statusWindowVanishEffect"];
+
+ [sw setExitEffect:[[[effectClass alloc] initWithWindow:sw] autorelease]];
+ [[sw exitEffect] setEffectTime:time];
+}
+
+- (void)setCustomColor:(NSColor *)color updateWell:(BOOL)update
+{
+ [(ITTSWBackgroundView *)[[StatusWindow sharedWindow] contentView] setBackgroundColor:color];
+ [df setObject:[NSArchiver archivedDataWithRootObject:color] forKey:@"statusWindowBackgroundColor"];
+
+ if ( update ) {
+ [backgroundColorWell setColor:color];
+ }
+}
+
+- (void)repopulateEffectPopupsForVerticalPosition:(ITVerticalWindowPosition)vPos horizontalPosition:(ITHorizontalWindowPosition)hPos
+{
+ NSEnumerator *effectEnum = [effectClasses objectEnumerator];
+ id anItem;
+
+ [appearanceEffectPopup removeAllItems];
+ [vanishEffectPopup removeAllItems];
+
+ while ( (anItem = [effectEnum nextObject]) ) {
+ [appearanceEffectPopup addItemWithTitle:[anItem effectName]];
+ [vanishEffectPopup addItemWithTitle:[anItem effectName]];
+
+ [[appearanceEffectPopup lastItem] setRepresentedObject:anItem];
+ [[vanishEffectPopup lastItem] setRepresentedObject:anItem];
+
+ if ( [self effect:anItem supportsVerticalPosition:vPos withHorizontalPosition:hPos] ) {
+ [[appearanceEffectPopup lastItem] setEnabled:YES];
+ [[vanishEffectPopup lastItem] setEnabled:YES];
+ } else {
+ [[appearanceEffectPopup lastItem] setEnabled:NO];
+ [[vanishEffectPopup lastItem] setEnabled:NO];
+ }
+ }
+
+}
+
+- (BOOL)effect:(Class)effectClass supportsVerticalPosition:(ITVerticalWindowPosition)vPos withHorizontalPosition:(ITHorizontalWindowPosition)hPos
{
+ BOOL valid = NO;
+
+ if ( vPos == ITWindowPositionTop ) {
+ if ( hPos == ITWindowPositionLeft ) {
+ valid = ( [[[[effectClass supportedPositions] objectForKey:@"Top"] objectForKey:@"Left"] boolValue] ) ;
+ } else if ( hPos == ITWindowPositionCenter ) {
+ valid = ( [[[[effectClass supportedPositions] objectForKey:@"Top"] objectForKey:@"Center"] boolValue] );
+ } else if ( hPos == ITWindowPositionRight ) {
+ valid = ( [[[[effectClass supportedPositions] objectForKey:@"Top"] objectForKey:@"Right"] boolValue] );
+ }
+ } else if ( vPos == ITWindowPositionMiddle ) {
+ if ( hPos == ITWindowPositionLeft ) {
+ valid = ( [[[[effectClass supportedPositions] objectForKey:@"Middle"] objectForKey:@"Left"] boolValue] );
+ } else if ( hPos == ITWindowPositionCenter ) {
+ valid = ( [[[[effectClass supportedPositions] objectForKey:@"Middle"] objectForKey:@"Center"] boolValue] );
+ } else if ( hPos == ITWindowPositionRight ) {
+ valid = ( [[[[effectClass supportedPositions] objectForKey:@"Middle"] objectForKey:@"Right"] boolValue] );
+ }
+ } else if ( vPos == ITWindowPositionBottom ) {
+ if ( hPos == ITWindowPositionLeft ) {
+ valid = ( [[[[effectClass supportedPositions] objectForKey:@"Bottom"] objectForKey:@"Left"] boolValue] );
+ } else if ( hPos == ITWindowPositionCenter ) {
+ valid = ( [[[[effectClass supportedPositions] objectForKey:@"Bottom"] objectForKey:@"Center"] boolValue] );
+ } else if ( hPos == ITWindowPositionRight ) {
+ valid = ( [[[[effectClass supportedPositions] objectForKey:@"Bottom"] objectForKey:@"Right"] boolValue] );
+ }
+ }
+ return valid;
}
- (IBAction)changeMenus:(id)sender
{
[hotKeysArray release];
[hotKeysDictionary release];
+ [effectClasses release];
[menuTableView setDataSource:nil];
[allTableView setDataSource:nil];
[controller release];