]> git.sesse.net Git - vlc/blob - modules/gui/macosx/fspanel.m
fix play / pause and rename method for better clarity
[vlc] / modules / gui / macosx / fspanel.m
1 /*****************************************************************************
2  * fspanel.m: MacOS X full screen panel
3  *****************************************************************************
4  * Copyright (C) 2006-2013 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Jérôme Decoodt <djc at videolan dot org>
8  *          Felix Paul Kühne <fkuehne at videolan dot org>
9  *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 /*****************************************************************************
27  * Preamble
28  *****************************************************************************/
29 #import "intf.h"
30 #import "CoreInteraction.h"
31 #import "MainWindow.h"
32 #import "misc.h"
33 #import "fspanel.h"
34 #import "CompatibilityFixes.h"
35
36 @interface VLCFSPanel ()
37 - (void)hideMouse;
38 @end
39
40 /*****************************************************************************
41  * VLCFSPanel
42  *****************************************************************************/
43 @implementation VLCFSPanel
44 /* We override this initializer so we can set the NSBorderlessWindowMask styleMask, and set a few other important settings */
45 - (id)initWithContentRect:(NSRect)contentRect
46                 styleMask:(NSUInteger)aStyle
47                   backing:(NSBackingStoreType)bufferingType
48                     defer:(BOOL)flag
49 {
50     id win = [super initWithContentRect:contentRect styleMask:NSTexturedBackgroundWindowMask backing:bufferingType defer:flag];
51     [win setOpaque:NO];
52     [win setHasShadow: NO];
53     [win setBackgroundColor:[NSColor clearColor]];
54     if (!OSX_SNOW_LEOPARD)
55         [win setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
56
57     /* let the window sit on top of everything else and start out completely transparent */
58     [win setLevel:NSModalPanelWindowLevel];
59     i_device = 0;
60     hideAgainTimer = fadeTimer = nil;
61     [self setNonActive:nil];
62     return win;
63 }
64
65 - (void)awakeFromNib
66 {
67     [self setContentView:[[VLCFSPanelView alloc] initWithFrame: [self frame]]];
68     BOOL isInside = (NSPointInRect([NSEvent mouseLocation],[self frame]));
69     [[self contentView] addTrackingRect:[[self contentView] bounds] owner:self userData:nil assumeInside:isInside];
70     if (isInside)
71         [self mouseEntered:NULL];
72     if (!isInside)
73         [self mouseExited:NULL];
74
75     [self center];
76
77     /* get a notification if VLC isn't the active app anymore */
78     [[NSNotificationCenter defaultCenter]
79     addObserver: self
80        selector: @selector(setNonActive:)
81            name: NSApplicationDidResignActiveNotification
82          object: NSApp];
83
84     /* get a notification if VLC is the active app again */
85     [[NSNotificationCenter defaultCenter]
86     addObserver: self
87        selector: @selector(setActive:)
88            name: NSApplicationDidBecomeActiveNotification
89          object: NSApp];
90 }
91
92 /* make sure that we don't become key, since we can't handle hotkeys */
93 - (BOOL)canBecomeKeyWindow
94 {
95     return NO;
96 }
97
98 - (BOOL)mouseDownCanMoveWindow
99 {
100     return YES;
101 }
102
103 -(void)dealloc
104 {
105     [[NSNotificationCenter defaultCenter] removeObserver: self];
106
107     if (hideAgainTimer) {
108         [hideAgainTimer invalidate];
109         [hideAgainTimer release];
110     }
111
112     if (o_vout_window)
113         [o_vout_window release];
114
115     [self setFadeTimer:nil];
116     [super dealloc];
117 }
118
119 -(void)center
120 {
121     /* centre the panel in the lower third of the screen */
122     NSPoint theCoordinate;
123     NSRect theScreensFrame;
124     NSRect theWindowsFrame;
125     NSScreen *screen;
126
127     /* user-defined screen */
128     screen = [NSScreen screenWithDisplayID: (CGDirectDisplayID)i_device];
129
130     if (!screen)
131         /* invalid preferences or none specified, using main screen */
132         screen = [NSScreen mainScreen];
133
134     theScreensFrame = [screen frame];
135     theWindowsFrame = [self frame];
136
137     theCoordinate.x = (theScreensFrame.size.width - theWindowsFrame.size.width) / 2 + theScreensFrame.origin.x;
138     theCoordinate.y = (theScreensFrame.size.height / 3) - theWindowsFrame.size.height + theScreensFrame.origin.y;
139     [self setFrameTopLeftPoint: theCoordinate];
140 }
141
142 - (void)setPlay
143 {
144     [[self contentView] setPlay];
145 }
146
147 - (void)setPause
148 {
149     [[self contentView] setPause];
150 }
151
152 - (void)setStreamTitle:(NSString *)o_title
153 {
154     [[self contentView] setStreamTitle: o_title];
155 }
156
157 - (void)setStreamPos:(float) f_pos andTime:(NSString *)o_time
158 {
159     [[self contentView] setStreamPos:f_pos andTime: o_time];
160 }
161
162 - (void)setSeekable:(BOOL) b_seekable
163 {
164     [[self contentView] setSeekable: b_seekable];
165 }
166
167 - (void)setVolumeLevel: (int)i_volumeLevel
168 {
169     [[self contentView] setVolumeLevel: i_volumeLevel];
170 }
171
172 - (void)setNonActive:(id)noData
173 {
174     b_nonActive = YES;
175     [self orderOut: self];
176
177     /* here's fadeOut, just without visibly fading */
178     b_displayed = NO;
179     [self setAlphaValue:0.0];
180     [self setFadeTimer:nil];
181     b_fadeQueued = NO;
182 }
183
184 - (void)setActive:(id)noData
185 {
186     b_nonActive = NO;
187
188     [[VLCMain sharedInstance] showFullscreenController];
189 }
190
191 /* This routine is called repeatedly to fade in the window */
192 - (void)focus:(NSTimer *)timer
193 {
194     /* we need to push ourselves to front if the vout window was closed since our last display */
195     if (b_voutWasUpdated) {
196         [self orderFront: self];
197         b_voutWasUpdated = NO;
198     }
199
200     if ([self alphaValue] < 1.0)
201         [self setAlphaValue:[self alphaValue]+0.1];
202     if ([self alphaValue] >= 1.0) {
203         b_displayed = YES;
204         [self setAlphaValue: 1.0];
205         [self setFadeTimer:nil];
206         if (b_fadeQueued) {
207             b_fadeQueued=NO;
208             [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(unfocus:) userInfo:NULL repeats:YES]];
209         }
210     }
211 }
212
213 /* This routine is called repeatedly to hide the window */
214 - (void)unfocus:(NSTimer *)timer
215 {
216     if (b_keptVisible) {
217         b_keptVisible = NO;
218         b_fadeQueued = NO;
219         [self setFadeTimer: NULL];
220         [self fadeIn];
221         return;
222     }
223     if ([self alphaValue] > 0.0)
224         [self setAlphaValue:[self alphaValue]-0.05];
225     if ([self alphaValue] <= 0.05) {
226         b_displayed = NO;
227         [self setAlphaValue:0.0];
228         [self setFadeTimer:nil];
229         if (b_fadeQueued) {
230             b_fadeQueued=NO;
231             [self setFadeTimer:
232                 [NSTimer scheduledTimerWithTimeInterval:0.1
233                                                  target:self
234                                                selector:@selector(focus:)
235                                                userInfo:NULL
236                                                 repeats:YES]];
237         }
238     }
239 }
240
241 - (void)mouseExited:(NSEvent *)theEvent
242 {
243     /* give up our focus, so the vout may show us again without letting the user clicking it */
244     if (o_vout_window && var_GetBool(pl_Get(VLCIntf), "fullscreen"))
245         [o_vout_window makeKeyWindow];
246 }
247
248 - (void)hideMouse
249 {
250     [NSCursor setHiddenUntilMouseMoves: YES];
251 }
252
253 - (void)fadeIn
254 {
255     /* in case that the user don't want us to appear, make sure we hide the mouse */
256
257     if (!config_GetInt(VLCIntf, "macosx-fspanel")) {
258         float time = (float)var_CreateGetInteger(VLCIntf, "mouse-hide-timeout") / 1000.;
259         [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:time target:self selector:@selector(hideMouse) userInfo:nil repeats:NO]];
260         return;
261     }
262
263     if (b_nonActive)
264         return;
265
266     [self orderFront: nil];
267
268     if ([self alphaValue] < 1.0 || b_displayed != YES) {
269         if (![self fadeTimer])
270             [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(focus:) userInfo:[NSNumber numberWithShort:1] repeats:YES]];
271         else if ([[[self fadeTimer] userInfo] shortValue]==0)
272             b_fadeQueued=YES;
273     }
274     [self autoHide];
275 }
276
277 - (void)fadeOut
278 {
279     if (NSPointInRect([NSEvent mouseLocation],[self frame]))
280         return;
281
282     if (([self alphaValue] > 0.0)) {
283         if (![self fadeTimer])
284             [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(unfocus:) userInfo:[NSNumber numberWithShort:0] repeats:YES]];
285         else if ([[[self fadeTimer] userInfo] shortValue]==1)
286             b_fadeQueued=YES;
287     }
288 }
289
290 /* triggers a timer to autoHide us again after some seconds of no activity */
291 - (void)autoHide
292 {
293     /* this will tell the timer to start over again or to start at all */
294     b_keptVisible = YES;
295
296     /* get us a valid timer */
297     if (! b_alreadyCounting) {
298         i_timeToKeepVisibleInSec = var_CreateGetInteger(VLCIntf, "mouse-hide-timeout") / 500;
299         if (hideAgainTimer) {
300             [hideAgainTimer invalidate];
301             [hideAgainTimer autorelease];
302         }
303         /* released in -autoHide and -dealloc */
304         hideAgainTimer = [[NSTimer scheduledTimerWithTimeInterval: 0.5
305                                                           target: self
306                                                         selector: @selector(keepVisible:)
307                                                         userInfo: nil
308                                                          repeats: YES] retain];
309         b_alreadyCounting = YES;
310     }
311 }
312
313 - (void)keepVisible:(NSTimer *)timer
314 {
315     /* if the user triggered an action, start over again */
316     if (b_keptVisible)
317         b_keptVisible = NO;
318
319     /* count down until we hide ourselfes again and do so if necessary */
320     if (--i_timeToKeepVisibleInSec < 1) {
321         [self hideMouse];
322         [self fadeOut];
323         [hideAgainTimer invalidate]; /* released in -autoHide and -dealloc */
324         b_alreadyCounting = NO;
325     }
326 }
327
328 /* A getter and setter for our main timer that handles window fading */
329 - (NSTimer *)fadeTimer
330 {
331     return fadeTimer;
332 }
333
334 - (void)setFadeTimer:(NSTimer *)timer
335 {
336     [timer retain];
337     [fadeTimer invalidate];
338     [fadeTimer autorelease];
339     fadeTimer=timer;
340 }
341
342 - (void)mouseDown:(NSEvent *)theEvent
343 {
344     mouseClic = [theEvent locationInWindow];
345 }
346
347 - (void)mouseDragged:(NSEvent *)theEvent
348 {
349     NSPoint point = [NSEvent mouseLocation];
350     point.x -= mouseClic.x;
351     point.y -= mouseClic.y;
352     [self setFrameOrigin:point];
353 }
354
355 - (void)setVoutWasUpdated: (VLCWindow *)o_window
356 {
357     b_voutWasUpdated = YES;
358     if (o_vout_window)
359         [o_vout_window release];
360     o_vout_window = [o_window retain];
361     int i_newdevice = (int)[[o_vout_window screen] displayID];
362     if (i_newdevice != i_device) {
363         i_device = i_newdevice;
364         [self center];
365     }
366 }
367 @end
368
369 /*****************************************************************************
370  * FSPanelView
371  *****************************************************************************/
372 @implementation VLCFSPanelView
373
374 #define addButton(o_button, imageOff, imageOn, _x, _y, action, AXDesc, ToolTip)               \
375     s_rc.origin.x = _x;                                                                         \
376     s_rc.origin.y = _y;                                                                         \
377     o_button = [[NSButton alloc] initWithFrame: s_rc];                                 \
378     [o_button setButtonType: NSMomentaryChangeButton];                                          \
379     [o_button setBezelStyle: NSRegularSquareBezelStyle];                                        \
380     [o_button setBordered: NO];                                                                 \
381     [o_button setFont:[NSFont systemFontOfSize:0]];                                             \
382     [o_button setImage:[NSImage imageNamed:imageOff]];                                 \
383     [o_button setAlternateImage:[NSImage imageNamed:imageOn]];                         \
384     [o_button sizeToFit];                                                                       \
385     [o_button setTarget: self];                                                                 \
386     [o_button setAction: @selector(action:)];                                                   \
387     [[o_button cell] accessibilitySetOverrideValue:AXDesc forAttribute:NSAccessibilityDescriptionAttribute]; \
388     [[o_button cell] accessibilitySetOverrideValue:ToolTip forAttribute:NSAccessibilityTitleAttribute]; \
389     [o_button setToolTip: ToolTip]; \
390     [self addSubview:o_button];
391
392 #define addTextfield(class, o_text, align, font, color)                                    \
393     o_text = [[class alloc] initWithFrame: s_rc];                            \
394     [o_text setDrawsBackground: NO];                                                        \
395     [o_text setBordered: NO];                                                               \
396     [o_text setEditable: NO];                                                               \
397     [o_text setSelectable: NO];                                                             \
398     [o_text setStringValue: _NS("(no item is being played)")];                                                    \
399     [o_text setAlignment: align];                                                           \
400     [o_text setTextColor: [NSColor color]];                                                 \
401     [o_text setFont:[NSFont font:[NSFont smallSystemFontSize]]];                     \
402     [self addSubview:o_text];
403
404 - (id)initWithFrame:(NSRect)frameRect
405 {
406     id view = [super initWithFrame:frameRect];
407     fillColor = [[NSColor clearColor] retain];
408     NSRect s_rc = [self frame];
409     addButton(o_prev, @"fs_skip_previous" , @"fs_skip_previous_highlight", 174, 15, prev, _NS("Click to go to the previous playlist item."), _NS("Previous"));
410     addButton(o_bwd, @"fs_rewind"        , @"fs_rewind_highlight"       , 211, 14, backward, _NS("Click and hold to skip backward through the current media."), _NS("Backward"));
411     addButton(o_play, @"fs_play"          , @"fs_play_highlight"         , 267, 10, play, _NS("Click to play or pause the current media."), _NS("Play/Pause"));
412     addButton(o_fwd, @"fs_forward"       , @"fs_forward_highlight"      , 313, 14, forward, _NS("Click and hold to skip forward through the current media."), _NS("Forward"));
413     addButton(o_next, @"fs_skip_next"     , @"fs_skip_next_highlight"    , 365, 15, next, _NS("Click to go to the next playlist item."), _NS("Next"));
414     addButton(o_fullscreen, @"fs_exit_fullscreen", @"fs_exit_fullscreen_hightlight", 507, 13, toggleFullscreen, _NS("Click to exit fullscreen playback."), _NS("Toggle Fullscreen mode"));
415 /*
416     addButton(o_button, @"image (off state)", @"image (on state)", 38, 51, something, accessibility help string, usual tool tip);
417  */
418     [o_fwd setContinuous:YES];
419     [o_bwd setContinuous:YES];
420
421     /* time slider */
422     // (surrounding progress view for swipe behaviour)
423     s_rc.origin.x = 15;
424     s_rc.origin.y = 45;
425     s_rc.size.width = 518;
426     s_rc.size.height = 13;
427     o_progress_view = [[VLCProgressView alloc] initWithFrame: s_rc];
428     s_rc.origin.x = 0;
429     s_rc.origin.y = 0;
430     o_fs_timeSlider = [[VLCFSTimeSlider alloc] initWithFrame: s_rc];
431     [o_fs_timeSlider setMinValue:0];
432     [o_fs_timeSlider setMaxValue:10000];
433     [o_fs_timeSlider setFloatValue: 0];
434     [o_fs_timeSlider setContinuous: YES];
435     [o_fs_timeSlider setTarget: self];
436     [o_fs_timeSlider setAction: @selector(fsTimeSliderUpdate:)];
437     [[o_fs_volumeSlider cell] accessibilitySetOverrideValue:_NS("Position") forAttribute:NSAccessibilityTitleAttribute];
438     [[o_fs_timeSlider cell] accessibilitySetOverrideValue:_NS("Click and move the mouse while keeping the button pressed to use this slider to change current playback position.") forAttribute:NSAccessibilityDescriptionAttribute];
439     [self addSubview: o_progress_view];
440     [o_progress_view addSubview: o_fs_timeSlider];
441
442     /* volume slider */
443     s_rc = [self frame];
444     s_rc.origin.x = 26;
445     s_rc.origin.y = 20;
446     s_rc.size.width = 95;
447     s_rc.size.height = 10;
448     o_fs_volumeSlider = [[VLCFSVolumeSlider alloc] initWithFrame: s_rc];
449     [o_fs_volumeSlider setMinValue:0];
450     [o_fs_volumeSlider setMaxValue:AOUT_VOLUME_MAX];
451     [o_fs_volumeSlider setIntValue:AOUT_VOLUME_DEFAULT];
452     [o_fs_volumeSlider setContinuous: YES];
453     [o_fs_volumeSlider setTarget: self];
454     [o_fs_volumeSlider setAction: @selector(fsVolumeSliderUpdate:)];
455     [[o_fs_volumeSlider cell] accessibilitySetOverrideValue:_NS("Volume") forAttribute:NSAccessibilityTitleAttribute];
456     [[o_fs_volumeSlider cell] accessibilitySetOverrideValue:_NS("Click and move the mouse while keeping the button pressed to use this slider to change the volume.") forAttribute:NSAccessibilityDescriptionAttribute];
457     [self addSubview: o_fs_volumeSlider];
458
459     /* time counter and stream title output fields */
460     s_rc = [self frame];
461     s_rc.origin.x = 98;
462     s_rc.origin.y = 64;
463     s_rc.size.width = 352;
464     s_rc.size.height = 14;
465     addTextfield(NSTextField, o_streamTitle_txt, NSCenterTextAlignment, systemFontOfSize, whiteColor);
466     s_rc.origin.x = 471;
467     s_rc.origin.y = 64;
468     s_rc.size.width = 65;
469     addTextfield(VLCTimeField, o_streamPosition_txt, NSRightTextAlignment, systemFontOfSize, whiteColor);
470
471     o_background_img = [[NSImage imageNamed:@"fs_background"] retain];
472     o_vol_sld_img = [[NSImage imageNamed:@"fs_volume_slider_bar"] retain];
473     o_vol_mute_img = [[NSImage imageNamed:@"fs_volume_mute"] retain];
474     o_vol_max_img = [[NSImage imageNamed:@"fs_volume_max"] retain];
475     o_time_sld_img = [[NSImage imageNamed:@"fs_time_slider"] retain];
476
477     return view;
478 }
479
480 - (void)dealloc
481 {
482     [o_background_img release];
483     [o_vol_sld_img release];
484     [o_vol_mute_img release];
485     [o_vol_max_img release];
486     [o_time_sld_img release];
487     [o_fs_timeSlider release];
488     [o_fs_volumeSlider release];
489     [o_prev release];
490     [o_next release];
491     [o_bwd release];
492     [o_play release];
493     [o_fwd release];
494     [o_fullscreen release];
495     [o_streamTitle_txt release];
496     [o_streamPosition_txt release];
497     [super dealloc];
498 }
499
500 - (void)setPlay
501 {
502     [o_play setImage:[NSImage imageNamed:@"fs_play"]];
503     [o_play setAlternateImage: [NSImage imageNamed:@"fs_play_highlight"]];
504 }
505
506 - (void)setPause
507 {
508     [o_play setImage: [NSImage imageNamed:@"fs_pause"]];
509     [o_play setAlternateImage: [NSImage imageNamed:@"fs_pause_highlight"]];
510 }
511
512 - (void)setStreamTitle:(NSString *)o_title
513 {
514     [o_streamTitle_txt setStringValue: o_title];
515 }
516
517 - (void)setStreamPos:(float) f_pos andTime:(NSString *)o_time
518 {
519     [o_streamPosition_txt setStringValue: o_time];
520     [o_fs_timeSlider setFloatValue: f_pos];
521 }
522
523 - (void)setSeekable:(BOOL)b_seekable
524 {
525     [o_bwd setEnabled: b_seekable];
526     [o_fwd setEnabled: b_seekable];
527     [o_fs_timeSlider setEnabled: b_seekable];
528 }
529
530 - (void)setVolumeLevel: (int)i_volumeLevel
531 {
532     [o_fs_volumeSlider setIntValue: i_volumeLevel];
533 }
534
535 - (IBAction)play:(id)sender
536 {
537     [[VLCCoreInteraction sharedInstance] playOrPause];
538 }
539
540 - (IBAction)forward:(id)sender
541 {
542     if (([NSDate timeIntervalSinceReferenceDate] - last_fwd_event) > 0.16) {
543         // we just skipped 4 "continous" events, otherwise we are too fast
544         [[VLCCoreInteraction sharedInstance] forwardExtraShort];
545         last_fwd_event = [NSDate timeIntervalSinceReferenceDate];
546     }
547 }
548
549 - (IBAction)backward:(id)sender
550 {
551     if (([NSDate timeIntervalSinceReferenceDate] - last_bwd_event) > 0.16) {
552         // we just skipped 4 "continous" events, otherwise we are too fast
553         [[VLCCoreInteraction sharedInstance] backwardExtraShort];
554         last_bwd_event = [NSDate timeIntervalSinceReferenceDate];
555     }
556 }
557
558 - (IBAction)prev:(id)sender
559 {
560     [[VLCCoreInteraction sharedInstance] previous];
561 }
562
563 - (IBAction)next:(id)sender
564 {
565     [[VLCCoreInteraction sharedInstance] next];
566 }
567
568 - (IBAction)toggleFullscreen:(id)sender
569 {
570     [[VLCCoreInteraction sharedInstance] toggleFullscreen];
571 }
572
573 - (IBAction)fsTimeSliderUpdate:(id)sender
574 {
575     input_thread_t * p_input;
576     p_input = pl_CurrentInput(VLCIntf);
577     if (p_input != NULL) {
578         vlc_value_t pos;
579
580         pos.f_float = [o_fs_timeSlider floatValue] / 10000.;
581         var_Set(p_input, "position", pos);
582         vlc_object_release(p_input);
583     }
584     [[VLCMain sharedInstance] updatePlaybackPosition];
585 }
586
587 - (IBAction)fsVolumeSliderUpdate:(id)sender
588 {
589     [[VLCCoreInteraction sharedInstance] setVolume: [sender intValue]];
590 }
591
592 #define addImage(image, _x, _y, mode)                                                       \
593     image_size = [image size];                                                              \
594     image_rect.size = image_size;                                                           \
595     image_rect.origin.x = 0;                                                                \
596     image_rect.origin.y = 0;                                                                \
597     frame.origin.x = _x;                                                                    \
598     frame.origin.y = _y;                                                                    \
599     frame.size = image_size;                                                                \
600     [image drawInRect:frame fromRect:image_rect operation:mode fraction:1];
601
602 - (void)drawRect:(NSRect)rect
603 {
604     NSRect frame = [self frame];
605     NSRect image_rect;
606     NSSize image_size;
607     NSImage *img;
608     addImage(o_background_img, 0, 0, NSCompositeCopy);
609     addImage(o_vol_sld_img, 26, 23, NSCompositeSourceOver);
610     addImage(o_vol_mute_img, 16, 18, NSCompositeSourceOver);
611     addImage(o_vol_max_img, 124, 18, NSCompositeSourceOver);
612     addImage(o_time_sld_img, 15, 45, NSCompositeSourceOver);
613 }
614
615 @end
616
617 /*****************************************************************************
618  * VLCFSTimeSlider
619  *****************************************************************************/
620 @implementation VLCFSTimeSlider
621 - (void)drawKnobInRect:(NSRect)knobRect
622 {
623     NSRect image_rect;
624     NSImage *img = [NSImage imageNamed:@"fs_time_slider_knob_highlight"];
625     image_rect.size = [img size];
626     image_rect.origin.x = 0;
627     image_rect.origin.y = 0;
628     knobRect.origin.x += (knobRect.size.width - image_rect.size.width) / 2;
629     knobRect.size.width = image_rect.size.width;
630     knobRect.size.height = image_rect.size.height;
631     [img drawInRect:knobRect fromRect:image_rect operation:NSCompositeSourceOver fraction:1];
632 }
633
634 - (void)drawRect:(NSRect)rect
635 {
636     /* Draw default to make sure the slider behaves correctly */
637     [[NSGraphicsContext currentContext] saveGraphicsState];
638     NSRectClip(NSZeroRect);
639     [super drawRect:rect];
640     [[NSGraphicsContext currentContext] restoreGraphicsState];
641
642     NSRect knobRect = [[self cell] knobRectFlipped:NO];
643     knobRect.origin.y+=4;
644     [[[NSColor blackColor] colorWithAlphaComponent:0.6] set];
645     [self drawKnobInRect: knobRect];
646 }
647
648 @end
649
650 /*****************************************************************************
651 * VLCFSVolumeSlider
652 *****************************************************************************/
653 @implementation VLCFSVolumeSlider
654 - (void)drawKnobInRect:(NSRect) knobRect
655 {
656     NSRect image_rect;
657     NSImage *img = [NSImage imageNamed:@"fs_volume_slider_knob"];
658     image_rect.size = [img size];
659     image_rect.origin.x = 0;
660     image_rect.origin.y = 0;
661     knobRect.origin.x += (knobRect.size.width - image_rect.size.width) / 2;
662     knobRect.size.width = image_rect.size.width;
663     knobRect.size.height = image_rect.size.height;
664     [img drawInRect:knobRect fromRect:image_rect operation:NSCompositeSourceOver fraction:1];
665 }
666
667 - (void)drawRect:(NSRect)rect
668 {
669     /* Draw default to make sure the slider behaves correctly */
670     [[NSGraphicsContext currentContext] saveGraphicsState];
671     NSRectClip(NSZeroRect);
672     [super drawRect:rect];
673     [[NSGraphicsContext currentContext] restoreGraphicsState];
674
675     NSRect knobRect = [[self cell] knobRectFlipped:NO];
676     knobRect.origin.y+=6;
677     [[[NSColor blackColor] colorWithAlphaComponent:0.6] set];
678     [self drawKnobInRect: knobRect];
679 }
680
681 @end
682