File: ControlsBar.m

package info (click to toggle)
vlc 2.2.7-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 191,124 kB
  • sloc: ansic: 356,116; cpp: 94,295; objc: 34,063; sh: 6,765; makefile: 4,272; xml: 1,538; asm: 1,251; python: 240; perl: 77; sed: 16
file content (1167 lines) | stat: -rw-r--r-- 43,316 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
/*****************************************************************************
 * ControlsBar.m: MacOS X interface module
 *****************************************************************************
 * Copyright (C) 2012-2014 VLC authors and VideoLAN
 * $Id: 3da5f9be6b1e50aae0903a1d2183acc4c32def8c $
 *
 * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
 *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#import "ControlsBar.h"
#import "intf.h"
#import "CoreInteraction.h"
#import "MainMenu.h"
#import "fspanel.h"
#import "CompatibilityFixes.h"

/*****************************************************************************
 * VLCControlsBarCommon
 *
 *  Holds all outlets, actions and code common for controls bar in detached
 *  and in main window.
 *****************************************************************************/

@implementation VLCControlsBarCommon

@synthesize bottomBarView=o_bottombar_view;

- (void)awakeFromNib
{
    b_dark_interface = config_GetInt(VLCIntf, "macosx-interfacestyle");

    b_nativeFullscreenMode = NO;
#ifdef MAC_OS_X_VERSION_10_7
    if (!OSX_SNOW_LEOPARD)
        b_nativeFullscreenMode = var_InheritBool(VLCIntf, "macosx-nativefullscreenmode");
#endif

    [o_drop_view setDrawBorder: NO];

    [o_play_btn setToolTip: _NS("Play/Pause")];
    [[o_play_btn cell] accessibilitySetOverrideValue:_NS("Click to play or pause the current media.") forAttribute:NSAccessibilityDescriptionAttribute];
    [[o_play_btn cell] accessibilitySetOverrideValue:[o_play_btn toolTip] forAttribute:NSAccessibilityTitleAttribute];

    [o_bwd_btn setToolTip: _NS("Backward")];
    [[o_bwd_btn cell] accessibilitySetOverrideValue:_NS("Click to go to the previous playlist item. Hold to skip backward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute];
    [[o_bwd_btn cell] accessibilitySetOverrideValue:[o_bwd_btn toolTip] forAttribute:NSAccessibilityTitleAttribute];

    [o_fwd_btn setToolTip: _NS("Forward")];
    [[o_fwd_btn cell] accessibilitySetOverrideValue:_NS("Click to go to the next playlist item. Hold to skip forward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute];
    [[o_fwd_btn cell] accessibilitySetOverrideValue:[o_fwd_btn toolTip] forAttribute:NSAccessibilityTitleAttribute];

    [o_time_sld setToolTip: _NS("Position")];
    [[o_time_sld cell] accessibilitySetOverrideValue:_NS("Click and move the mouse while keeping the button pressed to use this slider to change current playback position.") forAttribute:NSAccessibilityDescriptionAttribute];
    [[o_time_sld cell] accessibilitySetOverrideValue:[o_time_sld toolTip] forAttribute:NSAccessibilityTitleAttribute];

    [o_fullscreen_btn setToolTip: _NS("Toggle Fullscreen mode")];
    [[o_fullscreen_btn cell] accessibilitySetOverrideValue:_NS("Click to enable fullscreen video playback.") forAttribute:NSAccessibilityDescriptionAttribute];
    [[o_fullscreen_btn cell] accessibilitySetOverrideValue:[o_fullscreen_btn toolTip] forAttribute:NSAccessibilityTitleAttribute];

    if (!b_dark_interface) {
        [o_bottombar_view setImagesLeft: imageFromRes(@"bottom-background") middle: imageFromRes(@"bottom-background") right: imageFromRes(@"bottom-background")];

        [o_bwd_btn setImage: imageFromRes(@"backward-3btns")];
        [o_bwd_btn setAlternateImage: imageFromRes(@"backward-3btns-pressed")];
        o_play_img = [imageFromRes(@"play") retain];
        o_play_pressed_img = [imageFromRes(@"play-pressed") retain];
        o_pause_img = [imageFromRes(@"pause") retain];
        o_pause_pressed_img = [imageFromRes(@"pause-pressed") retain];
        [o_fwd_btn setImage: imageFromRes(@"forward-3btns")];
        [o_fwd_btn setAlternateImage: imageFromRes(@"forward-3btns-pressed")];

        [o_time_sld_background setImagesLeft: imageFromRes(@"progression-track-wrapper-left") middle: imageFromRes(@"progression-track-wrapper-middle") right: imageFromRes(@"progression-track-wrapper-right")];
        [o_time_sld_fancygradient_view setImagesLeft:imageFromRes(@"progression-fill-left") middle:imageFromRes(@"progression-fill-middle") right:imageFromRes(@"progression-fill-right")];

        [o_fullscreen_btn setImage: imageFromRes(@"fullscreen-one-button")];
        [o_fullscreen_btn setAlternateImage: imageFromRes(@"fullscreen-one-button-pressed")];
    } else {
        [o_bottombar_view setImagesLeft: imageFromRes(@"bottomdark-left") middle: imageFromRes(@"bottom-background_dark") right: imageFromRes(@"bottomdark-right")];

        [o_bwd_btn setImage: imageFromRes(@"backward-3btns-dark")];
        [o_bwd_btn setAlternateImage: imageFromRes(@"backward-3btns-dark-pressed")];
        o_play_img = [imageFromRes(@"play_dark") retain];
        o_play_pressed_img = [imageFromRes(@"play-pressed_dark") retain];
        o_pause_img = [imageFromRes(@"pause_dark") retain];
        o_pause_pressed_img = [imageFromRes(@"pause-pressed_dark") retain];
        [o_fwd_btn setImage: imageFromRes(@"forward-3btns-dark")];
        [o_fwd_btn setAlternateImage: imageFromRes(@"forward-3btns-dark-pressed")];

        [o_time_sld_background setImagesLeft: imageFromRes(@"progression-track-wrapper-left_dark") middle: imageFromRes(@"progression-track-wrapper-middle_dark") right: imageFromRes(@"progression-track-wrapper-right_dark")];
        [o_time_sld_fancygradient_view setImagesLeft:imageFromRes(@"progressbar-fill-left_dark") middle:imageFromRes(@"progressbar-fill-middle_dark") right:imageFromRes(@"progressbar-fill-right_dark")];

        [o_fullscreen_btn setImage: imageFromRes(@"fullscreen-one-button-pressed_dark")];
        [o_fullscreen_btn setAlternateImage: imageFromRes(@"fullscreen-one-button-pressed_dark")];
    }

    [o_play_btn setImage: o_play_img];
    [o_play_btn setAlternateImage: o_play_pressed_img];

    NSColor *o_string_color;
    if (!var_InheritBool(VLCIntf, "macosx-interfacestyle"))
        o_string_color = [NSColor colorWithCalibratedRed:0.229 green:0.229 blue:0.229 alpha:100.0];
    else
        o_string_color = [NSColor colorWithCalibratedRed:0.64 green:0.64 blue:0.64 alpha:100.0];
    [o_time_fld setTextColor: o_string_color];
    [o_time_fld setFont:[NSFont titleBarFontOfSize:10.0]];
    [o_time_fld setAlignment: NSCenterTextAlignment];
    [o_time_fld setNeedsDisplay:YES];
    [o_time_fld setRemainingIdentifier:@"DisplayTimeAsTimeRemaining"];

    // prepare time slider fance gradient view
    if (!b_dark_interface) {
        NSRect frame;
        frame = [o_time_sld_fancygradient_view frame];
        frame.size.height = frame.size.height - 1;
        frame.origin.y = frame.origin.y + 1;
        [o_time_sld_fancygradient_view setFrame: frame];
    }

    NSRect frame;
    frame = [o_time_sld_fancygradient_view frame];
    frame.size.width = 0;
    [o_time_sld_fancygradient_view setFrame: frame];

    // hide resize view if necessary
    if (!OSX_SNOW_LEOPARD)
        [o_resize_view setImage: NULL];

    if ([[o_bottombar_view window] styleMask] & NSResizableWindowMask)
        [o_resize_view removeFromSuperviewWithoutNeedingDisplay];


    // remove fullscreen button for lion fullscreen
    if (b_nativeFullscreenMode) {
        CGFloat f_width = [o_fullscreen_btn frame].size.width;

        NSRect frame = [o_time_fld frame];
        frame.origin.x += f_width;
        [o_time_fld setFrame: frame];

        frame = [o_progress_view frame];
        frame.size.width = f_width + frame.size.width;
        [o_progress_view setFrame: frame];

        [o_fullscreen_btn removeFromSuperviewWithoutNeedingDisplay];
    }

    if (config_GetInt(VLCIntf, "macosx-show-playback-buttons"))
        [self toggleForwardBackwardMode: YES];

}

- (CGFloat)height
{
    return [o_bottombar_view frame].size.height;
}

- (void)toggleForwardBackwardMode:(BOOL)b_alt
{
    if (b_alt == YES) {
        /* change the accessibility help for the backward/forward buttons accordingly */
        [[o_bwd_btn cell] accessibilitySetOverrideValue:_NS("Click and hold to skip backward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute];
        [[o_fwd_btn cell] accessibilitySetOverrideValue:_NS("Click and hold to skip forward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute];

        [o_fwd_btn setAction:@selector(alternateForward:)];
        [o_bwd_btn setAction:@selector(alternateBackward:)];

    } else {
        /* change the accessibility help for the backward/forward buttons accordingly */
        [[o_bwd_btn cell] accessibilitySetOverrideValue:_NS("Click to go to the previous playlist item. Hold to skip backward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute];
        [[o_fwd_btn cell] accessibilitySetOverrideValue:_NS("Click to go to the next playlist item. Hold to skip forward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute];

        [o_fwd_btn setAction:@selector(fwd:)];
        [o_bwd_btn setAction:@selector(bwd:)];
    }
}

#pragma mark -
#pragma mark Button Actions

- (IBAction)play:(id)sender
{
    [[VLCCoreInteraction sharedInstance] playOrPause];
}

- (void)resetPreviousButton
{
    if (([NSDate timeIntervalSinceReferenceDate] - last_bwd_event) >= 0.35) {
        // seems like no further event occurred, so let's switch the playback item
        [[VLCCoreInteraction sharedInstance] previous];
        just_triggered_previous = NO;
    }
}

- (void)resetBackwardSkip
{
    // the user stopped skipping, so let's allow him to change the item
    if (([NSDate timeIntervalSinceReferenceDate] - last_bwd_event) >= 0.35)
        just_triggered_previous = NO;
}

- (IBAction)bwd:(id)sender
{
    if (!just_triggered_previous) {
        just_triggered_previous = YES;
        [self performSelector:@selector(resetPreviousButton)
                   withObject: NULL
                   afterDelay:0.40];
    } else {
        if (([NSDate timeIntervalSinceReferenceDate] - last_fwd_event) > 0.16) {
            // we just skipped 4 "continous" events, otherwise we are too fast
            [[VLCCoreInteraction sharedInstance] backwardExtraShort];
            last_bwd_event = [NSDate timeIntervalSinceReferenceDate];
            [self performSelector:@selector(resetBackwardSkip)
                       withObject: NULL
                       afterDelay:0.40];
        }
    }
}

- (void)resetNextButton
{
    if (([NSDate timeIntervalSinceReferenceDate] - last_fwd_event) >= 0.35) {
        // seems like no further event occurred, so let's switch the playback item
        [[VLCCoreInteraction sharedInstance] next];
        just_triggered_next = NO;
    }
}

- (void)resetForwardSkip
{
    // the user stopped skipping, so let's allow him to change the item
    if (([NSDate timeIntervalSinceReferenceDate] - last_fwd_event) >= 0.35)
        just_triggered_next = NO;
}

- (IBAction)fwd:(id)sender
{
    if (!just_triggered_next) {
        just_triggered_next = YES;
        [self performSelector:@selector(resetNextButton)
                   withObject: NULL
                   afterDelay:0.40];
    } else {
        if (([NSDate timeIntervalSinceReferenceDate] - last_fwd_event) > 0.16) {
            // we just skipped 4 "continous" events, otherwise we are too fast
            [[VLCCoreInteraction sharedInstance] forwardExtraShort];
            last_fwd_event = [NSDate timeIntervalSinceReferenceDate];
            [self performSelector:@selector(resetForwardSkip)
                       withObject: NULL
                       afterDelay:0.40];
        }
    }
}

// alternative actions for forward / backward buttons when next / prev are activated
- (IBAction)alternateForward:(id)sender
{
    [[VLCCoreInteraction sharedInstance] forwardExtraShort];
}

- (IBAction)alternateBackward:(id)sender
{
    [[VLCCoreInteraction sharedInstance] backwardExtraShort];
}

- (IBAction)timeSliderAction:(id)sender
{
    float f_updated;
    input_thread_t * p_input;

    switch([[NSApp currentEvent] type]) {
        case NSLeftMouseUp:
        case NSLeftMouseDown:
        case NSLeftMouseDragged:
            f_updated = [sender floatValue];
            break;

        default:
            return;
    }
    p_input = pl_CurrentInput(VLCIntf);
    if (p_input != NULL) {
        vlc_value_t pos;
        NSString * o_time;

        pos.f_float = f_updated / 10000.;
        var_Set(p_input, "position", pos);
        [o_time_sld setFloatValue: f_updated];

        o_time = [[VLCStringUtility sharedInstance] getCurrentTimeAsString: p_input negative:[o_time_fld timeRemaining]];
        [o_time_fld setStringValue: o_time];
        vlc_object_release(p_input);
    }
}

- (IBAction)fullscreen:(id)sender
{
    [[VLCCoreInteraction sharedInstance] toggleFullscreen];
}

#pragma mark -
#pragma mark Updaters

- (void)updateTimeSlider
{
    input_thread_t * p_input;
    p_input = pl_CurrentInput(VLCIntf);
    if (p_input) {
        NSString * o_time;
        vlc_value_t pos;
        float f_updated;

        var_Get(p_input, "position", &pos);
        f_updated = 10000. * pos.f_float;
        [o_time_sld setFloatValue: f_updated];

        o_time = [[VLCStringUtility sharedInstance] getCurrentTimeAsString: p_input negative:[o_time_fld timeRemaining]];

        mtime_t dur = input_item_GetDuration(input_GetItem(p_input));
        if (dur == -1) {
            [o_time_sld setHidden: YES];
            [o_time_sld_fancygradient_view setHidden: YES];
        } else {
            if ([o_time_sld isHidden] == YES) {
                bool b_buffering = false;
                input_state_e inputState = input_GetState(p_input);
                if (inputState == INIT_S || inputState == OPENING_S)
                    b_buffering = YES;

                [o_time_sld setHidden: b_buffering];
                [o_time_sld_fancygradient_view setHidden: b_buffering];
            }
        }
        [o_time_fld setStringValue: o_time];
        [o_time_fld setNeedsDisplay:YES];

        vlc_object_release(p_input);
    } else {
        [o_time_sld setFloatValue: 0.0];
        [o_time_fld setStringValue: @"00:00"];
        [o_time_sld setHidden: YES];
        [o_time_sld_fancygradient_view setHidden: YES];
    }
}

- (void)drawFancyGradientEffectForTimeSlider
{
    NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
    CGFloat f_value = [o_time_sld knobPosition];
    if (f_value > 7.5) {
        NSRect oldFrame = [o_time_sld_fancygradient_view frame];
        if (f_value != oldFrame.size.width) {
            if ([o_time_sld_fancygradient_view isHidden])
                [o_time_sld_fancygradient_view setHidden: NO];
            [o_time_sld_fancygradient_view setFrame: NSMakeRect(oldFrame.origin.x, oldFrame.origin.y, f_value, oldFrame.size.height)];
        }
    } else {
        NSRect frame;
        frame = [o_time_sld_fancygradient_view frame];
        if (frame.size.width > 0) {
            frame.size.width = 0;
            [o_time_sld_fancygradient_view setFrame: frame];
        }
        [o_time_sld_fancygradient_view setHidden: YES];
    }
    [o_pool release];
}

- (void)updateControls
{
    bool b_plmul = false;
    bool b_seekable = false;
    bool b_chapters = false;
    bool b_buffering = false;

    playlist_t * p_playlist = pl_Get(VLCIntf);

    PL_LOCK;
    b_plmul = playlist_CurrentSize(p_playlist) > 1;
    PL_UNLOCK;

    input_thread_t * p_input = playlist_CurrentInput(p_playlist);


    if (p_input) {
        input_state_e inputState = input_GetState(p_input);
        if (inputState == INIT_S || inputState == OPENING_S)
            b_buffering = YES;

        /* seekable streams */
        b_seekable = var_GetBool(p_input, "can-seek");

        /* chapters & titles */
        //FIXME! b_chapters = p_input->stream.i_area_nb > 1;

        vlc_object_release(p_input);
    }


    if (b_buffering) {
        [o_progress_bar startAnimation:self];
        [o_progress_bar setIndeterminate:YES];
        [o_progress_bar setHidden:NO];
    } else {
        [o_progress_bar stopAnimation:self];
        [o_progress_bar setHidden:YES];
    }

    [o_time_sld setEnabled: b_seekable];

    [o_fwd_btn setEnabled: (b_seekable || b_plmul || b_chapters)];
    [o_bwd_btn setEnabled: (b_seekable || b_plmul || b_chapters)];
}

- (void)setPause
{
    [o_play_btn setImage: o_pause_img];
    [o_play_btn setAlternateImage: o_pause_pressed_img];
    [o_play_btn setToolTip: _NS("Pause")];
}

- (void)setPlay
{
    [o_play_btn setImage: o_play_img];
    [o_play_btn setAlternateImage: o_play_pressed_img];
    [o_play_btn setToolTip: _NS("Play")];
}

- (void)setFullscreenState:(BOOL)b_fullscreen
{
    if (!b_nativeFullscreenMode)
        [o_fullscreen_btn setState:b_fullscreen];
}

- (void)dealloc {
    [o_play_img release];
    [o_play_pressed_img release];
    [o_pause_img release];
    [o_pause_pressed_img release];
    [super dealloc];
}

@end


/*****************************************************************************
 * VLCMainWindowControlsBar
 *
 *  Holds all specific outlets, actions and code for the main window controls bar.
 *****************************************************************************/

@interface VLCMainWindowControlsBar (Internal)
- (void)addJumpButtons:(BOOL)b_fast;
- (void)removeJumpButtons:(BOOL)b_fast;
- (void)addPlaymodeButtons:(BOOL)b_fast;
- (void)removePlaymodeButtons:(BOOL)b_fast;
@end

@implementation VLCMainWindowControlsBar

- (void)awakeFromNib
{
    [super awakeFromNib];


    [o_stop_btn setToolTip: _NS("Stop")];
    [[o_stop_btn cell] accessibilitySetOverrideValue:_NS("Click to stop playback.") forAttribute:NSAccessibilityDescriptionAttribute];
    [[o_stop_btn cell] accessibilitySetOverrideValue:[o_stop_btn toolTip] forAttribute:NSAccessibilityTitleAttribute];

    [o_playlist_btn setToolTip: _NS("Show/Hide Playlist")];
    [[o_playlist_btn cell] accessibilitySetOverrideValue:_NS("Click to switch between video output and playlist. If no video is shown in the main window, this allows you to hide the playlist.") forAttribute:NSAccessibilityDescriptionAttribute];
    [[o_playlist_btn cell] accessibilitySetOverrideValue:[o_playlist_btn toolTip] forAttribute:NSAccessibilityTitleAttribute];

    [o_repeat_btn setToolTip: _NS("Repeat")];
    [[o_repeat_btn cell] accessibilitySetOverrideValue:_NS("Click to change repeat mode. There are 3 states: repeat one, repeat all and off.") forAttribute:NSAccessibilityDescriptionAttribute];
    [[o_repeat_btn cell] accessibilitySetOverrideValue:[o_repeat_btn toolTip] forAttribute:NSAccessibilityTitleAttribute];

    [o_shuffle_btn setToolTip: _NS("Shuffle")];
    [[o_shuffle_btn cell] accessibilitySetOverrideValue:[o_shuffle_btn toolTip] forAttribute:NSAccessibilityTitleAttribute];
    [[o_shuffle_btn cell] accessibilitySetOverrideValue:_NS("Click to enable or disable random playback.") forAttribute:NSAccessibilityDescriptionAttribute];

    [o_volume_sld setToolTip: _NS("Volume")];
    [[o_volume_sld cell] accessibilitySetOverrideValue:_NS("Click and move the mouse while keeping the button pressed to use this slider to change the volume.") forAttribute:NSAccessibilityDescriptionAttribute];
    [[o_volume_sld cell] accessibilitySetOverrideValue:[o_volume_sld toolTip] forAttribute:NSAccessibilityTitleAttribute];
    [o_volume_down_btn setToolTip: _NS("Mute")];
    [[o_volume_down_btn cell] accessibilitySetOverrideValue:_NS("Click to mute or unmute the audio.") forAttribute:NSAccessibilityDescriptionAttribute];
    [[o_volume_down_btn cell] accessibilitySetOverrideValue:[o_volume_down_btn toolTip] forAttribute:NSAccessibilityTitleAttribute];
    [o_volume_up_btn setToolTip: _NS("Full Volume")];
    [[o_volume_up_btn cell] accessibilitySetOverrideValue:_NS("Click to play the audio at maximum volume.") forAttribute:NSAccessibilityDescriptionAttribute];
    [[o_volume_up_btn cell] accessibilitySetOverrideValue:[o_volume_up_btn toolTip] forAttribute:NSAccessibilityTitleAttribute];

    [o_effects_btn setToolTip: _NS("Audio Effects")];
    [[o_effects_btn cell] accessibilitySetOverrideValue:_NS("Click to show an Audio Effects panel featuring an equalizer and further filters.") forAttribute:NSAccessibilityDescriptionAttribute];
    [[o_effects_btn cell] accessibilitySetOverrideValue:[o_effects_btn toolTip] forAttribute:NSAccessibilityTitleAttribute];

    if (!b_dark_interface) {
        [o_stop_btn setImage: imageFromRes(@"stop")];
        [o_stop_btn setAlternateImage: imageFromRes(@"stop-pressed")];

        [o_playlist_btn setImage: imageFromRes(@"playlist-btn")];
        [o_playlist_btn setAlternateImage: imageFromRes(@"playlist-btn-pressed")];
        o_repeat_img = [imageFromRes(@"repeat") retain];
        o_repeat_pressed_img = [imageFromRes(@"repeat-pressed") retain];
        o_repeat_all_img  = [imageFromRes(@"repeat-all") retain];
        o_repeat_all_pressed_img = [imageFromRes(@"repeat-all-pressed") retain];
        o_repeat_one_img = [imageFromRes(@"repeat-one") retain];
        o_repeat_one_pressed_img = [imageFromRes(@"repeat-one-pressed") retain];
        o_shuffle_img = [imageFromRes(@"shuffle") retain];
        o_shuffle_pressed_img = [imageFromRes(@"shuffle-pressed") retain];
        o_shuffle_on_img = [imageFromRes(@"shuffle-blue") retain];
        o_shuffle_on_pressed_img = [imageFromRes(@"shuffle-blue-pressed") retain];

        [o_volume_down_btn setImage: imageFromRes(@"volume-low")];
        [o_volume_track_view setImage: imageFromRes(@"volume-slider-track")];
        [o_volume_up_btn setImage: imageFromRes(@"volume-high")];
        [o_volume_sld setUsesBrightArtwork: YES];

        if (b_nativeFullscreenMode) {
            [o_effects_btn setImage: imageFromRes(@"effects-one-button")];
            [o_effects_btn setAlternateImage: imageFromRes(@"effects-one-button-pressed")];
        } else {
            [o_effects_btn setImage: imageFromRes(@"effects-double-buttons")];
            [o_effects_btn setAlternateImage: imageFromRes(@"effects-double-buttons-pressed")];
        }

        [o_fullscreen_btn setImage: imageFromRes(@"fullscreen-double-buttons")];
        [o_fullscreen_btn setAlternateImage: imageFromRes(@"fullscreen-double-buttons-pressed")];
    } else {
        [o_stop_btn setImage: imageFromRes(@"stop_dark")];
        [o_stop_btn setAlternateImage: imageFromRes(@"stop-pressed_dark")];

        [o_playlist_btn setImage: imageFromRes(@"playlist_dark")];
        [o_playlist_btn setAlternateImage: imageFromRes(@"playlist-pressed_dark")];
        o_repeat_img = [imageFromRes(@"repeat_dark") retain];
        o_repeat_pressed_img = [imageFromRes(@"repeat-pressed_dark") retain];
        o_repeat_all_img  = [imageFromRes(@"repeat-all-blue_dark") retain];
        o_repeat_all_pressed_img = [imageFromRes(@"repeat-all-blue-pressed_dark") retain];
        o_repeat_one_img = [imageFromRes(@"repeat-one-blue_dark") retain];
        o_repeat_one_pressed_img = [imageFromRes(@"repeat-one-blue-pressed_dark") retain];
        o_shuffle_img = [imageFromRes(@"shuffle_dark") retain];
        o_shuffle_pressed_img = [imageFromRes(@"shuffle-pressed_dark") retain];
        o_shuffle_on_img = [imageFromRes(@"shuffle-blue_dark") retain];
        o_shuffle_on_pressed_img = [imageFromRes(@"shuffle-blue-pressed_dark") retain];

        [o_volume_down_btn setImage: imageFromRes(@"volume-low_dark")];
        [o_volume_track_view setImage: imageFromRes(@"volume-slider-track_dark")];
        [o_volume_up_btn setImage: imageFromRes(@"volume-high_dark")];
        [o_volume_sld setUsesBrightArtwork: NO];

        if (b_nativeFullscreenMode) {
            [o_effects_btn setImage: imageFromRes(@"effects-one-button_dark")];
            [o_effects_btn setAlternateImage: imageFromRes(@"effects-one-button-pressed-dark")];
        } else {
            [o_effects_btn setImage: imageFromRes(@"effects-double-buttons_dark")];
            [o_effects_btn setAlternateImage: imageFromRes(@"effects-double-buttons-pressed_dark")];
        }

        [o_fullscreen_btn setImage: imageFromRes(@"fullscreen-double-buttons_dark")];
        [o_fullscreen_btn setAlternateImage: imageFromRes(@"fullscreen-double-buttons-pressed_dark")];
    }
    [o_repeat_btn setImage: o_repeat_img];
    [o_repeat_btn setAlternateImage: o_repeat_pressed_img];
    [o_shuffle_btn setImage: o_shuffle_img];
    [o_shuffle_btn setAlternateImage: o_shuffle_pressed_img];

    BOOL b_mute = ![[VLCCoreInteraction sharedInstance] mute];
    [o_volume_sld setEnabled: b_mute];
    [o_volume_sld setMaxValue: [[VLCCoreInteraction sharedInstance] maxVolume]];
    [o_volume_up_btn setEnabled: b_mute];

    // remove fullscreen button for lion fullscreen
    if (b_nativeFullscreenMode) {
        NSRect frame;

        // == [o_fullscreen_btn frame].size.width;
        // button is already removed!
        float f_width = 29.;
#define moveItem(item) \
frame = [item frame]; \
frame.origin.x = f_width + frame.origin.x; \
[item setFrame: frame]

        moveItem(o_effects_btn);
        moveItem(o_volume_up_btn);
        moveItem(o_volume_sld);
        moveItem(o_volume_track_view);
        moveItem(o_volume_down_btn);
#undef moveItem

        // time field and progress bar are moved in super method!
    }


    b_show_jump_buttons = config_GetInt(VLCIntf, "macosx-show-playback-buttons");
    if (b_show_jump_buttons)
        [self addJumpButtons:YES];

    b_show_playmode_buttons = config_GetInt(VLCIntf, "macosx-show-playmode-buttons");
    if (!b_show_playmode_buttons)
        [self removePlaymodeButtons:YES];

    if (!config_GetInt(VLCIntf, "macosx-show-effects-button"))
        [self removeEffectsButton:YES];

    [[VLCMain sharedInstance] playbackModeUpdated];

}

#pragma mark -
#pragma mark interface customization


- (void)toggleEffectsButton
{
    if (config_GetInt(VLCIntf, "macosx-show-effects-button"))
        [self addEffectsButton:NO];
    else
        [self removeEffectsButton:NO];
}

- (void)addEffectsButton:(BOOL)b_fast
{
    if (!o_effects_btn)
        return;

    if (b_fast) {
        [o_effects_btn setHidden: NO];
    } else {
        [[o_effects_btn animator] setHidden: NO];
    }

#define moveItem(item) \
frame = [item frame]; \
frame.origin.x = frame.origin.x - f_space; \
if (b_fast) \
[item setFrame: frame]; \
else \
[[item animator] setFrame: frame]

    NSRect frame;
    CGFloat f_space = [o_effects_btn frame].size.width;
    // extra margin between button and volume up button
    if (b_nativeFullscreenMode)
        f_space += 2;


    moveItem(o_volume_up_btn);
    moveItem(o_volume_sld);
    moveItem(o_volume_track_view);
    moveItem(o_volume_down_btn);
    moveItem(o_time_fld);
#undef moveItem


    frame = [o_progress_view frame];
    frame.size.width = frame.size.width - f_space;
    if (b_fast)
        [o_progress_view setFrame: frame];
    else
        [[o_progress_view animator] setFrame: frame];

    if (!b_nativeFullscreenMode) {
        if (b_dark_interface) {
            [o_fullscreen_btn setImage: imageFromRes(@"fullscreen-double-buttons_dark")];
            [o_fullscreen_btn setAlternateImage: imageFromRes(@"fullscreen-double-buttons-pressed_dark")];
        } else {
            [o_fullscreen_btn setImage: imageFromRes(@"fullscreen-double-buttons")];
            [o_fullscreen_btn setAlternateImage: imageFromRes(@"fullscreen-double-buttons-pressed")];
        }
    }

    [o_bottombar_view setNeedsDisplay:YES];
}

- (void)removeEffectsButton:(BOOL)b_fast
{
    if (!o_effects_btn)
        return;

    [o_effects_btn setHidden: YES];

#define moveItem(item) \
frame = [item frame]; \
frame.origin.x = frame.origin.x + f_space; \
if (b_fast) \
[item setFrame: frame]; \
else \
[[item animator] setFrame: frame]

    NSRect frame;
    CGFloat f_space = [o_effects_btn frame].size.width;
    // extra margin between button and volume up button
    if (b_nativeFullscreenMode)
        f_space += 2;

    moveItem(o_volume_up_btn);
    moveItem(o_volume_sld);
    moveItem(o_volume_track_view);
    moveItem(o_volume_down_btn);
    moveItem(o_time_fld);
#undef moveItem


    frame = [o_progress_view frame];
    frame.size.width = frame.size.width + f_space;
    if (b_fast)
        [o_progress_view setFrame: frame];
    else
        [[o_progress_view animator] setFrame: frame];

    if (!b_nativeFullscreenMode) {
        if (b_dark_interface) {
            [[o_fullscreen_btn animator] setImage: imageFromRes(@"fullscreen-one-button_dark")];
            [[o_fullscreen_btn animator] setAlternateImage: imageFromRes(@"fullscreen-one-button-pressed_dark")];
        } else {
            [[o_fullscreen_btn animator] setImage: imageFromRes(@"fullscreen-one-button")];
            [[o_fullscreen_btn animator] setAlternateImage: imageFromRes(@"fullscreen-one-button-pressed")];
        }
    }

    [o_bottombar_view setNeedsDisplay:YES];
}

- (void)toggleJumpButtons
{
    b_show_jump_buttons = config_GetInt(VLCIntf, "macosx-show-playback-buttons");

    if (b_show_jump_buttons)
        [self addJumpButtons:NO];
    else
        [self removeJumpButtons:NO];
}

- (void)addJumpButtons:(BOOL)b_fast
{
    NSRect preliminaryFrame = [o_bwd_btn frame];
    BOOL b_enabled = [o_bwd_btn isEnabled];
    preliminaryFrame.size.width = 29.;
    o_prev_btn = [[NSButton alloc] initWithFrame:preliminaryFrame];
    [o_prev_btn setButtonType: NSMomentaryChangeButton];
    [o_prev_btn setBezelStyle:NSRegularSquareBezelStyle];
    [o_prev_btn setBordered:NO];
    [o_prev_btn setTarget:self];
    [o_prev_btn setAction:@selector(prev:)];
    [o_prev_btn setToolTip: _NS("Previous")];
    [[o_prev_btn cell] accessibilitySetOverrideValue:_NS("Previous") forAttribute:NSAccessibilityTitleAttribute];
    [[o_prev_btn cell] accessibilitySetOverrideValue:_NS("Click to go to the previous playlist item.") forAttribute:NSAccessibilityDescriptionAttribute];
    [o_prev_btn setEnabled: b_enabled];

    o_next_btn = [[NSButton alloc] initWithFrame:preliminaryFrame];
    [o_next_btn setButtonType: NSMomentaryChangeButton];
    [o_next_btn setBezelStyle:NSRegularSquareBezelStyle];
    [o_next_btn setBordered:NO];
    [o_next_btn setTarget:self];
    [o_next_btn setAction:@selector(next:)];
    [o_next_btn setToolTip: _NS("Next")];
    [[o_next_btn cell] accessibilitySetOverrideValue:_NS("Next") forAttribute:NSAccessibilityTitleAttribute];
    [[o_next_btn cell] accessibilitySetOverrideValue:_NS("Click to go to the next playlist item.") forAttribute:NSAccessibilityDescriptionAttribute];
    [o_next_btn setEnabled: b_enabled];

    if (b_dark_interface) {
        [o_prev_btn setImage: imageFromRes(@"previous-6btns-dark")];
        [o_prev_btn setAlternateImage: imageFromRes(@"previous-6btns-dark-pressed")];
        [o_next_btn setImage: imageFromRes(@"next-6btns-dark")];
        [o_next_btn setAlternateImage: imageFromRes(@"next-6btns-dark-pressed")];
    } else {
        [o_prev_btn setImage: imageFromRes(@"previous-6btns")];
        [o_prev_btn setAlternateImage: imageFromRes(@"previous-6btns-pressed")];
        [o_next_btn setImage: imageFromRes(@"next-6btns")];
        [o_next_btn setAlternateImage: imageFromRes(@"next-6btns-pressed")];
    }

    NSRect frame;
    frame = [o_bwd_btn frame];
    frame.size.width--;
    [o_bwd_btn setFrame:frame];
    frame = [o_fwd_btn frame];
    frame.size.width--;
    [o_fwd_btn setFrame:frame];

#define moveItem(item) \
frame = [item frame]; \
frame.origin.x = frame.origin.x + f_space; \
if (b_fast) \
    [item setFrame: frame]; \
else \
    [[item animator] setFrame: frame]

    float f_space = 29.;
    moveItem(o_bwd_btn);
    f_space = 28.;
    moveItem(o_play_btn);
    moveItem(o_fwd_btn);
    f_space = 28. * 2;
    moveItem(o_stop_btn);
    moveItem(o_playlist_btn);
    moveItem(o_repeat_btn);
    moveItem(o_shuffle_btn);
#undef moveItem

    frame = [o_progress_view frame];
    frame.size.width = frame.size.width - f_space;
    frame.origin.x = frame.origin.x + f_space;
    if (b_fast)
        [o_progress_view setFrame: frame];
    else
        [[o_progress_view animator] setFrame: frame];

    if (b_dark_interface) {
        [[o_fwd_btn animator] setImage:imageFromRes(@"forward-6btns-dark")];
        [[o_fwd_btn animator] setAlternateImage:imageFromRes(@"forward-6btns-dark-pressed")];
        [[o_bwd_btn animator] setImage:imageFromRes(@"backward-6btns-dark")];
        [[o_bwd_btn animator] setAlternateImage:imageFromRes(@"backward-6btns-dark-pressed")];
    } else {
        [[o_fwd_btn animator] setImage:imageFromRes(@"forward-6btns")];
        [[o_fwd_btn animator] setAlternateImage:imageFromRes(@"forward-6btns-pressed")];
        [[o_bwd_btn animator] setImage:imageFromRes(@"backward-6btns")];
        [[o_bwd_btn animator] setAlternateImage:imageFromRes(@"backward-6btns-pressed")];
    }

    preliminaryFrame.origin.x = [o_prev_btn frame].origin.x + [o_prev_btn frame].size.width + [o_bwd_btn frame].size.width + [o_play_btn frame].size.width + [o_fwd_btn frame].size.width;
    [o_next_btn setFrame: preliminaryFrame];

    // wait until the animation is done, if displayed
    if (b_fast) {
        [o_bottombar_view addSubview:o_prev_btn];
        [o_bottombar_view addSubview:o_next_btn];
    } else {
        [o_bottombar_view performSelector:@selector(addSubview:) withObject:o_prev_btn afterDelay:.2];
        [o_bottombar_view performSelector:@selector(addSubview:) withObject:o_next_btn afterDelay:.2];
    }

    [self toggleForwardBackwardMode: YES];
}

- (void)removeJumpButtons:(BOOL)b_fast
{
    if (!o_prev_btn || !o_next_btn)
        return;

    if (b_fast) {
        [o_prev_btn setHidden: YES];
        [o_next_btn setHidden: YES];
    } else {
        [[o_prev_btn animator] setHidden: YES];
        [[o_next_btn animator] setHidden: YES];
    }
    [o_prev_btn removeFromSuperviewWithoutNeedingDisplay];
    [o_next_btn removeFromSuperviewWithoutNeedingDisplay];
    [o_prev_btn release];
    o_prev_btn = NULL;
    [o_next_btn release];
    o_next_btn = NULL;

    NSRect frame;
    frame = [o_bwd_btn frame];
    frame.size.width++;
    [o_bwd_btn setFrame:frame];
    frame = [o_fwd_btn frame];
    frame.size.width++;
    [o_fwd_btn setFrame:frame];

#define moveItem(item) \
frame = [item frame]; \
frame.origin.x = frame.origin.x - f_space; \
if (b_fast) \
    [item setFrame: frame]; \
else \
    [[item animator] setFrame: frame]

    float f_space = 29.;
    moveItem(o_bwd_btn);
    f_space = 28.;
    moveItem(o_play_btn);
    moveItem(o_fwd_btn);
    f_space = 28. * 2;
    moveItem(o_stop_btn);
    moveItem(o_playlist_btn);
    moveItem(o_repeat_btn);
    moveItem(o_shuffle_btn);
#undef moveItem

    frame = [o_progress_view frame];
    frame.size.width = frame.size.width + f_space;
    frame.origin.x = frame.origin.x - f_space;
    if (b_fast)
        [o_progress_view setFrame: frame];
    else
        [[o_progress_view animator] setFrame: frame];

    if (b_dark_interface) {
        [[o_fwd_btn animator] setImage:imageFromRes(@"forward-3btns-dark")];
        [[o_fwd_btn animator] setAlternateImage:imageFromRes(@"forward-3btns-dark-pressed")];
        [[o_bwd_btn animator] setImage:imageFromRes(@"backward-3btns-dark")];
        [[o_bwd_btn animator] setAlternateImage:imageFromRes(@"backward-3btns-dark-pressed")];
    } else {
        [[o_fwd_btn animator] setImage:imageFromRes(@"forward-3btns")];
        [[o_fwd_btn animator] setAlternateImage:imageFromRes(@"forward-3btns-pressed")];
        [[o_bwd_btn animator] setImage:imageFromRes(@"backward-3btns")];
        [[o_bwd_btn animator] setAlternateImage:imageFromRes(@"backward-3btns-pressed")];
    }

    [self toggleForwardBackwardMode: NO];

    [o_bottombar_view setNeedsDisplay:YES];
}

- (void)togglePlaymodeButtons
{
    b_show_playmode_buttons = config_GetInt(VLCIntf, "macosx-show-playmode-buttons");

    if (b_show_playmode_buttons)
        [self addPlaymodeButtons:NO];
    else
        [self removePlaymodeButtons:NO];
}

- (void)addPlaymodeButtons:(BOOL)b_fast
{
    NSRect frame;
    CGFloat f_space = [o_repeat_btn frame].size.width + [o_shuffle_btn frame].size.width - 6.;

    if (b_dark_interface) {
        [[o_playlist_btn animator] setImage:imageFromRes(@"playlist_dark")];
        [[o_playlist_btn animator] setAlternateImage:imageFromRes(@"playlist-pressed_dark")];
    } else {
        [[o_playlist_btn animator] setImage:imageFromRes(@"playlist-btn")];
        [[o_playlist_btn animator] setAlternateImage:imageFromRes(@"playlist-btn-pressed")];
    }
    frame = [o_playlist_btn frame];
    frame.size.width--;
    [o_playlist_btn setFrame:frame];

    if (b_fast) {
        [o_repeat_btn setHidden: NO];
        [o_shuffle_btn setHidden: NO];
    } else {
        [[o_repeat_btn animator] setHidden: NO];
        [[o_shuffle_btn animator] setHidden: NO];
    }

    frame = [o_progress_view frame];
    frame.size.width = frame.size.width - f_space;
    frame.origin.x = frame.origin.x + f_space;
    if (b_fast)
        [o_progress_view setFrame: frame];
    else
        [[o_progress_view animator] setFrame: frame];
}

- (void)removePlaymodeButtons:(BOOL)b_fast
{
    NSRect frame;
    CGFloat f_space = [o_repeat_btn frame].size.width + [o_shuffle_btn frame].size.width - 6.;
    [o_repeat_btn setHidden: YES];
    [o_shuffle_btn setHidden: YES];

    if (b_dark_interface) {
        [[o_playlist_btn animator] setImage:imageFromRes(@"playlist-1btn-dark")];
        [[o_playlist_btn animator] setAlternateImage:imageFromRes(@"playlist-1btn-dark-pressed")];
    } else {
        [[o_playlist_btn animator] setImage:imageFromRes(@"playlist-1btn")];
        [[o_playlist_btn animator] setAlternateImage:imageFromRes(@"playlist-1btn-pressed")];
    }
    frame = [o_playlist_btn frame];
    frame.size.width++;
    [o_playlist_btn setFrame:frame];

    frame = [o_progress_view frame];
    frame.size.width = frame.size.width + f_space;
    frame.origin.x = frame.origin.x - f_space;
    if (b_fast)
        [o_progress_view setFrame: frame];
    else
        [[o_progress_view animator] setFrame: frame];
}

#pragma mark -
#pragma mark Extra button actions

- (IBAction)stop:(id)sender
{
    [[VLCCoreInteraction sharedInstance] stop];
}

// dynamically created next / prev buttons
- (IBAction)prev:(id)sender
{
    [[VLCCoreInteraction sharedInstance] previous];
}

- (IBAction)next:(id)sender
{
    [[VLCCoreInteraction sharedInstance] next];
}

- (void)setRepeatOne
{
    [o_repeat_btn setImage: o_repeat_one_img];
    [o_repeat_btn setAlternateImage: o_repeat_one_pressed_img];
}

- (void)setRepeatAll
{
    [o_repeat_btn setImage: o_repeat_all_img];
    [o_repeat_btn setAlternateImage: o_repeat_all_pressed_img];
}

- (void)setRepeatOff
{
    [o_repeat_btn setImage: o_repeat_img];
    [o_repeat_btn setAlternateImage: o_repeat_pressed_img];
}

- (IBAction)repeat:(id)sender
{
    vlc_value_t looping,repeating;
    intf_thread_t * p_intf = VLCIntf;
    playlist_t * p_playlist = pl_Get(p_intf);

    var_Get(p_playlist, "repeat", &repeating);
    var_Get(p_playlist, "loop", &looping);

    if (!repeating.b_bool && !looping.b_bool) {
        /* was: no repeating at all, switching to Repeat One */
        [[VLCCoreInteraction sharedInstance] repeatOne];
        [self setRepeatOne];
    }
    else if (repeating.b_bool && !looping.b_bool) {
        /* was: Repeat One, switching to Repeat All */
        [[VLCCoreInteraction sharedInstance] repeatAll];
        [self setRepeatAll];
    } else {
        /* was: Repeat All or bug in VLC, switching to Repeat Off */
        [[VLCCoreInteraction sharedInstance] repeatOff];
        [self setRepeatOff];
    }
}

- (void)setShuffle
{
    bool b_value;
    playlist_t *p_playlist = pl_Get(VLCIntf);
    b_value = var_GetBool(p_playlist, "random");

    if (b_value) {
        [o_shuffle_btn setImage: o_shuffle_on_img];
        [o_shuffle_btn setAlternateImage: o_shuffle_on_pressed_img];
    } else {
        [o_shuffle_btn setImage: o_shuffle_img];
        [o_shuffle_btn setAlternateImage: o_shuffle_pressed_img];
    }
}

- (IBAction)shuffle:(id)sender
{
    [[VLCCoreInteraction sharedInstance] shuffle];
    [self setShuffle];
}

- (IBAction)togglePlaylist:(id)sender
{
    [[[VLCMain sharedInstance] mainWindow] changePlaylistState: psUserEvent];
}

- (IBAction)volumeAction:(id)sender
{
    if (sender == o_volume_sld)
        [[VLCCoreInteraction sharedInstance] setVolume: [sender intValue]];
    else if (sender == o_volume_down_btn)
        [[VLCCoreInteraction sharedInstance] toggleMute];
    else
        [[VLCCoreInteraction sharedInstance] setVolume: AOUT_VOLUME_MAX];
}

- (IBAction)effects:(id)sender
{
    [[VLCMainMenu sharedInstance] showAudioEffects: sender];
}

#pragma mark -
#pragma mark Extra updaters

- (void)updateVolumeSlider
{
    int i_volume = [[VLCCoreInteraction sharedInstance] volume];
    BOOL b_muted = [[VLCCoreInteraction sharedInstance] mute];

    if (!b_muted)
        [o_volume_sld setIntValue: i_volume];
    else
        [o_volume_sld setIntValue: 0];

    [o_volume_sld setEnabled: !b_muted];
    [o_volume_up_btn setEnabled: !b_muted];
}

- (void)updateControls
{
    [super updateControls];

    bool b_input = false;
    bool b_seekable = false;
    bool b_plmul = false;
    bool b_control = false;
    bool b_chapters = false;

    playlist_t * p_playlist = pl_Get(VLCIntf);

    PL_LOCK;
    b_plmul = playlist_CurrentSize(p_playlist) > 1;
    PL_UNLOCK;

    input_thread_t * p_input = playlist_CurrentInput(p_playlist);
    if ((b_input = (p_input != NULL))) {
        /* seekable streams */
        b_seekable = var_GetBool(p_input, "can-seek");

        /* check whether slow/fast motion is possible */
        b_control = var_GetBool(p_input, "can-rate");

        /* chapters & titles */
        //FIXME! b_chapters = p_input->stream.i_area_nb > 1;

        vlc_object_release(p_input);
    }

    [o_stop_btn setEnabled: b_input];

    if (b_show_jump_buttons) {
        [o_prev_btn setEnabled: (b_seekable || b_plmul || b_chapters)];
        [o_next_btn setEnabled: (b_seekable || b_plmul || b_chapters)];
    }

    [[VLCMainMenu sharedInstance] setRateControlsEnabled: b_control];
}

- (void)dealloc {
    [o_repeat_img release];
    [o_repeat_pressed_img release];
    [o_repeat_all_img release];
    [o_repeat_all_pressed_img release];
    [o_repeat_one_img release];
    [o_repeat_one_pressed_img release];
    [o_shuffle_img release];
    [o_shuffle_pressed_img release];
    [o_shuffle_on_img release];
    [o_shuffle_on_pressed_img release];
    [super dealloc];
}

@end