]> git.sesse.net Git - vlc/blob - modules/gui/macosx/embeddedwindow.m
e2ff658dc2204266b01a7167eb3056d8b06ea484
[vlc] / modules / gui / macosx / embeddedwindow.m
1 /*****************************************************************************
2  * embeddedwindow.m: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2005-2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Benjamin Pracht <bigben at videolan dot org>
8  *          Felix Paul Kühne <fkuehne at videolan dot org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28
29 #import "intf.h"
30 #import "controls.h"
31 #import "vout.h"
32 #import "embeddedwindow.h"
33 #import "fspanel.h"
34
35 /*****************************************************************************
36  * VLCEmbeddedWindow Implementation
37  *****************************************************************************/
38
39 @implementation VLCEmbeddedWindow
40
41 - (id)initWithContentRect:(NSRect)contentRect styleMask: (NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
42 {
43     BOOL b_useTextured = YES;
44     if( [[NSWindow class] instancesRespondToSelector:@selector(setContentBorderThickness:forEdge:)] )
45     {
46         b_useTextured = NO;
47         windowStyle ^= NSTexturedBackgroundWindowMask;
48     }
49     self = [super initWithContentRect:contentRect styleMask:windowStyle backing:bufferingType defer:deferCreation];
50     if(! b_useTextured )
51     {
52         [self setContentBorderThickness:28.0 forEdge:NSMinYEdge];
53     }
54     return self;
55 }
56
57 - (void)awakeFromNib
58 {
59     [self setDelegate: self];
60
61     [o_btn_backward setToolTip: _NS("Rewind")];
62     [o_btn_forward setToolTip: _NS("Fast Forward")];
63     [o_btn_fullscreen setToolTip: _NS("Fullscreen")];
64     [o_btn_play setToolTip: _NS("Play")];
65     [o_slider setToolTip: _NS("Position")];
66
67     o_img_play = [NSImage imageNamed: @"play_embedded"];
68     o_img_pause = [NSImage imageNamed: @"pause_embedded"];
69     [self controlTintChanged];
70     [[NSNotificationCenter defaultCenter] addObserver: self
71                                              selector: @selector( controlTintChanged )
72                                                  name: NSControlTintDidChangeNotification
73                                                object: nil];
74
75     /* Useful to save o_view frame in fullscreen mode */
76     o_temp_view = [[NSView alloc] init];
77     [o_temp_view setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
78
79     o_fullscreen_window = nil;
80     o_fullscreen_anim1 = o_fullscreen_anim2 = nil;
81
82     /* Not fullscreen when we wake up */
83     [o_btn_fullscreen setState: NO];
84     b_fullscreen = NO;
85
86     [self setMovableByWindowBackground:YES];
87
88     [self setDelegate:self];
89
90     /* Make sure setVisible: returns NO */
91     [self orderOut:self];
92     b_window_is_invisible = YES;
93     videoRatio = NSMakeSize( 0., 0. );
94 }
95
96 - (void)controlTintChanged
97 {
98     BOOL b_playing = NO;
99     if( [o_btn_play alternateImage] == o_img_play_pressed )
100         b_playing = YES;
101     
102     if( [NSColor currentControlTint] == NSGraphiteControlTint )
103     {
104         o_img_play_pressed = [NSImage imageNamed: @"play_embedded_graphite"];
105         o_img_pause_pressed = [NSImage imageNamed: @"pause_embedded_graphite"];
106         [o_btn_backward setAlternateImage: [NSImage imageNamed: @"skip_previous_embedded_graphite"]];
107         [o_btn_forward setAlternateImage: [NSImage imageNamed: @"skip_forward_embedded_graphite"]];
108         [o_btn_fullscreen setAlternateImage: [NSImage imageNamed: @"fullscreen_graphite"]];
109     }
110     else
111     {
112         o_img_play_pressed = [NSImage imageNamed: @"play_embedded_blue"];
113         o_img_pause_pressed = [NSImage imageNamed: @"pause_embedded_blue"];
114         [o_btn_backward setAlternateImage: [NSImage imageNamed: @"skip_previous_embedded_blue"]];
115         [o_btn_forward setAlternateImage: [NSImage imageNamed: @"skip_forward_embedded_blue"]];
116         [o_btn_fullscreen setAlternateImage: [NSImage imageNamed: @"fullscreen_blue"]];
117     }
118     
119     if( b_playing )
120         [o_btn_play setAlternateImage: o_img_play_pressed];
121     else
122         [o_btn_play setAlternateImage: o_img_pause_pressed];
123 }
124
125 - (void)dealloc
126 {
127     [[NSNotificationCenter defaultCenter] removeObserver: self];
128     [o_img_play release];
129     [o_img_play_pressed release];
130     [o_img_pause release];
131     [o_img_pause_pressed release];
132     
133     [super dealloc];
134 }
135
136 - (void)setTime:(NSString *)o_arg_time position:(float)f_position
137 {
138     [o_time setStringValue: o_arg_time];
139     [o_slider setFloatValue: f_position];
140 }
141
142 - (void)playStatusUpdated:(int)i_status
143 {
144     if( i_status == PLAYING_S )
145     {
146         [o_btn_play setImage: o_img_pause];
147         [o_btn_play setAlternateImage: o_img_pause_pressed];
148         [o_btn_play setToolTip: _NS("Pause")];
149     }
150     else
151     {
152         [o_btn_play setImage: o_img_play];
153         [o_btn_play setAlternateImage: o_img_play_pressed];
154         [o_btn_play setToolTip: _NS("Play")];
155     }
156 }
157
158 - (void)setSeekable:(BOOL)b_seekable
159 {
160     [o_btn_forward setEnabled: b_seekable];
161     [o_btn_backward setEnabled: b_seekable];
162     [o_slider setEnabled: b_seekable];
163 }
164
165 - (BOOL)windowShouldZoom:(NSWindow *)sender toFrame:(NSRect)newFrame
166 {
167     [self setFrame: newFrame display: YES animate: YES];
168     return NO;
169 }
170
171 - (BOOL)windowShouldClose:(id)sender
172 {
173     playlist_t * p_playlist = pl_Hold( VLCIntf );
174
175     playlist_Stop( p_playlist );
176     pl_Release( VLCIntf );
177     return YES;
178 }
179
180 - (NSView *)mainView
181 {
182     if (o_fullscreen_window)
183         return o_temp_view;
184     else
185         return o_view;
186 }
187
188 - (void)setVideoRatio:(NSSize)ratio
189 {
190     videoRatio = ratio;
191 }
192
193 - (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
194 {
195     if( videoRatio.height == 0. || videoRatio.width == 0. )
196         return proposedFrameSize;
197
198     NSRect viewRect = [o_view convertRect:[o_view bounds] toView: nil];
199     NSRect contentRect = [self contentRectForFrameRect:[self frame]];
200     float marginy = viewRect.origin.y + [self frame].size.height - contentRect.size.height;
201     float marginx = contentRect.size.width - viewRect.size.width;
202     proposedFrameSize.height = (proposedFrameSize.width - marginx) * videoRatio.height / videoRatio.width + marginy;
203
204     return proposedFrameSize;
205 }
206
207 /*****************************************************************************
208  * Fullscreen support
209  */
210
211 - (BOOL)isFullscreen
212 {
213     return b_fullscreen;
214 }
215
216 - (void)lockFullscreenAnimation
217 {
218     [o_animation_lock lock];
219 }
220
221 - (void)unlockFullscreenAnimation
222 {
223     [o_animation_lock unlock];
224 }
225
226 - (void)enterFullscreen
227 {
228     NSMutableDictionary *dict1, *dict2;
229     NSScreen *screen;
230     NSRect screen_rect;
231     NSRect rect;
232     vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
233     BOOL blackout_other_displays = config_GetInt( VLCIntf, "macosx-black" );
234
235     screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_GetInteger( p_vout, "video-device" )]; 
236  
237     [self lockFullscreenAnimation];
238
239     if (!screen)
240     {
241         msg_Dbg( p_vout, "chosen screen isn't present, using current screen for fullscreen mode" );
242         screen = [self screen];
243     }
244     if (!screen)
245     {
246         msg_Dbg( p_vout, "Using deepest screen" );
247         screen = [NSScreen deepestScreen];
248     }
249
250     vlc_object_release( p_vout );
251
252     screen_rect = [screen frame];
253
254     [o_btn_fullscreen setState: YES];
255
256     [NSCursor setHiddenUntilMouseMoves: YES];
257  
258     if( blackout_other_displays )        
259         [screen blackoutOtherScreens];
260
261     /* Make sure we don't see the window flashes in float-on-top mode */
262     originalLevel = [self level];
263     [self setLevel:NSNormalWindowLevel];
264
265     /* Only create the o_fullscreen_window if we are not in the middle of the zooming animation */
266     if (!o_fullscreen_window)
267     {
268         /* We can't change the styleMask of an already created NSWindow, so we create an other window, and do eye catching stuff */
269
270         rect = [[o_view superview] convertRect: [o_view frame] toView: nil]; /* Convert to Window base coord */
271         rect.origin.x += [self frame].origin.x;
272         rect.origin.y += [self frame].origin.y;
273         o_fullscreen_window = [[VLCWindow alloc] initWithContentRect:rect styleMask: NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
274         [o_fullscreen_window setBackgroundColor: [NSColor blackColor]];
275         [o_fullscreen_window setCanBecomeKeyWindow: YES];
276
277         if (![self isVisible] || [self alphaValue] == 0.0)
278         {
279             /* We don't animate if we are not visible, instead we
280              * simply fade the display */
281             CGDisplayFadeReservationToken token;
282  
283             CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
284             CGDisplayFade( token, 0.5, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES );
285  
286             if ([screen isMainScreen])
287                 [NSMenu setMenuBarVisible:NO];
288  
289             [[self contentView] replaceSubview:o_view with:o_temp_view];
290             [o_temp_view setFrame:[o_view frame]];
291             [o_fullscreen_window setContentView:o_view];
292
293             [o_fullscreen_window makeKeyAndOrderFront:self];
294             [o_fullscreen_window orderFront:self animate:YES];
295
296             [o_fullscreen_window setFrame:screen_rect display:YES];
297
298             CGDisplayFade( token, 0.3, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
299             CGReleaseDisplayFadeReservation( token);
300
301             /* Will release the lock */
302             [self hasBecomeFullscreen];
303
304             return;
305         }
306  
307         /* Make sure we don't see the o_view disappearing of the screen during this operation */
308         NSEnableScreenUpdates();
309                 [[self contentView] replaceSubview:o_view with:o_temp_view];
310         [o_temp_view setFrame:[o_view frame]];
311         [o_fullscreen_window setContentView:o_view];
312         [o_fullscreen_window makeKeyAndOrderFront:self];
313         NSDisableScreenUpdates();
314     }
315
316     /* We are in fullscreen (and no animation is running) */
317     if (b_fullscreen)
318     {
319         /* Make sure we are hidden */
320         [super orderOut: self];
321         [self unlockFullscreenAnimation];
322         return;
323     }
324
325     if (o_fullscreen_anim1)
326     {
327         [o_fullscreen_anim1 stopAnimation];
328         [o_fullscreen_anim1 release];
329     }
330     if (o_fullscreen_anim2)
331     {
332         [o_fullscreen_anim2 stopAnimation];
333         [o_fullscreen_anim2 release];
334     }
335  
336     if ([screen isMainScreen])
337         [NSMenu setMenuBarVisible:NO];
338
339     dict1 = [[NSMutableDictionary alloc] initWithCapacity:2];
340     dict2 = [[NSMutableDictionary alloc] initWithCapacity:3];
341
342     [dict1 setObject:self forKey:NSViewAnimationTargetKey];
343     [dict1 setObject:NSViewAnimationFadeOutEffect forKey:NSViewAnimationEffectKey];
344
345     [dict2 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
346     [dict2 setObject:[NSValue valueWithRect:[o_fullscreen_window frame]] forKey:NSViewAnimationStartFrameKey];
347     [dict2 setObject:[NSValue valueWithRect:screen_rect] forKey:NSViewAnimationEndFrameKey];
348
349     /* Strategy with NSAnimation allocation:
350         - Keep at most 2 animation at a time
351         - leaveFullscreen/enterFullscreen are the only responsible for releasing and alloc-ing
352     */
353     o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict1, nil]];
354     o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict2, nil]];
355
356     [dict1 release];
357     [dict2 release];
358
359     [o_fullscreen_anim1 setAnimationBlockingMode: NSAnimationNonblocking];
360     [o_fullscreen_anim1 setDuration: 0.3];
361     [o_fullscreen_anim1 setFrameRate: 30];
362     [o_fullscreen_anim2 setAnimationBlockingMode: NSAnimationNonblocking];
363     [o_fullscreen_anim2 setDuration: 0.2];
364     [o_fullscreen_anim2 setFrameRate: 30];
365
366     [o_fullscreen_anim2 setDelegate: self];
367     [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
368
369     [o_fullscreen_anim1 startAnimation];
370     /* fullscreenAnimation will be unlocked when animation ends */
371 }
372
373 - (void)hasBecomeFullscreen
374 {
375     [o_fullscreen_window makeFirstResponder: [[[VLCMain sharedInstance] controls] voutView]];
376
377     [o_fullscreen_window makeKeyWindow];
378     [o_fullscreen_window setAcceptsMouseMovedEvents: TRUE];
379
380     /* tell the fspanel to move itself to front next time it's triggered */
381     [[[[VLCMain sharedInstance] controls] fspanel] setVoutWasUpdated: (int)[[o_fullscreen_window screen] displayID]];
382
383     if([self isVisible])
384         [super orderOut: self];
385
386     [[[[VLCMain sharedInstance] controls] fspanel] setActive: nil];
387
388     b_fullscreen = YES;
389     [self unlockFullscreenAnimation];
390 }
391
392 - (void)leaveFullscreen
393 {
394     [self leaveFullscreenAndFadeOut: NO];
395 }
396
397 - (void)leaveFullscreenAndFadeOut: (BOOL)fadeout
398 {
399     NSMutableDictionary *dict1, *dict2;
400     NSRect frame;
401
402     [self lockFullscreenAnimation];
403
404     b_fullscreen = NO;
405     [o_btn_fullscreen setState: NO];
406
407     /* We always try to do so */
408     [NSScreen unblackoutScreens];
409
410     /* Don't do anything if o_fullscreen_window is already closed */
411     if (!o_fullscreen_window)
412     {
413         [self unlockFullscreenAnimation];
414         return;
415     }
416
417     if (fadeout)
418     {
419         /* We don't animate if we are not visible, instead we
420         * simply fade the display */
421         CGDisplayFadeReservationToken token;
422
423         CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
424         CGDisplayFade( token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES );
425
426         [[[[VLCMain sharedInstance] controls] fspanel] setNonActive: nil];
427         [NSMenu setMenuBarVisible:YES];
428
429         /* Will release the lock */
430         [self hasEndedFullscreen];
431
432         /* Our window is hidden, and might be faded. We need to workaround that, so note it
433          * here */
434         b_window_is_invisible = YES;
435
436         CGDisplayFade( token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
437         CGReleaseDisplayFadeReservation( token);
438         return;
439     }
440
441     [self setAlphaValue: 0.0];
442     [self orderFront: self];
443
444     [[[[VLCMain sharedInstance] controls] fspanel] setNonActive: nil];
445     [NSMenu setMenuBarVisible:YES];
446
447     if (o_fullscreen_anim1)
448     {
449         [o_fullscreen_anim1 stopAnimation];
450         [o_fullscreen_anim1 release];
451     }
452     if (o_fullscreen_anim2)
453     {
454         [o_fullscreen_anim2 stopAnimation];
455         [o_fullscreen_anim2 release];
456     }
457
458     frame = [[o_temp_view superview] convertRect: [o_temp_view frame] toView: nil]; /* Convert to Window base coord */
459     frame.origin.x += [self frame].origin.x;
460     frame.origin.y += [self frame].origin.y;
461
462     dict2 = [[NSMutableDictionary alloc] initWithCapacity:2];
463     [dict2 setObject:self forKey:NSViewAnimationTargetKey];
464     [dict2 setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
465
466     o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict2, nil]];
467     [dict2 release];
468
469     [o_fullscreen_anim2 setAnimationBlockingMode: NSAnimationNonblocking];
470     [o_fullscreen_anim2 setDuration: 0.3];
471     [o_fullscreen_anim2 setFrameRate: 30];
472
473     [o_fullscreen_anim2 setDelegate: self];
474
475     dict1 = [[NSMutableDictionary alloc] initWithCapacity:3];
476
477     [dict1 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
478     [dict1 setObject:[NSValue valueWithRect:[o_fullscreen_window frame]] forKey:NSViewAnimationStartFrameKey];
479     [dict1 setObject:[NSValue valueWithRect:frame] forKey:NSViewAnimationEndFrameKey];
480
481     o_fullscreen_anim1 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict1, nil]];
482     [dict1 release];
483
484     [o_fullscreen_anim1 setAnimationBlockingMode: NSAnimationNonblocking];
485     [o_fullscreen_anim1 setDuration: 0.2];
486     [o_fullscreen_anim1 setFrameRate: 30];
487     [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
488
489     /* Make sure o_fullscreen_window is the frontmost window */
490     [o_fullscreen_window orderFront: self];
491
492     [o_fullscreen_anim1 startAnimation];
493     /* fullscreenAnimation will be unlocked when animation ends */
494 }
495
496 - (void)hasEndedFullscreen
497 {
498     /* This function is private and should be only triggered at the end of the fullscreen change animation */
499     /* Make sure we don't see the o_view disappearing of the screen during this operation */
500     NSDisableScreenUpdates();
501     [o_view retain];
502     [o_view removeFromSuperviewWithoutNeedingDisplay];
503     [[self contentView] replaceSubview:o_temp_view with:o_view];
504     [o_view release];
505     [o_view setFrame:[o_temp_view frame]];
506     [self makeFirstResponder: o_view];
507     if ([self isVisible])
508         [super makeKeyAndOrderFront:self]; /* our version contains a workaround */
509     [o_fullscreen_window orderOut: self];
510     NSEnableScreenUpdates();
511
512     [o_fullscreen_window release];
513     o_fullscreen_window = nil;
514     [self setLevel:originalLevel];
515
516     [self unlockFullscreenAnimation];
517 }
518
519 - (void)animationDidEnd:(NSAnimation*)animation
520 {
521     NSArray *viewAnimations;
522
523     if ([animation currentValue] < 1.0)
524         return;
525
526     /* Fullscreen ended or started (we are a delegate only for leaveFullscreen's/enterFullscren's anim2) */
527     viewAnimations = [o_fullscreen_anim2 viewAnimations];
528     if ([viewAnimations count] >=1 &&
529         [[[viewAnimations objectAtIndex: 0] objectForKey: NSViewAnimationEffectKey] isEqualToString:NSViewAnimationFadeInEffect])
530     {
531         /* Fullscreen ended */
532         [self hasEndedFullscreen];
533     }
534     else
535     {
536         /* Fullscreen started */
537         [self hasBecomeFullscreen];
538     }
539 }
540
541 - (void)orderOut: (id)sender
542 {
543     [super orderOut: sender];
544
545     /* Make sure we leave fullscreen */
546     [self leaveFullscreenAndFadeOut: YES];
547 }
548
549 - (void)makeKeyAndOrderFront: (id)sender
550 {
551     /* Hack
552      * when we exit fullscreen and fade out, we may endup in
553      * having a window that is faded. We can't have it fade in unless we
554      * animate again. */
555
556     if(!b_window_is_invisible)
557     {
558         /* Make sure we don't do it too much */
559         [super makeKeyAndOrderFront: sender];
560         return;
561     }
562
563     [super setAlphaValue:0.0f];
564     [super makeKeyAndOrderFront: sender];
565
566     NSMutableDictionary * dict = [[[NSMutableDictionary alloc] initWithCapacity:2] autorelease];
567     [dict setObject:self forKey:NSViewAnimationTargetKey];
568     [dict setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
569
570     NSViewAnimation * anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict]];
571
572     [anim setAnimationBlockingMode: NSAnimationNonblocking];
573     [anim setDuration: 0.1];
574     [anim setFrameRate: 30];
575
576     [anim startAnimation];
577     b_window_is_invisible = NO;
578
579     /* fullscreenAnimation will be unlocked when animation ends */
580 }
581
582
583
584 /* Make sure setFrame gets executed on main thread especially if we are animating.
585  * (Thus we won't block the video output thread) */
586 - (void)setFrame:(NSRect)frame display:(BOOL)display animate:(BOOL)animate
587 {
588     struct { NSRect frame; BOOL display; BOOL animate;} args;
589     NSData *packedargs;
590
591     args.frame = frame;
592     args.display = display;
593     args.animate = animate;
594
595     packedargs = [NSData dataWithBytes:&args length:sizeof(args)];
596
597     [self performSelectorOnMainThread:@selector(setFrameOnMainThread:)
598                     withObject: packedargs waitUntilDone: YES];
599 }
600
601 - (void)setFrameOnMainThread:(NSData*)packedargs
602 {
603     struct args { NSRect frame; BOOL display; BOOL animate; } * args = (struct args*)[packedargs bytes];
604
605     if( args->animate )
606     {
607         /* Make sure we don't block too long and set up a non blocking animation */
608         NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys:
609             self, NSViewAnimationTargetKey,
610             [NSValue valueWithRect:[self frame]], NSViewAnimationStartFrameKey,
611             [NSValue valueWithRect:args->frame], NSViewAnimationEndFrameKey, nil];
612
613         NSViewAnimation * anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict, nil]];
614
615         [anim setAnimationBlockingMode: NSAnimationNonblocking];
616         [anim setDuration: 0.4];
617         [anim setFrameRate: 30];
618         [anim startAnimation];
619     }
620     else {
621         [super setFrame:args->frame display:args->display animate:args->animate];
622     }
623
624 }
625 @end