]> git.sesse.net Git - vlc/blob - modules/gui/macosx/fspanel.m
fspanel: resize the panel by factor 1.5 if the screen's width is > 1920
[vlc] / modules / gui / macosx / fspanel.m
1 /*****************************************************************************
2  * fspanel.m: MacOS X full screen panel
3  *****************************************************************************
4  * Copyright (C) 2006-2011 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  *
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 #import "intf.h"
29 #import "CoreInteraction.h"
30 #import "MainWindow.h"
31 #import "misc.h"
32 #import "fspanel.h"
33 #import "CompatibilityFixes.h"
34
35 @interface VLCFSPanel ()
36 - (void)hideMouse;
37 @end
38
39 /*****************************************************************************
40  * VLCFSPanel
41  *****************************************************************************/
42 @implementation VLCFSPanel
43 /* We override this initializer so we can set the NSBorderlessWindowMask styleMask, and set a few other important settings */
44 - (id)initWithContentRect:(NSRect)contentRect 
45                 styleMask:(NSUInteger)aStyle 
46                   backing:(NSBackingStoreType)bufferingType 
47                     defer:(BOOL)flag
48 {
49     id win = [super initWithContentRect:contentRect styleMask:NSTexturedBackgroundWindowMask backing:bufferingType defer:flag];
50     [win setOpaque:NO];
51     [win setHasShadow: NO];
52     [win setBackgroundColor:[NSColor clearColor]];
53     if (OSX_LION)
54         [win setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
55
56     /* let the window sit on top of everything else and start out completely transparent */
57     [win setLevel:NSModalPanelWindowLevel];
58     i_device = 0;
59     hideAgainTimer = fadeTimer = nil;
60     [self setNonActive:nil];
61     return win;
62 }
63
64 - (void)awakeFromNib
65 {
66     [self setContentView:[[VLCFSPanelView alloc] initWithFrame: [self frame]]];
67     BOOL isInside = (NSPointInRect([NSEvent mouseLocation],[self frame]));
68     [[self contentView] addTrackingRect:[[self contentView] bounds] owner:self userData:nil assumeInside:isInside];
69     if (isInside)
70         [self mouseEntered:NULL];
71     if (!isInside)
72         [self mouseExited:NULL];
73
74     [self center];
75     
76     /* get a notification if VLC isn't the active app anymore */
77     [[NSNotificationCenter defaultCenter]
78     addObserver: self
79        selector: @selector(setNonActive:)
80            name: NSApplicationDidResignActiveNotification
81          object: NSApp];
82     
83     /* get a notification if VLC is the active app again */
84     [[NSNotificationCenter defaultCenter]
85     addObserver: self
86        selector: @selector(setActive:)
87            name: NSApplicationDidBecomeActiveNotification
88          object: NSApp];
89 }
90
91 /* make sure that we don't become key, since we can't handle hotkeys */
92 - (BOOL)canBecomeKeyWindow
93 {
94     return NO;
95 }
96
97 - (BOOL)mouseDownCanMoveWindow
98 {
99     return YES;
100 }
101
102 -(void)dealloc
103 {
104     [[NSNotificationCenter defaultCenter] removeObserver: self];
105
106     if( hideAgainTimer )
107     {
108         [hideAgainTimer invalidate];
109         [hideAgainTimer release];
110     }
111     [self setFadeTimer:nil];
112     [super dealloc];
113 }
114
115 -(void)center
116 {
117     /* centre the panel in the lower third of the screen */
118     NSPoint theCoordinate;
119     NSRect theScreensFrame;
120     NSRect theWindowsFrame;
121     NSScreen *screen;
122     
123     /* user-defined screen */
124     screen = [NSScreen screenWithDisplayID: (CGDirectDisplayID)i_device];
125     
126     if (!screen)
127     {
128         /* invalid preferences or none specified, using main screen */
129         screen = [NSScreen mainScreen];
130     }
131
132     theScreensFrame = [screen frame];
133     theWindowsFrame = [self frame];
134     
135     if( theScreensFrame.size.width >= 1920 ) //  17" MBP, 24"/27" iMacs, external displays
136         b_usingBigScreen = YES;
137
138     if( (b_usingBigScreen && theWindowsFrame.size.width < 820) || (!b_usingBigScreen && theWindowsFrame.size.width > 550) )
139         [self adaptWindowSizeToScreen];
140
141     theCoordinate.x = (theScreensFrame.size.width - theWindowsFrame.size.width) / 2 + theScreensFrame.origin.x;
142     theCoordinate.y = (theScreensFrame.size.height / 3) - theWindowsFrame.size.height + theScreensFrame.origin.y;
143     [self setFrameTopLeftPoint: theCoordinate];
144 }
145
146 - (void)setPlay
147 {
148     [[self contentView] setPlay];
149 }
150
151 - (void)setPause
152 {
153     [[self contentView] setPause];
154 }
155
156 - (void)setStreamTitle:(NSString *)o_title
157 {
158     [[self contentView] setStreamTitle: o_title];
159 }
160
161 - (void)setStreamPos:(float) f_pos andTime:(NSString *)o_time
162 {
163     [[self contentView] setStreamPos:f_pos andTime: o_time];
164 }
165
166 - (void)setSeekable:(BOOL) b_seekable
167 {
168     [[self contentView] setSeekable: b_seekable];
169 }
170
171 - (void)setVolumeLevel: (float)f_volumeLevel
172 {
173     [[self contentView] setVolumeLevel: f_volumeLevel];
174 }
175
176 - (void)setNonActive:(id)noData
177 {
178     b_nonActive = YES;
179     [self orderOut: self];
180     
181     /* here's fadeOut, just without visibly fading */
182     b_displayed = NO;
183     [self setAlphaValue:0.0];
184     [self setFadeTimer:nil];
185     b_fadeQueued = NO;
186 }
187
188 - (void)setActive:(id)noData
189 {
190     b_nonActive = NO;
191     [[VLCMain sharedInstance] showFullscreenController];
192 }
193
194 /* This routine is called repeatedly to fade in the window */
195 - (void)focus:(NSTimer *)timer
196 {
197     /* we need to push ourselves to front if the vout window was closed since our last display */
198     if( b_voutWasUpdated )
199     {
200         [self orderFront: self];
201         b_voutWasUpdated = NO;
202     }
203
204     if( [self alphaValue] < 1.0 )
205         [self setAlphaValue:[self alphaValue]+0.1];
206     if( [self alphaValue] >= 1.0 )
207     {
208         b_displayed = YES;
209         [self setAlphaValue: 1.0];
210         [self setFadeTimer:nil];
211         if( b_fadeQueued )
212         {
213             b_fadeQueued=NO;
214             [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(unfocus:) userInfo:NULL repeats:YES]];
215         }
216     }
217 }
218
219 /* This routine is called repeatedly to hide the window */
220 - (void)unfocus:(NSTimer *)timer
221 {
222     if( b_keptVisible )
223     {
224         b_keptVisible = NO;
225         b_fadeQueued = NO;
226         [self setFadeTimer: NULL];
227         [self fadeIn];
228         return;
229     }
230     if( [self alphaValue] > 0.0 )
231         [self setAlphaValue:[self alphaValue]-0.05];
232     if( [self alphaValue] <= 0.05 )
233     {
234         b_displayed = NO;
235         [self setAlphaValue:0.0];
236         [self setFadeTimer:nil];
237         if( b_fadeQueued )
238         {
239             b_fadeQueued=NO;
240             [self setFadeTimer:
241                 [NSTimer scheduledTimerWithTimeInterval:0.1 
242                                                  target:self 
243                                                selector:@selector(focus:) 
244                                                userInfo:NULL 
245                                                 repeats:YES]];
246         }
247     }
248 }
249
250 - (void)mouseExited:(NSEvent *)theEvent
251 {
252     /* give up our focus, so the vout may show us again without letting the user clicking it */
253     vout_thread_t *p_vout = getVout();
254     if (p_vout)
255     {
256         if (var_GetBool( p_vout, "fullscreen" ))
257             [[[[VLCMainWindow sharedInstance] videoView] window] makeKeyWindow];
258         vlc_object_release( p_vout );
259     }
260 }
261
262 - (void)hideMouse
263 {
264     [NSCursor setHiddenUntilMouseMoves: YES];
265 }
266
267 - (void)fadeIn
268 {
269     /* in case that the user don't want us to appear, make sure we hide the mouse */
270
271     if( !config_GetInt( VLCIntf, "macosx-fspanel" ) )
272     {
273         float time = (float)var_CreateGetInteger( VLCIntf, "mouse-hide-timeout" ) / 1000.;
274         [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:time target:self selector:@selector(hideMouse) userInfo:nil repeats:NO]];
275         return;
276     }
277
278     if( b_nonActive )
279         return;
280
281     [self orderFront: nil];
282     
283     if( [self alphaValue] < 1.0 || b_displayed != YES )
284     {
285         if (![self fadeTimer])
286             [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(focus:) userInfo:[NSNumber numberWithShort:1] repeats:YES]];
287         else if ([[[self fadeTimer] userInfo] shortValue]==0)
288             b_fadeQueued=YES;
289     }
290     [self autoHide];
291 }
292
293 - (void)fadeOut
294 {
295     if( NSPointInRect([NSEvent mouseLocation],[self frame]))
296         return;
297
298     if( ( [self alphaValue] > 0.0 ) )
299     {
300         if (![self fadeTimer])
301             [self setFadeTimer:[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(unfocus:) userInfo:[NSNumber numberWithShort:0] repeats:YES]];
302         else if ([[[self fadeTimer] userInfo] shortValue]==1)
303             b_fadeQueued=YES;
304     }
305 }
306
307 /* triggers a timer to autoHide us again after some seconds of no activity */
308 - (void)autoHide
309 {
310     /* this will tell the timer to start over again or to start at all */
311     b_keptVisible = YES;
312     
313     /* get us a valid timer */
314     if(! b_alreadyCounting )
315     {
316         i_timeToKeepVisibleInSec = var_CreateGetInteger( VLCIntf, "mouse-hide-timeout" ) / 500;
317         if( hideAgainTimer )
318         {
319             [hideAgainTimer invalidate];
320             [hideAgainTimer autorelease];
321         }
322         /* released in -autoHide and -dealloc */
323         hideAgainTimer = [[NSTimer scheduledTimerWithTimeInterval: 0.5
324                                                           target: self 
325                                                         selector: @selector(keepVisible:)
326                                                         userInfo: nil 
327                                                          repeats: YES] retain];
328         b_alreadyCounting = YES;
329     }
330 }
331
332 - (void)keepVisible:(NSTimer *)timer
333 {
334     /* if the user triggered an action, start over again */
335     if( b_keptVisible )
336         b_keptVisible = NO;
337
338     /* count down until we hide ourselfes again and do so if necessary */
339     if( --i_timeToKeepVisibleInSec < 1 )
340     {
341         [self hideMouse];
342         [self fadeOut];
343         [hideAgainTimer invalidate]; /* released in -autoHide and -dealloc */
344         b_alreadyCounting = NO;
345     }
346 }
347
348 /* A getter and setter for our main timer that handles window fading */
349 - (NSTimer *)fadeTimer
350 {
351     return fadeTimer;
352 }
353
354 - (void)setFadeTimer:(NSTimer *)timer
355 {
356     [timer retain];
357     [fadeTimer invalidate];
358     [fadeTimer autorelease];
359     fadeTimer=timer;
360 }
361
362 - (void)mouseDown:(NSEvent *)theEvent
363 {
364     mouseClic = [theEvent locationInWindow];
365 }
366
367 - (void)mouseDragged:(NSEvent *)theEvent
368 {
369     NSPoint point = [NSEvent mouseLocation];
370     point.x -= mouseClic.x;
371     point.y -= mouseClic.y;
372     [self setFrameOrigin:point];
373 }
374
375 - (BOOL)isDisplayed
376 {
377     return b_displayed;
378 }
379
380 - (void)setVoutWasUpdated: (int)i_newdevice;
381 {
382     b_voutWasUpdated = YES;
383     if( i_newdevice != i_device )
384     {
385         i_device = i_newdevice;
386         [self center];
387     }
388 }
389
390 - (void)adaptWindowSizeToScreen
391 {
392     NSRect theWindowsFrame = [self frame];
393     if( b_usingBigScreen )
394     {
395         theWindowsFrame.size.width = 824;
396         theWindowsFrame.size.height = 131;
397     }
398     else
399     {
400         theWindowsFrame.size.width = 549;
401         theWindowsFrame.size.height = 87;
402     }
403
404     [[self contentView] adaptViewSizeToScreen: b_usingBigScreen];
405
406     [self setFrame:theWindowsFrame display:YES animate:YES];
407 }
408 @end
409
410 /*****************************************************************************
411  * FSPanelView
412  *****************************************************************************/
413 @implementation VLCFSPanelView
414
415 #define addButton( o_button, imageOff, imageOn, _x, _y, action )                                \
416     s_rc.origin.x = _x;                                                                         \
417     s_rc.origin.y = _y;                                                                         \
418     o_button = [[NSButton alloc] initWithFrame: s_rc];                                 \
419     [o_button setButtonType: NSMomentaryChangeButton];                                          \
420     [o_button setBezelStyle: NSRegularSquareBezelStyle];                                        \
421     [o_button setBordered: NO];                                                                 \
422     [o_button setFont:[NSFont systemFontOfSize:0]];                                             \
423     [o_button setImage:[NSImage imageNamed:imageOff]];                                 \
424     [o_button setAlternateImage:[NSImage imageNamed:imageOn]];                         \
425     [o_button sizeToFit];                                                                       \
426     [o_button setTarget: self];                                                                 \
427     [o_button setAction: @selector(action:)];                                                   \
428     [self addSubview:o_button];
429
430 #define addTextfield( class, o_text, align, font, color )                                    \
431     o_text = [[class alloc] initWithFrame: s_rc];                            \
432     [o_text setDrawsBackground: NO];                                                        \
433     [o_text setBordered: NO];                                                               \
434     [o_text setEditable: NO];                                                               \
435     [o_text setSelectable: NO];                                                             \
436     [o_text setStringValue: _NS("(no item is being played)")];                                                    \
437     [o_text setAlignment: align];                                                           \
438     [o_text setTextColor: [NSColor color]];                                                 \
439     [o_text setFont:[NSFont font:[NSFont smallSystemFontSize]]];                     \
440     [self addSubview:o_text];
441
442 #define restyleButton( o_button, imageOff, imageOn, _x, _y ) \
443     [o_button setFrameOrigin: NSMakePoint( _x, _y )]; \
444     [o_button setImage: [NSImage imageNamed: imageOff]]; \
445     [o_button setAlternateImage: [NSImage imageNamed: imageOn]]; \
446     [o_button sizeToFit]; \
447     [o_button setNeedsDisplay: YES]
448
449 #define restyleTextfieldOrSlider( o_field, _x, _y, _w, _h ) \
450     [o_field setFrameOrigin: NSMakePoint( _x, _y )]; \
451     [o_field setFrameSize: NSMakeSize( _w, _h )]; \
452     [o_field setNeedsDisplay: YES]
453
454
455 - (id)initWithFrame:(NSRect)frameRect
456 {
457     id view = [super initWithFrame:frameRect];
458     fillColor = [[NSColor clearColor] retain];
459     NSRect s_rc = [self frame];
460     addButton( o_prev, @"fs_skip_previous" , @"fs_skip_previous_highlight", 174, 15, prev );
461     addButton( o_bwd, @"fs_rewind"        , @"fs_rewind_highlight"       , 211, 14, backward );
462     addButton( o_play, @"fs_play"          , @"fs_play_highlight"         , 267, 10, play );
463     addButton( o_fwd, @"fs_forward"       , @"fs_forward_highlight"      , 313, 14, forward );
464     addButton( o_next, @"fs_skip_next"     , @"fs_skip_next_highlight"    , 365, 15, next );
465     addButton( o_fullscreen, @"fs_exit_fullscreen", @"fs_exit_fullscreen_hightlight", 507, 13, toggleFullscreen );
466 /*
467     addButton( o_button, @"image (off state)", @"image (on state)", 38, 51, something );
468  */
469
470     /* time slider */
471     s_rc = [self frame];
472     s_rc.origin.x = 15;
473     s_rc.origin.y = 55;
474     s_rc.size.width = 518;
475     s_rc.size.height = 9;
476     o_fs_timeSlider = [[VLCFSTimeSlider alloc] initWithFrame: s_rc];
477     [o_fs_timeSlider setMinValue:0];
478     [o_fs_timeSlider setMaxValue:10000];
479     [o_fs_timeSlider setFloatValue: 0];
480     [o_fs_timeSlider setContinuous: YES];
481     [o_fs_timeSlider setTarget: self];
482     [o_fs_timeSlider setAction: @selector(fsTimeSliderUpdate:)];
483     [self addSubview: o_fs_timeSlider];
484
485     /* volume slider */
486     s_rc = [self frame];
487     s_rc.origin.x = 26;
488     s_rc.origin.y = 20;
489     s_rc.size.width = 95;
490     s_rc.size.height = 10;
491     o_fs_volumeSlider = [[VLCFSVolumeSlider alloc] initWithFrame: s_rc];
492     [o_fs_volumeSlider setMinValue:0];
493     [o_fs_volumeSlider setMaxValue:32];
494     [o_fs_volumeSlider setFloatValue: 0];
495     [o_fs_volumeSlider setContinuous: YES];
496     [o_fs_volumeSlider setTarget: self];
497     [o_fs_volumeSlider setAction: @selector(fsVolumeSliderUpdate:)];
498     [self addSubview: o_fs_volumeSlider];
499     
500     /* time counter and stream title output fields */
501     s_rc = [self frame];
502     s_rc.origin.x = 98;
503     s_rc.origin.y = 64;
504     s_rc.size.width = 352;
505     s_rc.size.height = 14;
506     addTextfield( NSTextField, o_streamTitle_txt, NSCenterTextAlignment, systemFontOfSize, whiteColor );
507     s_rc.origin.x = 481;
508     s_rc.origin.y = 64;
509     s_rc.size.width = 55;
510     addTextfield( VLCTimeField, o_streamPosition_txt, NSRightTextAlignment, systemFontOfSize, whiteColor );
511
512     return view;
513 }
514
515 - (void)dealloc
516 {
517     [o_fs_timeSlider release];
518     [o_fs_volumeSlider release];
519     [o_prev release];
520     [o_next release];
521     [o_bwd release];
522     [o_play release];
523     [o_fwd release];
524     [o_fullscreen release];
525     [o_streamTitle_txt release];
526     [o_streamPosition_txt release];
527     [super dealloc];
528 }
529
530 - (void)setPlay
531 {
532     if( b_usingBigScreen )
533     {
534         [o_play setImage:[NSImage imageNamed:@"fs_play@x1.5"]];
535         [o_play setAlternateImage: [NSImage imageNamed:@"fs_play_highlight@x1.5"]];
536     }
537     else
538     {
539         [o_play setImage:[NSImage imageNamed:@"fs_play"]];
540         [o_play setAlternateImage: [NSImage imageNamed:@"fs_play_highlight"]];
541     }
542 }
543
544 - (void)setPause
545 {
546     if( b_usingBigScreen )
547     {
548         [o_play setImage: [NSImage imageNamed:@"fs_pause@x1.5"]];
549         [o_play setAlternateImage: [NSImage imageNamed:@"fs_pause_highlight@x1.5"]];
550     }
551     else
552     {
553         [o_play setImage: [NSImage imageNamed:@"fs_pause"]];
554         [o_play setAlternateImage: [NSImage imageNamed:@"fs_pause_highlight"]];
555     }
556 }
557
558 - (void)setStreamTitle:(NSString *)o_title
559 {
560     [o_streamTitle_txt setStringValue: o_title];
561 }
562
563 - (void)setStreamPos:(float) f_pos andTime:(NSString *)o_time
564 {
565     [o_streamPosition_txt setStringValue: o_time];
566     [o_fs_timeSlider setFloatValue: f_pos];
567 }
568
569 - (void)setSeekable:(BOOL)b_seekable
570 {
571     [o_bwd setEnabled: b_seekable];
572     [o_fwd setEnabled: b_seekable];
573     [o_fs_timeSlider setEnabled: b_seekable];
574 }
575
576 - (void)setVolumeLevel: (float)f_volumeLevel
577 {
578     [o_fs_volumeSlider setFloatValue: f_volumeLevel];
579 }
580
581 - (IBAction)play:(id)sender
582 {
583     [[VLCCoreInteraction sharedInstance] play];
584 }
585
586 - (IBAction)forward:(id)sender
587 {
588     [[VLCCoreInteraction sharedInstance] forward];
589 }
590
591 - (IBAction)backward:(id)sender
592 {
593     [[VLCCoreInteraction sharedInstance] backward];
594 }
595
596 - (IBAction)prev:(id)sender
597 {
598     [[VLCCoreInteraction sharedInstance] previous];
599 }
600
601 - (IBAction)next:(id)sender
602 {
603     [[VLCCoreInteraction sharedInstance] next];
604 }
605
606 - (IBAction)toggleFullscreen:(id)sender
607 {
608     [[VLCCoreInteraction sharedInstance] toggleFullscreen];
609 }
610
611 - (IBAction)fsTimeSliderUpdate:(id)sender
612 {
613     input_thread_t * p_input;
614     p_input = pl_CurrentInput( VLCIntf );
615     if( p_input != NULL )
616     {
617         vlc_value_t pos;
618
619         pos.f_float = [o_fs_timeSlider floatValue] / 10000.;
620         var_Set( p_input, "position", pos );
621         vlc_object_release( p_input );
622     }
623     [[VLCMain sharedInstance] updatePlaybackPosition];
624 }
625
626 - (IBAction)fsVolumeSliderUpdate:(id)sender
627 {
628     [[VLCCoreInteraction sharedInstance] setVolume: [sender intValue]];
629 }
630
631 #define addImage(image, _x, _y, mode, _width)                                               \
632     img = [NSImage imageNamed:image];                                              \
633     image_rect.size = [img size];                                                           \
634     image_rect.origin.x = 0;                                                                \
635     image_rect.origin.y = 0;                                                                \
636     frame.origin.x = _x;                                                                    \
637     frame.origin.y = _y;                                                                    \
638     frame.size = [img size];                                                                \
639     if( _width ) frame.size.width = _width;                                                 \
640     [img drawInRect:frame fromRect:image_rect operation:mode fraction:1];
641
642 - (void)drawRect:(NSRect)rect
643 {
644     NSRect frame = [self frame];
645     NSRect image_rect;
646     NSImage *img;
647     if (b_usingBigScreen)
648     {
649         addImage( @"fs_background@x1.5", 0, 0, NSCompositeCopy, 0 );
650         addImage( @"fs_volume_slider_bar@x1.5", 39, 35.5, NSCompositeSourceOver, 0 );
651         addImage( @"fs_volume_mute@x1.5", 24, 27, NSCompositeSourceOver, 0 );
652         addImage( @"fs_volume_max@x1.5", 186, 27, NSCompositeSourceOver, 0 );
653         addImage( @"fs_time_slider@x1.5", 22.5, 79.5, NSCompositeSourceOver, 0);
654     }
655     else
656     {
657         addImage( @"fs_background", 0, 0, NSCompositeCopy, 0 );
658         addImage( @"fs_volume_slider_bar", 26, 23, NSCompositeSourceOver, 0 );
659         addImage( @"fs_volume_mute", 16, 18, NSCompositeSourceOver, 0 );
660         addImage( @"fs_volume_max", 124, 18, NSCompositeSourceOver, 0 );
661         addImage( @"fs_time_slider", 15, 53, NSCompositeSourceOver, 0);
662     }
663 }
664
665 - (void)adaptViewSizeToScreen:(BOOL)b_value
666 {
667     b_usingBigScreen = b_value;
668
669     if (b_usingBigScreen)
670     {
671         restyleButton( o_prev, @"fs_skip_previous@x1.5", @"fs_skip_previous_highlight@x1.5", 261, 22.5 );
672         restyleButton( o_bwd, @"fs_rewind@x1.5", @"fs_rewind_highlight@x1.5", 316.5, 21 );
673         restyleButton( o_play, @"fs_play@x1.5", @"fs_play_highlight@x1.5", 400.5, 15 );
674         restyleButton( o_fwd, @"fs_forward@x1.5", @"fs_forward_highlight@x1.5", 469.5, 21 );
675         restyleButton( o_next, @"fs_skip_next@x1.5", @"fs_skip_next_highlight@x1.5", 547.5, 22.5 );
676         restyleButton( o_fullscreen, @"fs_exit_fullscreen@x1.5", @"fs_exit_fullscreen_hightlight@x1.5", 765.5, 19.5 );
677         restyleTextfieldOrSlider( o_streamTitle_txt, 148, 96, 528, 21 );
678         [o_streamTitle_txt setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
679         restyleTextfieldOrSlider( o_streamPosition_txt, 718, 96, 82.5, 21 );
680         [o_streamPosition_txt setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
681         restyleTextfieldOrSlider( o_fs_timeSlider, 22.5, 82.5, 777, 13.5 );
682         restyleTextfieldOrSlider( o_fs_volumeSlider, 39, 32, 142.5, 15);
683     }
684     else
685     {
686         restyleButton( o_prev, @"fs_skip_previous", @"fs_skip_previous_highlight", 174, 15 );
687         restyleButton( o_bwd, @"fs_rewind", @"fs_rewind_highlight", 211, 14 );
688         restyleButton( o_play, @"fs_play", @"fs_play_highlight", 267, 10 );
689         restyleButton( o_fwd, @"fs_forward", @"fs_forward_highlight", 313, 14 );
690         restyleButton( o_next, @"fs_skip_next", @"fs_skip_next_highlight", 365, 15 );
691         restyleButton( o_fullscreen, @"fs_exit_fullscreen", @"fs_exit_fullscreen_hightlight", 507, 13 );
692         restyleTextfieldOrSlider( o_streamTitle_txt, 98, 64, 352, 14 );
693         [o_streamTitle_txt setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
694         restyleTextfieldOrSlider( o_streamPosition_txt, 481, 64, 55, 14);
695         [o_streamPosition_txt setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
696         restyleTextfieldOrSlider( o_fs_timeSlider, 15, 55, 518, 9 );
697         restyleTextfieldOrSlider( o_fs_volumeSlider, 26, 20, 95, 10);
698     }
699 }
700
701 @end
702
703 /*****************************************************************************
704  * VLCFSTimeSlider
705  *****************************************************************************/
706 @implementation VLCFSTimeSlider
707 - (void)drawKnobInRect:(NSRect)knobRect
708 {
709     NSRect image_rect;
710     NSImage *img = [NSImage imageNamed:@"fs_time_slider_knob_highlight"];
711     image_rect.size = [img size];
712     image_rect.origin.x = 0;
713     image_rect.origin.y = 0;
714     knobRect.origin.x += (knobRect.size.width - image_rect.size.width) / 2;
715     knobRect.size.width = image_rect.size.width;
716     knobRect.size.height = image_rect.size.height;
717     [img drawInRect:knobRect fromRect:image_rect operation:NSCompositeSourceOver fraction:1];
718 }
719
720 - (void)drawRect:(NSRect)rect
721 {
722     /* Draw default to make sure the slider behaves correctly */
723     [[NSGraphicsContext currentContext] saveGraphicsState];
724     NSRectClip(NSZeroRect);
725     [super drawRect:rect];
726     [[NSGraphicsContext currentContext] restoreGraphicsState];
727     
728     NSRect knobRect = [[self cell] knobRectFlipped:NO];
729     knobRect.origin.y+=7.5;
730     [[[NSColor blackColor] colorWithAlphaComponent:0.6] set];
731     [self drawKnobInRect: knobRect];
732 }
733
734 @end
735
736 /*****************************************************************************
737 * VLCFSVolumeSlider
738 *****************************************************************************/
739 @implementation VLCFSVolumeSlider
740 - (void)drawKnobInRect:(NSRect) knobRect
741 {
742     NSRect image_rect;
743     NSImage *img = [NSImage imageNamed:@"fs_volume_slider_knob"];
744     image_rect.size = [img size];
745     image_rect.origin.x = 0;
746     image_rect.origin.y = 0;
747     knobRect.origin.x += (knobRect.size.width - image_rect.size.width) / 2;
748     knobRect.size.width = image_rect.size.width;
749     knobRect.size.height = image_rect.size.height;
750     [img drawInRect:knobRect fromRect:image_rect operation:NSCompositeSourceOver fraction:1];
751 }
752
753 - (void)drawRect:(NSRect)rect
754 {
755     /* Draw default to make sure the slider behaves correctly */
756     [[NSGraphicsContext currentContext] saveGraphicsState];
757     NSRectClip(NSZeroRect);
758     [super drawRect:rect];
759     [[NSGraphicsContext currentContext] restoreGraphicsState];
760     
761     NSRect knobRect = [[self cell] knobRectFlipped:NO];
762     knobRect.origin.y+=6;
763     [[[NSColor blackColor] colorWithAlphaComponent:0.6] set];
764     [self drawKnobInRect: knobRect];
765 }
766
767 @end
768