1
mirror of https://code.videolan.org/videolan/vlc synced 2024-08-18 23:45:06 +02:00

macosx: re-add volume slider and stop button to main window

This commit removes a lot of legacy code for control bar customization which is no longer desired in v4.
This commit is contained in:
Felix Paul Kühne 2019-05-29 18:31:55 +02:00
parent 3fbd27c8db
commit 5d8def777f
11 changed files with 125 additions and 458 deletions

View File

@ -145,9 +145,6 @@
<outlet property="teletext_yellow" destination="5500" id="auC-nl-mJx"/>
<outlet property="title" destination="5148" id="HFs-7N-MNr"/>
<outlet property="titleMenu" destination="5159" id="Akr-s6-bqw"/>
<outlet property="toggleEffectsButton" destination="5537" id="Gg8-nl-gzx"/>
<outlet property="toggleJumpButtons" destination="5240" id="53V-UC-536"/>
<outlet property="togglePlaymodeButtons" destination="5242" id="9TB-F7-ttT"/>
<outlet property="trackSynchronization" destination="4412" id="BHW-NJ-jbd"/>
<outlet property="videoMenu" destination="334" id="7Ri-Tc-yej"/>
<outlet property="videoeffects" destination="2390" id="fXe-JA-9GI"/>
@ -369,24 +366,6 @@
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="View" id="5238">
<items>
<menuItem title="Show Previous &amp; Next Buttons" id="5240">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleJumpButtons:" target="-2" id="rFJ-9Z-m4G"/>
</connections>
</menuItem>
<menuItem title="Show Shuffle &amp; Repeat Buttons" id="5242">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="togglePlaymodeButtons:" target="-2" id="p7O-r4-WDX"/>
</connections>
</menuItem>
<menuItem title="Show Audio Effects Button" id="5537">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleEffectsButton:" target="-2" id="QSm-2E-Nlo"/>
</connections>
</menuItem>
<menuItem title="Show Library Folders..." id="5413">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>

View File

@ -28,9 +28,9 @@
<rect key="frame" x="0.0" y="46" width="256" height="168"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="dFt-oZ-h9P" customClass="VLCLinearProgressIndicator">
<rect key="frame" x="0.0" y="0.0" width="256" height="10"/>
<rect key="frame" x="0.0" y="0.0" width="256" height="4"/>
<constraints>
<constraint firstAttribute="height" constant="10" id="lyQ-kl-gVk"/>
<constraint firstAttribute="height" constant="4" id="lyQ-kl-gVk"/>
</constraints>
</customView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="S3I-5Z-qgS">

View File

