+ [self orderOut: self animate: YES callback: invoc];
+}
+
+- (void)orderOut: (id)sender animate: (BOOL)animate
+{
+ NSInvocation *invoc = [NSInvocation invocationWithMethodSignature:[super methodSignatureForSelector:@selector(orderOut:)]];
+ [invoc setTarget: (id)super];
+ [invoc setArgument: sender atIndex: 0];
+ [self orderOut: sender animate: animate callback: invoc];
+}
+
+- (void)orderOut: (id)sender animate: (BOOL)animate callback:(NSInvocation *)callback
+{
+ NSViewAnimation *anim;
+ NSViewAnimation *current_anim;
+ NSMutableDictionary *dict;
+
+ if (!animate || MACOS_VERSION < 10.4f)
+ {
+ [self orderOut: sender];
+ return;
+ }
+
+ dict = [[NSMutableDictionary alloc] initWithCapacity:2];
+
+ [dict setObject:self forKey:NSViewAnimationTargetKey];
+
+ [dict setObject:NSViewAnimationFadeOutEffect forKey:NSViewAnimationEffectKey];
+ anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict, nil]];
+ [dict release];
+
+ [anim setAnimationBlockingMode:NSAnimationNonblocking];
+ [anim setDuration:0.9];
+ [anim setFrameRate:30];
+ [anim setUserInfo: callback];
+
+ @synchronized(self) {
+ current_anim = self->animation;
+
+ if ([[[current_anim viewAnimations] objectAtIndex:0] objectForKey: NSViewAnimationEffectKey] == NSViewAnimationFadeOutEffect && [current_anim isAnimating])
+ {
+ [anim release];
+ }
+ else
+ {
+ if (current_anim)
+ {
+ [current_anim stopAnimation];
+ [anim setCurrentProgress:1.0-[current_anim currentProgress]];
+ [current_anim release];
+ }
+ else
+ [anim setCurrentProgress:1.0 - [self alphaValue]];
+ self->animation = anim;
+ [self setDelegate: self];
+ [anim startAnimation];
+ }
+ }
+}
+
+- (void)orderFront: (id)sender animate: (BOOL)animate
+{
+ NSViewAnimation *anim;
+ NSViewAnimation *current_anim;
+ NSMutableDictionary *dict;
+
+ if (!animate || MACOS_VERSION < 10.4f)
+ {
+ [super orderFront: sender];
+ [self setAlphaValue: 1.0];
+ return;
+ }
+
+ if (![self isVisible])
+ {
+ [self setAlphaValue: 0.0];
+ [super orderFront: sender];
+ }
+ else if ([self alphaValue] == 1.0)
+ {
+ [super orderFront: self];
+ return;
+ }
+
+ dict = [[NSMutableDictionary alloc] initWithCapacity:2];
+
+ [dict setObject:self forKey:NSViewAnimationTargetKey];
+
+ [dict setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
+ anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict, nil]];
+ [dict release];
+
+ [anim setAnimationBlockingMode:NSAnimationNonblocking];
+ [anim setDuration:0.5];
+ [anim setFrameRate:30];
+
+ @synchronized(self) {
+ current_anim = self->animation;
+
+ if ([[[current_anim viewAnimations] objectAtIndex:0] objectForKey: NSViewAnimationEffectKey] == NSViewAnimationFadeInEffect && [current_anim isAnimating])
+ {
+ [anim release];
+ }
+ else
+ {
+ if (current_anim)
+ {
+ [current_anim stopAnimation];
+ [anim setCurrentProgress:1.0 - [current_anim currentProgress]];
+ [current_anim release];
+ }
+ else
+ [anim setCurrentProgress:[self alphaValue]];
+ self->animation = anim;
+ [self setDelegate: self];
+ [self orderFront: sender];
+ [anim startAnimation];
+ }
+ }
+}
+
+- (void)animationDidEnd:(NSAnimation*)anim
+{
+ if ([self alphaValue] <= 0.0)
+ {
+ NSInvocation * invoc;
+ [super orderOut: nil];
+ [self setAlphaValue: 1.0];
+ if ((invoc = [anim userInfo]))
+ [invoc invoke];
+ }
+}
+@end
+
+/*****************************************************************************
+ * VLCControllerWindow
+ *****************************************************************************/
+
+@implementation VLCControllerWindow
+
+- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask
+ backing:(NSBackingStoreType)backingType defer:(BOOL)flag
+{
+ self = [super initWithContentRect:contentRect styleMask:styleMask //& ~NSTitledWindowMask
+ backing:backingType defer:flag];
+
+ [[VLCMain sharedInstance] updateTogglePlaylistState];
+