]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/ControlsBar.m
macosx: hide bottom bar of main window only when really necessary
[vlc] / modules / gui / macosx / ControlsBar.m
index 1057341a513a6f65c4517a64852c876cb656b669..15a5a979380d7b5425d1dfdc266914b6da0699d0 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * ControlsBar.m: MacOS X interface module
  *****************************************************************************
- * Copyright (C) 2012 VLC authors and VideoLAN
+ * Copyright (C) 2012-2013 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
@@ -28,8 +28,6 @@
 #import "MainMenu.h"
 #import "fspanel.h"
 
-#import <vlc_aout_intf.h>
-
 /*****************************************************************************
  * VLCControlsBarCommon
  *
     [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: [NSImage imageNamed:@"bottom-background"] middle: [NSImage imageNamed:@"bottom-background"] right: [NSImage imageNamed:@"bottom-background"]];
 
         o_pause_pressed_img = [[NSImage imageNamed:@"pause-pressed"] retain];
         [o_fwd_btn setImage: [NSImage imageNamed:@"forward-3btns"]];
         [o_fwd_btn setAlternateImage: [NSImage imageNamed:@"forward-3btns-pressed"]];
-        
+
         [o_time_sld_background setImagesLeft: [NSImage imageNamed:@"progression-track-wrapper-left"] middle: [NSImage imageNamed:@"progression-track-wrapper-middle"] right: [NSImage imageNamed:@"progression-track-wrapper-right"]];
         [o_time_sld_fancygradient_view setImagesLeft:[NSImage imageNamed:@"progression-fill-left"] middle:[NSImage imageNamed:@"progression-fill-middle"] right:[NSImage imageNamed:@"progression-fill-right"]];
 
         [o_fullscreen_btn setImage: [NSImage imageNamed:@"fullscreen-one-button"]];
         [o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"fullscreen-one-button-pressed"]];
-
     } else {
         [o_bottombar_view setImagesLeft: [NSImage imageNamed:@"bottomdark-left"] middle: [NSImage imageNamed:@"bottom-background_dark"] right: [NSImage imageNamed:@"bottomdark-right"]];
 
 
         [o_fullscreen_btn setImage: [NSImage imageNamed:@"fullscreen-one-button-pressed_dark"]];
         [o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"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) {
     if (!OSX_SNOW_LEOPARD)
         [o_resize_view setImage: NULL];
 
-    if ([o_associated_window styleMask] & NSResizableWindowMask)
+    if ([[o_bottombar_view window] styleMask] & NSResizableWindowMask)
         [o_resize_view removeFromSuperviewWithoutNeedingDisplay];
 
+    
+    // remove fullscreen button for lion fullscreen
+    if (b_nativeFullscreenMode) {
+        float 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];
+    }
+
 }
 
 #pragma mark -
 
 - (IBAction)play:(id)sender
 {
-    [[VLCCoreInteraction sharedInstance] play];
+    [[VLCCoreInteraction sharedInstance] playOrPause];
 }
 
 - (void)resetPreviousButton
                 [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];
     }
 
         /* chapters & titles */
         //FIXME! b_chapters = p_input->stream.i_area_nb > 1;