@ -272,7 +272,7 @@
</constraints>
</customView>
<slider hidden="YES" horizontalHuggingPriority="200" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9Hg-t2-K5z" customClass="VLCSlider">
<rect key="frame" x="101" y="10" width="274" height="16"/>
<rect key="frame" x="134" y="10" width="161" height="16"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="4YR-vo-ZfK"/>
</constraints>
@ -284,7 +284,7 @@
</connections>
</slider>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="oGd-mG-cFw" customClass="VLCTimeField">
<rect key="frame" x="381" y="12" width="56" height="13"/>
<rect key="frame" x="301" y="12" width="56" height="13"/>
<constraints>
<constraint firstAttribute="height" constant="13" id="ZpD-fD-qke"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="52" id="aOU-Hc-ufI"/>
@ -309,17 +309,74 @@
<action selector="fullscreen:" target="Uzf-Tf-H8x" id="ayV-qE-Nmy"/>
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="IAy-58-UPp">
<rect key="frame" x="363" y="13" width="5" height="11"/>
<constraints>
<constraint firstAttribute="height" constant="11" id="VxM-zR-jQR"/>
</constraints>
<buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="volume-low" imagePosition="only" alignment="center" id="qTN-dX-Oj5">
<behavior key="behavior" lightByContents="YES"/>
<font key="font" metaFont="label"/>
</buttonCell>
<connections>
<action selector="volumeAction:" target="Uzf-Tf-H8x" id="ugn-Py-dV8"/>
</connections>
</button>
<slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="noz-yJ-oH4" customClass="VLCVolumeSlider">
<rect key="frame" x="371" y="11" width="48" height="13"/>
<constraints>
<constraint firstAttribute="width" constant="48" id="EM2-Hh-lqK"/>
</constraints>
<sliderCell key="cell" controlSize="mini" continuous="YES" alignment="left" maxValue="512" doubleValue="251.95348837209303" tickMarkPosition="above" sliderType="linear" id="IIu-VN-bEm" customClass="VLCVolumeSliderCell"/>
<connections>
<action selector="volumeAction:" target="Uzf-Tf-H8x" id="am0-Zu-eBs"/>
</connections>
</slider>
<button translatesAutoresizingMaskIntoConstraints="NO" id="75c-FF-mgb">
<rect key="frame" x="422" y="13" width="13" height="11"/>
<constraints>
<constraint firstAttribute="height" constant="11" id="Kt0-WP-qU0"/>
</constraints>
<buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="volume-high" imagePosition="only" alignment="center" id="a9Z-7I-lXJ">
<behavior key="behavior" lightByContents="YES"/>
<font key="font" metaFont="label"/>
</buttonCell>
<connections>
<action selector="volumeAction:" target="Uzf-Tf-H8x" id="8aL-jE-MXa"/>
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="cEC-SX-pks">
<rect key="frame" x="97" y="7" width="29" height="23"/>
<constraints>
<constraint firstAttribute="height" constant="23" id="VRF-YR-kTr"/>
</constraints>
<buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="stop" imagePosition="only" alignment="center" alternateImage="stop-pressed" enabled="NO" id="NEI-Es-D2A">
<behavior key="behavior" lightByContents="YES"/>
<font key="font" metaFont="label"/>
</buttonCell>
<connections>
<action selector="stop:" target="Uzf-Tf-H8x" id="kMO-P8-eOG"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="9Hg-t2-K5z" firstAttribute="leading" secondItem="cEC-SX-pks" secondAttribute="trailing" constant="8" id="1kG-GO-EmC"/>
<constraint firstItem="9Hg-t2-K5z" firstAttribute="centerY" secondItem="MQH-bI-Zdh" secondAttribute="centerY" id="3I8-IC-m3C"/>
<constraint firstItem="SUi-Nm-KtK" firstAttribute="centerY" secondItem="MQH-bI-Zdh" secondAttribute="centerY" id="7SA-kP-WYu"/>
<constraint firstItem="dwM-Uz-pAw" firstAttribute="leading" secondItem="noz-yJ-oH4" secondAttribute="trailing" constant="24" id="A2S-l6-Vfg"/>
<constraint firstItem="dwM-Uz-pAw" firstAttribute="centerY" secondItem="oGd-mG-cFw" secondAttribute="centerY" id="Brc-26-tG5"/>
<constraint firstItem="9Hg-t2-K5z" firstAttribute="leading" secondItem="SUi-Nm-KtK" secondAttribute="trailing" constant="8" id="FtG-eC-1xc"/>
<constraint firstItem="cEC-SX-pks" firstAttribute="leading" secondItem="i34-50-c7o" secondAttribute="trailing" constant="4" id="FTA-il-NCk"/>
<constraint firstItem="75c-FF-mgb" firstAttribute="centerY" secondItem="noz-yJ-oH4" secondAttribute="centerY" id="HVh-uV-Ovg"/>
<constraint firstItem="cEC-SX-pks" firstAttribute="centerY" secondItem="i34-50-c7o" secondAttribute="centerY" id="KwV-AE-eNt"/>
<constraint firstItem="noz-yJ-oH4" firstAttribute="leading" secondItem="IAy-58-UPp" secondAttribute="trailing" constant="3" id="TH8-V3-URc"/>
<constraint firstAttribute="trailing" secondItem="dwM-Uz-pAw" secondAttribute="trailing" constant="8" id="UeR-IT-Q50"/>
<constraint firstItem="75c-FF-mgb" firstAttribute="leading" secondItem="noz-yJ-oH4" secondAttribute="trailing" constant="3" id="Uqf-cR-gMY"/>
<constraint firstItem="IAy-58-UPp" firstAttribute="centerY" secondItem="noz-yJ-oH4" secondAttribute="centerY" id="V9R-uE-YMc"/>
<constraint firstItem="SUi-Nm-KtK" firstAttribute="leading" secondItem="MQH-bI-Zdh" secondAttribute="leading" constant="8" id="Wgx-gy-pkh"/>
<constraint firstItem="oGd-mG-cFw" firstAttribute="leading" secondItem="9Hg-t2-K5z" secondAttribute="trailing" constant="8" id="ZEi-tc-qH8"/>
<constraint firstItem="dwM-Uz-pAw" firstAttribute="leading" secondItem="oGd-mG-cFw" secondAttribute="trailing" constant="8" symbolic="YES" id="ZWE-GB-jJp"/>
<constraint firstItem="dwM-Uz-pAw" firstAttribute="centerY" secondItem="MQH-bI-Zdh" secondAttribute="centerY" id="rld-Zd-Lbn"/>
<constraint firstItem="IAy-58-UPp" firstAttribute="leading" secondItem="oGd-mG-cFw" secondAttribute="trailing" constant="8" id="sUV-dY-Ewu"/>
<constraint firstItem="noz-yJ-oH4" firstAttribute="centerY" secondItem="MQH-bI-Zdh" secondAttribute="centerY" id="w6O-Hd-4Hv"/>
</constraints>
</customView>
</subviews>
@ -373,7 +430,7 @@
</connections>
<point key="canvasLocation" x="139" y="204.5"/>
</window>
<customObject id="Uzf-Tf-H8x" userLabel="Detached Window Controls Bar" customClass="VLCControlsBarCommon">
<customObject id="Uzf-Tf-H8x" userLabel="Detached Window Controls Bar" customClass="VLCMainWindowControlsBar">
<connections>
<outlet property="backwardButton" destination="Agm-yD-Chm" id="SZH-kZ-MBk"/>
<outlet property="bottomBarView" destination="vUy-jt-gjY" id="WqX-SW-mpv"/>
@ -381,8 +438,12 @@
<outlet property="forwardButton" destination="i34-50-c7o" id="b5w-NB-g4X"/>
<outlet property="fullscreenButton" destination="dwM-Uz-pAw" id="gXA-WS-Gig"/>
<outlet property="playButton" destination="Pa9-uC-URK" id="8cD-Sr-Uht"/>
<outlet property="stopButton" destination="cEC-SX-pks" id="AJE-gb-v0o"/>
<outlet property="timeField" destination="oGd-mG-cFw" id="GwZ-Mm-ZSb"/>
<outlet property="timeSlider" destination="9Hg-t2-K5z" id="sVe-s8-xW6"/>
<outlet property="volumeDownButton" destination="IAy-58-UPp" id="dDN-pE-Vmj"/>
<outlet property="volumeSlider" destination="noz-yJ-oH4" id="nbe-1c-lFH"/>
<outlet property="volumeUpButton" destination="75c-FF-mgb" id="xRz-F4-n0Z"/>
</connections>
</customObject>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="0.0" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" id="vak-Gp-ljo">
@ -750,5 +811,9 @@
<image name="play-pressed" width="27" height="23"/>
<image name="repeatOff" width="24" height="24"/>
<image name="shuffleOn" width="24" height="24"/>
<image name="stop" width="29" height="23"/>
<image name="stop-pressed" width="29" height="23"/>
<image name="volume-high" width="13" height="11"/>
<image name="volume-low" width="5" height="11"/>
</resources>
</document>

