- (void)setupCustomizationTables;
- (void)setupMenuItems;
- (void)setupUI;
+- (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",
{
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) {
- Class selectedClass = [[sender selectedItem] representedObject];
- float time = ([df floatForKey:@"statusWindowAppearanceSpeed"] ? [df floatForKey:@"statusWindowAppearanceSpeed"] : 0.8);
- [df setObject:NSStringFromClass(selectedClass) forKey:@"statusWindowAppearanceEffect"];
-
- [sw setEntryEffect:[[[selectedClass alloc] initWithWindow:sw] autorelease]];
- [[sw entryEffect] setEffectTime:time];
+
+ [self setStatusWindowEntryEffect:[[sender selectedItem] representedObject]];
} else if ( [sender tag] == 2040) {
- Class selectedClass = [[sender selectedItem] representedObject];
- float time = ([df floatForKey:@"statusWindowVanishSpeed"] ? [df floatForKey:@"statusWindowVanishSpeed"] : 0.8);
- [df setObject:NSStringFromClass(selectedClass) forKey:@"statusWindowVanishEffect"];
+
+ [self setStatusWindowExitEffect:[[sender selectedItem] representedObject]];
- [sw setExitEffect:[[[selectedClass 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;
NSEnumerator *keyArrayEnum;
NSString *serverName;
NSData *colorData;
- NSArray *effectClasses = [ITWindowEffect effectClasses];
- NSEnumerator *effectEnum = [effectClasses 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];
-
- while ( (anItem = [effectEnum nextObject]) ) {
- [appearanceEffectPopup addItemWithTitle:[anItem effectName]];
- [vanishEffectPopup addItemWithTitle:[anItem effectName]];
- [[appearanceEffectPopup lastItem] setRepresentedObject:anItem];
- [[vanishEffectPopup lastItem] setRepresentedObject:anItem];
- }
+ [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.
[vanishEffectPopup selectItemAtIndex:[effectClasses indexOfObject:NSClassFromString(@"ITCutWindowEffect")]];
}
- [appearanceSpeedSlider setFloatValue:-([df floatForKey:@"statusWindowAppearanceSpeed"])];
- [vanishSpeedSlider setFloatValue:-([df floatForKey:@"statusWindowVanishSpeed"])];
+ [appearanceSpeedSlider setFloatValue:( -([df floatForKey:@"statusWindowAppearanceSpeed"]) )];
+ [vanishSpeedSlider setFloatValue:( -([df floatForKey:@"statusWindowVanishSpeed"]) )];
[vanishDelaySlider setFloatValue:[df floatForKey:@"statusWindowVanishDelay"]];
// Setup General Controls
}
}
+- (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
{
ITDebugLog(@"Synchronizing menus");
{
[hotKeysArray release];
[hotKeysDictionary release];
+ [effectClasses release];
[menuTableView setDataSource:nil];
[allTableView setDataSource:nil];
[controller release];