-        
+
         vlc_object_release(p_input);
     }
 
 
 - (void)setFullscreenState:(BOOL)b_fullscreen
 {
-    [o_fullscreen_btn setState:b_fullscreen];
+    if (!b_nativeFullscreenMode)
+        [o_fullscreen_btn setState:b_fullscreen];
 }
 
 @end
  *  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_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("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];
         [o_volume_down_btn setImage: [NSImage imageNamed:@"volume-low"]];
         [o_volume_track_view setImage: [NSImage imageNamed:@"volume-slider-track"]];
         [o_volume_up_btn setImage: [NSImage imageNamed:@"volume-high"]];
-        
+
         if (b_nativeFullscreenMode) {
             [o_effects_btn setImage: [NSImage imageNamed:@"effects-one-button"]];
             [o_effects_btn setAlternateImage: [NSImage imageNamed:@"effects-one-button-pressed"]];
 
         [o_fullscreen_btn setImage: [NSImage imageNamed:@"fullscreen-double-buttons"]];
         [o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"fullscreen-double-buttons-pressed"]];
-
     } else {
         [o_stop_btn setImage: [NSImage imageNamed:@"stop_dark"]];
         [o_stop_btn setAlternateImage: [NSImage imageNamed:@"stop-pressed_dark"]];
-        
+
         [o_playlist_btn setImage: [NSImage imageNamed:@"playlist_dark"]];
         [o_playlist_btn setAlternateImage: [NSImage imageNamed:@"playlist-pressed_dark"]];
         o_repeat_img = [[NSImage imageNamed:@"repeat_dark"] retain];
         [o_volume_down_btn setImage: [NSImage imageNamed:@"volume-low_dark"]];
         [o_volume_track_view setImage: [NSImage imageNamed:@"volume-slider-track_dark"]];
         [o_volume_up_btn setImage: [NSImage imageNamed:@"volume-high_dark"]];
-        
+
         if (b_nativeFullscreenMode) {
             [o_effects_btn setImage: [NSImage imageNamed:@"effects-one-button_dark"]];
-            [o_effects_btn setAlternateImage: [NSImage imageNamed:@"effects-one-button-blue_dark"]];
+            [o_effects_btn setAlternateImage: [NSImage imageNamed:@"effects-one-button-pressed-dark"]];
         } else {
             [o_effects_btn setImage: [NSImage imageNamed:@"effects-double-buttons_dark"]];
             [o_effects_btn setAlternateImage: [NSImage imageNamed:@"effects-double-buttons-pressed_dark"]];
     [o_volume_sld setEnabled: b_mute];
     [o_volume_up_btn setEnabled: b_mute];
 
+
     // remove fullscreen button for lion fullscreen
     if (b_nativeFullscreenMode) {
-
         NSRect frame;
-        float f_width = [o_fullscreen_btn frame].size.width;
 
+        // == [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; \
@@ -503,15 +527,11 @@ frame.origin.x = f_width + frame.origin.x; \
         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 = f_width + frame.size.width;
-        [o_progress_view setFrame: frame];
-
-        [o_fullscreen_btn removeFromSuperviewWithoutNeedingDisplay];
+        // 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)
@@ -522,6 +542,7 @@ frame.origin.x = f_width + frame.origin.x; \
         [self removePlaymodeButtons:YES];
 
     [[VLCMain sharedInstance] playbackModeUpdated];
+
 }
 
 #pragma mark -
@@ -582,26 +603,26 @@ frame.origin.x = f_width + frame.origin.x; \
 
     NSRect frame;
     frame = [o_bwd_btn frame];
-    frame.size.width++;
+    frame.size.width--;
     [o_bwd_btn setFrame:frame];
     frame = [o_fwd_btn frame];
-    frame.size.width++;
+    frame.size.width--;
     [o_fwd_btn setFrame:frame];
 
-    float f_space = 29.;
 #define moveItem(item) \
 frame = [item frame]; \
 frame.origin.x = frame.origin.x + f_space; \
 if (b_fast) \
-[item setFrame: frame]; \
+    [item setFrame: frame]; \
 else \
-[[item animator] setFrame: frame]
-
+    [[item animator] setFrame: frame]
+    
+    float f_space = 29.;
     moveItem(o_bwd_btn);
-    moveItem(o_play_btn);
     f_space = 28.;
+    moveItem(o_play_btn);
     moveItem(o_fwd_btn);
-    f_space = 57.;
+    f_space = 28. * 2;
     moveItem(o_stop_btn);
     moveItem(o_playlist_btn);
     moveItem(o_repeat_btn);
@@ -628,7 +649,7 @@ else \
         [[o_bwd_btn animator] setAlternateImage:[NSImage imageNamed:@"backward-6btns-pressed"]];
     }
 
-    preliminaryFrame.origin.x = [o_next_btn frame].origin.x + 82. + [o_fwd_btn frame].size.width;
+    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
@@ -659,7 +680,9 @@ else \
     [o_prev_btn removeFromSuperviewWithoutNeedingDisplay];
     [o_next_btn removeFromSuperviewWithoutNeedingDisplay];
     [o_prev_btn release];
+    o_prev_btn = NULL;
     [o_next_btn release];
+    o_next_btn = NULL;
 
     /* 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];
@@ -667,26 +690,26 @@ else \
 
     NSRect frame;
     frame = [o_bwd_btn frame];
-    frame.size.width--;
+    frame.size.width++;
     [o_bwd_btn setFrame:frame];
     frame = [o_fwd_btn frame];
-    frame.size.width--;
+    frame.size.width++;
     [o_fwd_btn setFrame:frame];
 
-    float f_space = 29.;
 #define moveItem(item) \
 frame = [item frame]; \
 frame.origin.x = frame.origin.x - f_space; \
 if (b_fast) \
-[item setFrame: frame]; \
+    [item setFrame: frame]; \
 else \
-[[item animator] setFrame: frame]
+    [[item animator] setFrame: frame]
 
+    float f_space = 29.;
     moveItem(o_bwd_btn);
-    moveItem(o_play_btn);
     f_space = 28.;
+    moveItem(o_play_btn);
     moveItem(o_fwd_btn);
-    f_space = 57.;
+    f_space = 28. * 2;
     moveItem(o_stop_btn);
     moveItem(o_playlist_btn);
     moveItem(o_repeat_btn);
@@ -808,6 +831,16 @@ else \
     [[VLCCoreInteraction sharedInstance] next];
 }
 
+// alternative actions for forward / backward buttons when next / prev are activated
+- (IBAction)forward:(id)sender
+{
+    [[VLCCoreInteraction sharedInstance] forwardExtraShort];
+}
+
+- (IBAction)backward:(id)sender
+{
+    [[VLCCoreInteraction sharedInstance] backwardExtraShort];
+}
 
 - (void)setRepeatOne
 {
@@ -896,9 +929,9 @@ else \
     int i_volume = [[VLCCoreInteraction sharedInstance] volume];
     BOOL b_muted = [[VLCCoreInteraction sharedInstance] mute];
 
-    if (!b_muted) {
+    if (!b_muted)
         [o_volume_sld setIntValue: i_volume];
-    else
+    else
         [o_volume_sld setIntValue: 0];
 
     [o_volume_sld setEnabled: !b_muted];
@@ -939,7 +972,7 @@ else \
 
         /* chapters & titles */
         //FIXME! b_chapters = p_input->stream.i_area_nb > 1;
-        
+
         vlc_object_release(p_input);
     }
 
@@ -963,9 +996,4 @@ else \
     [[VLCMainMenu sharedInstance] setRateControlsEnabled: b_control];
 }
 
-- (void)updatePosAndTimeInFSPanel:(VLCFSPanel *)o_fspanel
-{
-    [o_fspanel setStreamPos:[o_time_sld floatValue] andTime: [o_time_fld stringValue]];
-}
-
-@end
\ No newline at end of file
+@end