View File

@ -108,15 +108,6 @@ int WindowOpen (vout_window_t *);
#define DIM_KEYBOARD_PLAYBACK_TEXT N_("Dim keyboard backlight during fullscreen playback")
#define DIM_KEYBOARD_PLAYBACK_LONGTEXT N_("Turn off the MacBook keyboard backlight while a video is playing in fullscreen. Automatic brightness adjustment should be disabled in System Preferences.")
#define JUMPBUTTONS_TEXT N_("Show Previous & Next Buttons")
#define JUMPBUTTONS_LONGTEXT N_("Shows the previous and next buttons in the main window.")
#define PLAYMODEBUTTONS_TEXT N_("Show Shuffle & Repeat Buttons")
#define PLAYMODEBUTTONS_LONGTEXT N_("Shows the shuffle and repeat buttons in the main window.")
#define EFFECTSBUTTON_TEXT N_("Show Audio Effects Button")
#define EFFECTSBUTTON_LONGTEXT N_("Shows the audio effects button in the main window.")
#define ITUNES_TEXT N_("Control external music players")
#define ITUNES_LONGTEXT N_("VLC will pause and resume supported music players on playback.")
@ -152,9 +143,6 @@ vlc_module_begin()
add_bool("macosx-nativefullscreenmode", false, NATIVE_FULLSCREEN_MODE_ON_LION_TEXT, NATIVE_FULLSCREEN_MODE_ON_LION_LONGTEXT, false)
add_bool("macosx-statusicon", true, DISPLAY_STATUS_ICONMENU_TEXT, DISPLAY_STATUS_ICONMENU_LONGTEXT, false)
add_bool("macosx-icon-change", true, ICONCHANGE_TEXT, ICONCHANGE_LONGTEXT, true)
add_bool("macosx-show-playback-buttons", false, JUMPBUTTONS_TEXT, JUMPBUTTONS_LONGTEXT, false)
add_bool("macosx-show-playmode-buttons", false, PLAYMODEBUTTONS_TEXT, PLAYMODEBUTTONS_LONGTEXT, false)
add_bool("macosx-show-effects-button", false, EFFECTSBUTTON_TEXT, EFFECTSBUTTON_LONGTEXT, false)
add_integer_with_range("macosx-max-volume", 125, 60, 200, VOLUME_MAX_TEXT, VOLUME_MAX_TEXT, true)
add_bool("macosx-large-text", false, LARGE_LISTFONT_TEXT, LARGE_LISTFONT_TEXT, false)
@ -182,6 +170,9 @@ vlc_module_begin()
add_obsolete_bool("macosx-autosave-volume") /* since 2.1.0 */
add_obsolete_bool("macosx-show-sidebar") /* since 3.0.1 */
add_obsolete_bool("macosx-interfacestyle") /* since 4.0.0 */
add_obsolete_bool("macosx-show-playmode-buttons") /* since 4.0.0 */
add_obsolete_bool("macosx-show-playback-buttons") /* since 4.0.0 */
add_obsolete_bool("macosx-show-effects-button") /* since 4.0.0 */
add_submodule()
set_description("Mac OS X Video Output Provider")

View File

@ -211,8 +211,6 @@
- (void)releaseRepresentedObjects:(NSMenu *)the_menu;
- (void)setRateControlsEnabled:(BOOL)b_enabled;
- (IBAction)openAddonManager:(id)sender;
- (IBAction)intfOpenFile:(id)sender;
@ -222,9 +220,6 @@
- (IBAction)intfOpenCapture:(id)sender;
- (IBAction)savePlaylist:(id)sender;
- (IBAction)toggleEffectsButton:(id)sender;
- (IBAction)toggleJumpButtons:(id)sender;
- (IBAction)togglePlaymodeButtons:(id)sender;
- (IBAction)showLibraryFolders:(id)sender;
- (IBAction)play:(id)sender;

View File

@ -365,12 +365,6 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
[_findItem setTitle: _NS("Find")];
[_viewMenu setTitle: _NS("View")];
[_toggleJumpButtons setTitle: _NS("Show Previous & Next Buttons")];
[_toggleJumpButtons setState: var_InheritBool(getIntf(), "macosx-show-playback-buttons")];
[_togglePlaymodeButtons setTitle: _NS("Show Shuffle & Repeat Buttons")];
[_togglePlaymodeButtons setState: var_InheritBool(getIntf(), "macosx-show-playmode-buttons")];
[_toggleEffectsButton setTitle: _NS("Show Audio Effects Button")];
[_toggleEffectsButton setState: var_InheritBool(getIntf(), "macosx-show-effects-button")];
[_showLibraryFolders setTitle: _NS("Show Library Folders...")];
[_playlistTableColumns setTitle: _NS("Playlist Table Columns")];
@ -660,9 +654,12 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
[_postprocessing setEnabled:YES];
[self setSubmenusEnabled:YES];
input_item_Release(p_mediaItem);
[self setRateControlsEnabled:_playerController.rateChangable];
} else {
[_postprocessing setEnabled:NO];
[self setSubmenusEnabled:NO];
[self setRateControlsEnabled:NO];
}
}
@ -736,35 +733,6 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
#pragma mark - View
- (IBAction)toggleEffectsButton:(id)sender
{
BOOL b_value = !var_InheritBool(getIntf(), "macosx-show-effects-button");
config_PutInt("macosx-show-effects-button", b_value);
[(VLCMainWindowControlsBar *)[[[VLCMain sharedInstance] libraryWindow] controlsBar] toggleEffectsButton];
[_toggleEffectsButton setState: b_value];
}
- (IBAction)toggleJumpButtons:(id)sender
{
BOOL b_value = !var_InheritBool(getIntf(), "macosx-show-playback-buttons");
config_PutInt("macosx-show-playback-buttons", b_value);
[(VLCMainWindowControlsBar *)[[[VLCMain sharedInstance] libraryWindow] controlsBar] toggleJumpButtons];
[[[VLCMain sharedInstance] voutProvider] updateWindowsUsingBlock:^(VLCVideoWindowCommon *window) {
[[window controlsBar] toggleForwardBackwardMode: b_value];
}];
[_toggleJumpButtons setState: b_value];
}
- (IBAction)togglePlaymodeButtons:(id)sender
{
BOOL b_value = !var_InheritBool(getIntf(), "macosx-show-playmode-buttons");
config_PutInt("macosx-show-playmode-buttons", b_value);
[(VLCMainWindowControlsBar *)[[[VLCMain sharedInstance] libraryWindow] controlsBar] togglePlaymodeButtons];
[_togglePlaymodeButtons setState: b_value];
}
- (IBAction)showLibraryFolders:(id)sender
{
if (!_libraryFoldersController) {

View File

@ -1658,12 +1658,12 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = {
- (void)incrementVolume
{
vlc_player_aout_SetVolume(_p_player, _volume + 0.05);
vlc_player_aout_IncrementVolume(_p_player, 1, NULL);
}
- (void)decrementVolume
{
vlc_player_aout_SetVolume(_p_player, _volume - 0.05);
vlc_player_aout_DecrementVolume(_p_player, 1, NULL);
}
- (void)muteChanged:(BOOL)mute

View File

@ -54,7 +54,6 @@
@property (readonly) BOOL nativeFullscreenMode;
- (CGFloat)height;
- (void)toggleForwardBackwardMode:(BOOL)b_alt;
- (IBAction)play:(id)sender;
- (IBAction)bwd:(id)sender;

View File

@ -109,7 +109,10 @@
[self.playButton setImage: _playImage];
[self.playButton setAlternateImage: _pressedPlayImage];
NSColor *timeFieldTextColor = [NSColor colorWithCalibratedRed:0.64 green:0.64 blue:0.64 alpha:100.0];
[self.timeSlider setHidden:NO];
[self updateTimeSlider:nil];
NSColor *timeFieldTextColor = [NSColor controlTextColor];
[self.timeField setTextColor: timeFieldTextColor];
[self.timeField setFont:[NSFont titleBarFontOfSize:10.0]];
[self.timeField setAlignment: NSCenterTextAlignment];
@ -122,8 +125,14 @@
self.fullscreenButtonWidthConstraint.constant = 0;
}
if (config_GetInt("macosx-show-playback-buttons"))
[self toggleForwardBackwardMode: YES];
self.backwardButton.accessibilityTitle = _NS("Previous");
self.backwardButton.accessibilityLabel = _NS("Go to previous item");
self.forwardButton.accessibilityTitle = _NS("Next");
self.forwardButton.accessibilityLabel = _NS("Go to next item");
[self.forwardButton setAction:@selector(fwd:)];
[self.backwardButton setAction:@selector(bwd:)];
[self playerStateUpdated:nil];
}
@ -138,32 +147,6 @@
return [self.bottomBarView frame].size.height;
}
- (void)toggleForwardBackwardMode:(BOOL)b_alt
{
if (b_alt == YES) {
/* change the accessibility help for the backward/forward buttons accordingly */
self.backwardButton.accessibilityTitle = _NS("Backward");
self.backwardButton.accessibilityLabel = _NS("Seek backward");
self.forwardButton.accessibilityTitle = _NS("Forward");
self.forwardButton.accessibilityLabel = _NS("Seek forward");
[self.forwardButton setAction:@selector(alternateForward:)];
[self.backwardButton setAction:@selector(alternateBackward:)];
} else {
/* change the accessibility help for the backward/forward buttons accordingly */
self.backwardButton.accessibilityTitle = _NS("Previous");
self.backwardButton.accessibilityLabel = _NS("Go to previous item");
self.forwardButton.accessibilityTitle = _NS("Next");
self.forwardButton.accessibilityLabel = _NS("Go to next item");
[self.forwardButton setAction:@selector(fwd:)];
[self.backwardButton setAction:@selector(bwd:)];
}
}
#pragma mark -
#pragma mark Button Actions
@ -242,17 +225,6 @@
}
}
// alternative actions for forward / backward buttons when next / prev are activated
- (IBAction)alternateForward:(id)sender
{
[_playerController jumpForwardExtraShort];
}
- (IBAction)alternateBackward:(id)sender
{
[_playerController jumpBackwardExtraShort];
}
- (IBAction)timeSliderAction:(id)sender
{
float f_updatedDelta;
@ -295,8 +267,6 @@
{
input_item_t *p_item = _playerController.currentMedia;
[self.timeSlider setHidden:NO];
if (!p_item) {
// Nothing playing
[self.timeSlider setKnobHidden:YES];

View File

@ -1,10 +1,10 @@
/*****************************************************************************
* ControlsBar.h: MacOS X interface module
* VLCMainWindowControlsBar.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2012-2019 VLC authors and VideoLAN
*
* Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
* David Fuhrmann <david dot fuhrmann at googlemail dot com>
* Authors: Felix Paul Kühne <fkuehne # videolan dot org>
* David Fuhrmann <dfuhrmann # videolan dot org>
*
* 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
@ -38,36 +38,15 @@
@property (readwrite, strong) IBOutlet NSButton *stopButton;
@property (readwrite, strong) IBOutlet NSButton *prevButton;
@property (readwrite, strong) IBOutlet NSLayoutConstraint *prevButtonWidthConstraint;
@property (readwrite, strong) IBOutlet NSButton *nextButton;
@property (readwrite, strong) IBOutlet NSLayoutConstraint *nextButtonWidthConstraint;
@property (readwrite, strong) IBOutlet NSButton *playlistButton;
@property (readwrite, strong) IBOutlet NSButton *repeatButton;
@property (readwrite, strong) IBOutlet NSLayoutConstraint *repeatButtonWidthConstraint;
@property (readwrite, strong) IBOutlet NSButton *shuffleButton;
@property (readwrite, strong) IBOutlet NSLayoutConstraint *shuffleButtonWidthConstraint;
@property (readwrite, strong) IBOutlet VLCVolumeSlider *volumeSlider;
@property (readwrite, strong) IBOutlet NSButton *volumeDownButton;
@property (readwrite, strong) IBOutlet NSButton *volumeUpButton;
@property (readwrite, strong) IBOutlet NSButton *effectsButton;
@property (readwrite, strong) IBOutlet NSLayoutConstraint *effectsButtonWidthConstraint;
- (IBAction)stop:(id)sender;
- (IBAction)shuffle:(id)sender;
- (IBAction)volumeAction:(id)sender;
- (IBAction)effects:(id)sender;
- (IBAction)repeat:(id)sender;
- (IBAction)togglePlaylist:(id)sender;
- (void)toggleEffectsButton;
- (void)toggleJumpButtons;
- (void)togglePlaymodeButtons;
@end

View File

@ -1,10 +1,10 @@
/*****************************************************************************
* ControlsBar.m: MacOS X interface module
* VLCMainWindowControlsBar.m: MacOS X interface module
*****************************************************************************
* Copyright (C) 2012-2016 VLC authors and VideoLAN
* Copyright (C) 2012-2019 VLC authors and VideoLAN
*
* Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
* David Fuhrmann <david dot fuhrmann at googlemail dot com>
* Authors: Felix Paul Kühne <fkuehne # videolan dot org>
* David Fuhrmann <dfuhrmann # videolan dot org>
*
* 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
@ -21,18 +21,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import "VLCMainWindowControlsBar.h"
#import "VLCControlsBarCommon.h"
#import <vlc_aout.h>
#import "extensions/NSString+Helpers.h"
#import "main/CompatibilityFixes.h"
#import "main/VLCMain.h"
#import "menus/VLCMainMenu.h"
#import "windows/mainwindow/VLCMainWindowControlsBar.h"
#import "playlist/VLCPlaylistController.h"
#import "playlist/VLCPlayerController.h"
#import "library/VLCLibraryWindow.h"
CGFloat VLCVolumeMaximum = 2.;
CGFloat VLCVolumeDefault = 1.;
/*****************************************************************************
* VLCMainWindowControlsBar
@ -42,20 +40,9 @@
@interface VLCMainWindowControlsBar()
{
NSImage * _repeatImage;
NSImage * _pressedRepeatImage;
NSImage * _repeatAllImage;
NSImage * _pressedRepeatAllImage;
NSImage * _repeatOneImage;
NSImage * _pressedRepeatOneImage;
NSImage * _shuffleImage;
NSImage * _pressedShuffleImage;
NSImage * _shuffleOnImage;
NSImage * _pressedShuffleOnImage;
VLCPlaylistController *_playlistController;
VLCPlayerController *_playerController;
}
@end
@implementation VLCMainWindowControlsBar
@ -70,22 +57,11 @@
[notificationCenter addObserver:self selector:@selector(updatePlaybackControls:) name:VLCPlaylistCurrentItemChanged object:nil];
[notificationCenter addObserver:self selector:@selector(updateVolumeSlider:) name:VLCPlayerVolumeChanged object:nil];
[notificationCenter addObserver:self selector:@selector(updateVolumeSlider:) name:VLCPlayerMuteChanged object:nil];
[notificationCenter addObserver:self selector:@selector(playbackOrderUpdated:) name:VLCPlaybackOrderChanged object:nil];
[notificationCenter addObserver:self selector:@selector(playbackRepeatChanged:) name:VLCPlaybackRepeatChanged object:nil];
[notificationCenter addObserver:self selector:@selector(playbackStateChanged:) name:VLCPlayerStateChanged object:nil];
[self.stopButton setToolTip: _NS("Stop")];
self.stopButton.accessibilityLabel = self.stopButton.toolTip;
[self.playlistButton setToolTip: _NS("Show/Hide Playlist")];
self.playlistButton.accessibilityLabel = self.playlistButton.toolTip;
[self.repeatButton setToolTip: _NS("Repeat")];
self.repeatButton.accessibilityLabel = _NS("Change repeat mode. Modes: repeat one, repeat all and no repeat.");
self.repeatButton.accessibilityTitle = self.repeatButton.toolTip;
[self.shuffleButton setToolTip: _NS("Shuffle")];
self.shuffleButton.accessibilityLabel = self.shuffleButton.toolTip;
NSString *volumeTooltip = [NSString stringWithFormat:_NS("Volume: %i %%"), 100];
[self.volumeSlider setToolTip: volumeTooltip];
self.volumeSlider.accessibilityLabel = _NS("Volume");
@ -96,37 +72,12 @@
[self.volumeUpButton setToolTip: _NS("Full Volume")];
self.volumeUpButton.accessibilityLabel = self.volumeUpButton.toolTip;
[self.effectsButton setToolTip: _NS("Audio Effects")];
self.effectsButton.accessibilityTitle = _NS("Open Audio Effects window");
self.effectsButton.accessibilityLabel = self.effectsButton.toolTip;
[self.stopButton setImage: imageFromRes(@"stop")];
[self.stopButton setAlternateImage: imageFromRes(@"stop-pressed")];
[self.playlistButton setImage: imageFromRes(@"playlist-btn")];
[self.playlistButton setAlternateImage: imageFromRes(@"playlist-btn-pressed")];
_repeatImage = imageFromRes(@"repeat");
_pressedRepeatImage = imageFromRes(@"repeat-pressed");
_repeatAllImage = imageFromRes(@"repeat-all");
_pressedRepeatAllImage = imageFromRes(@"repeat-all-pressed");
_repeatOneImage = imageFromRes(@"repeat-one");
_pressedRepeatOneImage = imageFromRes(@"repeat-one-pressed");
_shuffleImage = imageFromRes(@"shuffle");
_pressedShuffleImage = imageFromRes(@"shuffle-pressed");
_shuffleOnImage = imageFromRes(@"shuffle-blue");
_pressedShuffleOnImage = imageFromRes(@"shuffle-blue-pressed");
[self.volumeDownButton setImage: imageFromRes(@"volume-low")];
[self.volumeUpButton setImage: imageFromRes(@"volume-high")];
if (self.nativeFullscreenMode) {
[self.effectsButton setImage: imageFromRes(@"effects-one-button")];
[self.effectsButton setAlternateImage: imageFromRes(@"effects-one-button-pressed")];
} else {
[self.effectsButton setImage: imageFromRes(@"effects-double-buttons")];
[self.effectsButton setAlternateImage: imageFromRes(@"effects-double-buttons-pressed")];
}
[self.fullscreenButton setImage: imageFromRes(@"fullscreen-double-buttons")];
[self.fullscreenButton setAlternateImage: imageFromRes(@"fullscreen-double-buttons-pressed")];
@ -134,158 +85,12 @@
[self.prevButton setAlternateImage: imageFromRes(@"previous-6btns-pressed")];
[self.nextButton setImage: imageFromRes(@"next-6btns")];
[self.nextButton setAlternateImage: imageFromRes(@"next-6btns-pressed")];
[self.repeatButton setImage: _repeatImage];
[self.repeatButton setAlternateImage: _pressedRepeatImage];
[self.shuffleButton setImage: _shuffleImage];
[self.shuffleButton setAlternateImage: _pressedShuffleImage];
BOOL b_mute = ![_playerController mute];
[self.volumeSlider setEnabled: b_mute];
[self.volumeSlider setMaxValue: AOUT_VOLUME_MAX];
[self.volumeSlider setDefaultValue: AOUT_VOLUME_DEFAULT];
[self.volumeUpButton setEnabled: b_mute];
[self.volumeSlider setMaxValue: VLCVolumeMaximum];
[self.volumeSlider setDefaultValue: VLCVolumeDefault];
[self updateVolumeSlider:nil];
// configure optional buttons
if (!var_InheritBool(getIntf(), "macosx-show-effects-button"))
[self removeEffectsButton:NO];
if (!var_InheritBool(getIntf(), "macosx-show-playmode-buttons"))
[self removePlaymodeButtons:NO];
if (!var_InheritBool(getIntf(), "macosx-show-playback-buttons"))
[self removeJumpButtons:NO];
// FIXME: make sure that buttons appear in the correct state
}
#pragma mark -
#pragma mark interface customization
- (void)hideButtonWithConstraint:(NSLayoutConstraint *)constraint animation:(BOOL)animation
{
NSAssert([constraint.firstItem isKindOfClass:[NSButton class]], @"Constraint must be for NSButton object");
NSLayoutConstraint *animatedConstraint = animation ? constraint.animator : constraint;
animatedConstraint.constant = 0;
}
- (void)showButtonWithConstraint:(NSLayoutConstraint *)constraint animation:(BOOL)animation
{
NSAssert([constraint.firstItem isKindOfClass:[NSButton class]], @"Constraint must be for NSButton object");
NSLayoutConstraint *animatedConstraint = animation ? constraint.animator : constraint;
animatedConstraint.constant = ((NSButton *)constraint.firstItem).image.size.width;
}
- (void)toggleEffectsButton
{
if (var_InheritBool(getIntf(), "macosx-show-effects-button"))
[self addEffectsButton:YES];
else
[self removeEffectsButton:YES];
}
- (void)addEffectsButton:(BOOL)withAnimation
{
[NSAnimationContext beginGrouping];
[self showButtonWithConstraint:self.effectsButtonWidthConstraint animation:withAnimation];
id button = withAnimation ? self.fullscreenButton.animator : self.fullscreenButton;
if (!self.nativeFullscreenMode) {
[button setImage: imageFromRes(@"fullscreen-double-buttons")];
[button setAlternateImage: imageFromRes(@"fullscreen-double-buttons-pressed")];
}
[NSAnimationContext endGrouping];
}
- (void)removeEffectsButton:(BOOL)withAnimation
{
[NSAnimationContext beginGrouping];
[self hideButtonWithConstraint:self.effectsButtonWidthConstraint animation:withAnimation];
id button = withAnimation ? self.fullscreenButton.animator : self.fullscreenButton;
if (!self.nativeFullscreenMode) {
[button setImage: imageFromRes(@"fullscreen-one-button")];
[button setAlternateImage: imageFromRes(@"fullscreen-one-button-pressed")];
}
[NSAnimationContext endGrouping];
}
- (void)toggleJumpButtons
{
if (var_InheritBool(getIntf(), "macosx-show-playback-buttons"))
[self addJumpButtons:YES];
else
[self removeJumpButtons:YES];
}
- (void)addJumpButtons:(BOOL)withAnimation
{
[NSAnimationContext beginGrouping];
[self showButtonWithConstraint:self.prevButtonWidthConstraint animation:withAnimation];
[self showButtonWithConstraint:self.nextButtonWidthConstraint animation:withAnimation];
id backwardButton = withAnimation ? self.backwardButton.animator : self.backwardButton;
id forwardButton = withAnimation ? self.forwardButton.animator : self.forwardButton;
[forwardButton setImage:imageFromRes(@"forward-6btns")];
[forwardButton setAlternateImage:imageFromRes(@"forward-6btns-pressed")];
[backwardButton setImage:imageFromRes(@"backward-6btns")];
[backwardButton setAlternateImage:imageFromRes(@"backward-6btns-pressed")];
[NSAnimationContext endGrouping];
[self toggleForwardBackwardMode: YES];
}
- (void)removeJumpButtons:(BOOL)withAnimation
{
[NSAnimationContext beginGrouping];
[self hideButtonWithConstraint:self.prevButtonWidthConstraint animation:withAnimation];
[self hideButtonWithConstraint:self.nextButtonWidthConstraint animation:withAnimation];
id backwardButton = withAnimation ? self.backwardButton.animator : self.backwardButton;
id forwardButton = withAnimation ? self.forwardButton.animator : self.forwardButton;
[forwardButton setImage:imageFromRes(@"forward-3btns")];
[forwardButton setAlternateImage:imageFromRes(@"forward-3btns-pressed")];
[backwardButton setImage:imageFromRes(@"backward-3btns")];
[backwardButton setAlternateImage:imageFromRes(@"backward-3btns-pressed")];
[NSAnimationContext endGrouping];
[self toggleForwardBackwardMode: NO];
}
- (void)togglePlaymodeButtons
{
if (var_InheritBool(getIntf(), "macosx-show-playmode-buttons"))
[self addPlaymodeButtons:YES];
else
[self removePlaymodeButtons:YES];
}
- (void)addPlaymodeButtons:(BOOL)withAnimation
{
[NSAnimationContext beginGrouping];
[self showButtonWithConstraint:self.repeatButtonWidthConstraint animation:withAnimation];
[self showButtonWithConstraint:self.shuffleButtonWidthConstraint animation:withAnimation];
id button = withAnimation ? self.playlistButton.animator : self.playlistButton;
[button setImage:imageFromRes(@"playlist-btn")];
[button setAlternateImage:imageFromRes(@"playlist-btn-pressed")];
[NSAnimationContext endGrouping];
}
- (void)removePlaymodeButtons:(BOOL)withAnimation
{
[NSAnimationContext beginGrouping];
[self hideButtonWithConstraint:self.repeatButtonWidthConstraint animation:withAnimation];
[self hideButtonWithConstraint:self.shuffleButtonWidthConstraint animation:withAnimation];
id button = withAnimation ? self.playlistButton.animator : self.playlistButton;
[button setImage:imageFromRes(@"playlist-1btn")];
[button setAlternateImage:imageFromRes(@"playlist-1btn-pressed")];
[NSAnimationContext endGrouping];
[self playbackStateChanged:nil];
}
#pragma mark -
@ -307,100 +112,14 @@
[_playlistController playNextItem];
}
- (void)setRepeatOne
{
[self.repeatButton setImage: _repeatOneImage];
[self.repeatButton setAlternateImage: _pressedRepeatOneImage];
}
- (void)setRepeatAll
{
[self.repeatButton setImage: _repeatAllImage];
[self.repeatButton setAlternateImage: _pressedRepeatAllImage];
}
- (void)setRepeatOff
{
[self.repeatButton setImage: _repeatImage];
[self.repeatButton setAlternateImage: _pressedRepeatImage];
}
- (IBAction)repeat:(id)sender
{
enum vlc_playlist_playback_repeat repeatState = _playlistController.playbackRepeat;
switch (repeatState) {
case VLC_PLAYLIST_PLAYBACK_REPEAT_NONE:
/* was: no repeating at all, switching to Repeat One */
_playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT;
break;
case VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT:
/* was: Repeat One, switching to Repeat All */
_playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_ALL;
break;
default:
/* was: Repeat All, switching to Repeat Off */
_playlistController.playbackRepeat = VLC_PLAYLIST_PLAYBACK_REPEAT_NONE;
break;
}
}
- (void)playbackOrderUpdated:(NSNotification *)aNotification
{
if (_playlistController.playbackOrder == VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL) {
[self.shuffleButton setImage: _shuffleImage];
[self.shuffleButton setAlternateImage: _pressedShuffleImage];
} else {
[self.shuffleButton setImage: _shuffleOnImage];
[self.shuffleButton setAlternateImage: _pressedShuffleOnImage];
}
}
- (void)playbackRepeatChanged:(NSNotification *)aNotification
{
enum vlc_playlist_playback_repeat repeatState = _playlistController.playbackRepeat;
switch (repeatState) {
case VLC_PLAYLIST_PLAYBACK_REPEAT_ALL:
[self setRepeatAll];
break;
case VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT:
[self setRepeatOne];
break;
default:
[self setRepeatOff];
break;
}
}
- (IBAction)shuffle:(id)sender
{
if (_playlistController.playbackOrder == VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL) {
_playlistController.playbackOrder = VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM;
} else {
_playlistController.playbackOrder = VLC_PLAYLIST_PLAYBACK_ORDER_NORMAL;
}
}
- (IBAction)togglePlaylist:(id)sender
{
// FIXME: this is a NO-OP
}
- (IBAction)volumeAction:(id)sender
{
if (sender == self.volumeSlider)
[_playerController setVolume: [sender floatValue]];
[_playerController setVolume:[sender floatValue]];
else if (sender == self.volumeDownButton)
[_playerController toggleMute];
else
[_playerController setVolume: AOUT_VOLUME_MAX];
}
- (IBAction)effects:(id)sender
{
[[[VLCMain sharedInstance] mainMenu] showAudioEffects: sender];
[_playerController setVolume:VLCVolumeMaximum];
}
#pragma mark -
@ -422,26 +141,28 @@
[self.volumeUpButton setEnabled: !b_muted];
}
- (void)playbackStateChanged:(NSNotification *)aNotification
{
switch (_playerController.playerState) {
case VLC_PLAYER_STATE_STOPPING:
case VLC_PLAYER_STATE_STOPPED:
self.stopButton.enabled = NO;
break;
default:
self.stopButton.enabled = YES;
break;
}
}
- (void)updatePlaybackControls:(NSNotification *)aNotification
{
bool b_input = false;
bool b_seekable = _playerController.seekable;
bool b_control = _playerController.rateChangable;
// FIXME: re-add chapter navigation as needed
bool b_chapters = false;
input_item_t *p_item = _playerController.currentMedia;
b_input = p_item != NULL;
if (p_item) {
b_input = YES;
input_item_Release(p_item);
}
[self.stopButton setEnabled: b_input];
[self.prevButton setEnabled: (b_seekable || _playlistController.hasPreviousPlaylistItem || b_chapters)];
[self.nextButton setEnabled: (b_seekable || _playlistController.hasNextPlaylistItem || b_chapters)];
[[[VLCMain sharedInstance] mainMenu] setRateControlsEnabled: b_control];
}
@end