diff --git a/extras/package/macosx/vlc.xcodeproj/project.pbxproj b/extras/package/macosx/vlc.xcodeproj/project.pbxproj index 137d473a2f674dcb5fb80d0612afa741676ed604..18a8e1aa0b66d9163f1e971c98789828fcec0026 100644 --- a/extras/package/macosx/vlc.xcodeproj/project.pbxproj +++ b/extras/package/macosx/vlc.xcodeproj/project.pbxproj @@ -380,8 +380,8 @@ 1CCB5F5B1A62A724004C3E90 /* VLCBookmarksWindowController.h in Sources */ = {isa = PBXBuildFile; fileRef = DCE7BD0708A5724D007B10AE /* VLCBookmarksWindowController.h */; }; 1CCB5F5C1A62A724004C3E90 /* VLCBookmarksWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = DCE7BD0608A5724D007B10AE /* VLCBookmarksWindowController.m */; }; 1CCB5F5D1A62A724004C3E90 /* CompatibilityFixes.h in Sources */ = {isa = PBXBuildFile; fileRef = CCB0BB3013FAC9F40095BD0A /* CompatibilityFixes.h */; }; - 1CCB5F601A62A724004C3E90 /* ControlsBar.h in Sources */ = {isa = PBXBuildFile; fileRef = E0382C00160BA09E0031D7FF /* ControlsBar.h */; }; - 1CCB5F611A62A724004C3E90 /* ControlsBar.m in Sources */ = {isa = PBXBuildFile; fileRef = E0382C01160BA09E0031D7FF /* ControlsBar.m */; }; + 1CCB5F601A62A724004C3E90 /* VLCControlsBarCommon.h in Sources */ = {isa = PBXBuildFile; fileRef = E0382C00160BA09E0031D7FF /* VLCControlsBarCommon.h */; }; + 1CCB5F611A62A724004C3E90 /* VLCControlsBarCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = E0382C01160BA09E0031D7FF /* VLCControlsBarCommon.m */; }; 1CCB5F621A62A724004C3E90 /* VLCConvertAndSaveWindowController.h in Sources */ = {isa = PBXBuildFile; fileRef = CC0663341566C34C003A411C /* VLCConvertAndSaveWindowController.h */; }; 1CCB5F631A62A724004C3E90 /* VLCConvertAndSaveWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = CC0663351566C34C003A411C /* VLCConvertAndSaveWindowController.m */; }; 1CCB5F641A62A724004C3E90 /* VLCCoreDialogProvider.h in Sources */ = {isa = PBXBuildFile; fileRef = CC4A33220F8CB017000FC4A7 /* VLCCoreDialogProvider.h */; }; @@ -481,6 +481,7 @@ 6BBBB8B81D12AF72001BD9BA /* VLCRendererDialog.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6BBBB8AC1D108A87001BD9BA /* VLCRendererDialog.xib */; }; 7D3F6525188051F2005776C4 /* BWQuincyMain.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D3F6523188051F2005776C4 /* BWQuincyMain.xib */; }; 7D5678ED1D5BA1DC002698F3 /* VLCApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D5678EC1D5BA1DC002698F3 /* VLCApplication.m */; }; + 7D5678F01D5BA397002698F3 /* VLCMainWindowControlsBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D5678EF1D5BA397002698F3 /* VLCMainWindowControlsBar.m */; }; 7D8BB0B71830311300FAE9B7 /* DebugMessageVisualizer.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B51830311300FAE9B7 /* DebugMessageVisualizer.xib */; }; 7D8BB0BA1830367200FAE9B7 /* PlaylistMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B81830367200FAE9B7 /* PlaylistMenu.xib */; }; 7D8BB0C01830393300FAE9B7 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D8BB0BE1830393300FAE9B7 /* MainWindow.xib */; }; @@ -1299,6 +1300,8 @@ 7D3F652918805297005776C4 /* BWQuincyUI.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = BWQuincyUI.m; path = ../../../modules/gui/macosx/BWQuincyUI.m; sourceTree = SOURCE_ROOT; }; 7D5678EB1D5BA1DC002698F3 /* VLCApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCApplication.h; path = ../../../modules/gui/macosx/VLCApplication.h; sourceTree = "<group>"; }; 7D5678EC1D5BA1DC002698F3 /* VLCApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCApplication.m; path = ../../../modules/gui/macosx/VLCApplication.m; sourceTree = "<group>"; }; + 7D5678EE1D5BA397002698F3 /* VLCMainWindowControlsBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCMainWindowControlsBar.h; path = ../../../modules/gui/macosx/VLCMainWindowControlsBar.h; sourceTree = "<group>"; }; + 7D5678EF1D5BA397002698F3 /* VLCMainWindowControlsBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCMainWindowControlsBar.m; path = ../../../modules/gui/macosx/VLCMainWindowControlsBar.m; sourceTree = "<group>"; }; 7D871D371B5E6844000B56C0 /* VLCMain+OldPrefs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "VLCMain+OldPrefs.h"; path = "../../../modules/gui/macosx/VLCMain+OldPrefs.h"; sourceTree = "<group>"; }; 7D871D381B5E6844000B56C0 /* VLCMain+OldPrefs.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = "VLCMain+OldPrefs.m"; path = "../../../modules/gui/macosx/VLCMain+OldPrefs.m"; sourceTree = "<group>"; }; 7D871D391B5E684D000B56C0 /* helpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = helpers.h; path = ../../../modules/gui/macosx/helpers.h; sourceTree = "<group>"; }; @@ -1789,8 +1792,8 @@ DCC8017916FCA0DA007FE736 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; DCE7BD0608A5724D007B10AE /* VLCBookmarksWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCBookmarksWindowController.m; path = ../../../modules/gui/macosx/VLCBookmarksWindowController.m; sourceTree = SOURCE_ROOT; }; DCE7BD0708A5724D007B10AE /* VLCBookmarksWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCBookmarksWindowController.h; path = ../../../modules/gui/macosx/VLCBookmarksWindowController.h; sourceTree = SOURCE_ROOT; }; - E0382C00160BA09E0031D7FF /* ControlsBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ControlsBar.h; path = ../../../modules/gui/macosx/ControlsBar.h; sourceTree = SOURCE_ROOT; }; - E0382C01160BA09E0031D7FF /* ControlsBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ControlsBar.m; path = ../../../modules/gui/macosx/ControlsBar.m; sourceTree = SOURCE_ROOT; }; + E0382C00160BA09E0031D7FF /* VLCControlsBarCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCControlsBarCommon.h; path = ../../../modules/gui/macosx/VLCControlsBarCommon.h; sourceTree = SOURCE_ROOT; }; + E0382C01160BA09E0031D7FF /* VLCControlsBarCommon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCControlsBarCommon.m; path = ../../../modules/gui/macosx/VLCControlsBarCommon.m; sourceTree = SOURCE_ROOT; }; E06CF7F416020F6200C698B7 /* Windows.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Windows.h; path = ../../../modules/gui/macosx/Windows.h; sourceTree = SOURCE_ROOT; }; E06CF7F516020F6200C698B7 /* Windows.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Windows.m; path = ../../../modules/gui/macosx/Windows.m; sourceTree = SOURCE_ROOT; }; E0C2583E161B593D00185AAD /* VLCVoutWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCVoutWindowController.h; path = ../../../modules/gui/macosx/VLCVoutWindowController.h; sourceTree = SOURCE_ROOT; }; @@ -1885,8 +1888,10 @@ DCE7BD0708A5724D007B10AE /* VLCBookmarksWindowController.h */, DCE7BD0608A5724D007B10AE /* VLCBookmarksWindowController.m */, CCB0BB3013FAC9F40095BD0A /* CompatibilityFixes.h */, - E0382C00160BA09E0031D7FF /* ControlsBar.h */, - E0382C01160BA09E0031D7FF /* ControlsBar.m */, + E0382C00160BA09E0031D7FF /* VLCControlsBarCommon.h */, + E0382C01160BA09E0031D7FF /* VLCControlsBarCommon.m */, + 7D5678EE1D5BA397002698F3 /* VLCMainWindowControlsBar.h */, + 7D5678EF1D5BA397002698F3 /* VLCMainWindowControlsBar.m */, CC0663341566C34C003A411C /* VLCConvertAndSaveWindowController.h */, CC0663351566C34C003A411C /* VLCConvertAndSaveWindowController.m */, CC4A33220F8CB017000FC4A7 /* VLCCoreDialogProvider.h */, @@ -3971,9 +3976,10 @@ 7D9516BA1C60B6AB00D14E1A /* VLCStatusBarIcon.m in Sources */, 1CCB5F5B1A62A724004C3E90 /* VLCBookmarksWindowController.h in Sources */, 1CCB5F5C1A62A724004C3E90 /* VLCBookmarksWindowController.m in Sources */, + 7D5678F01D5BA397002698F3 /* VLCMainWindowControlsBar.m in Sources */, 1CCB5F5D1A62A724004C3E90 /* CompatibilityFixes.h in Sources */, - 1CCB5F601A62A724004C3E90 /* ControlsBar.h in Sources */, - 1CCB5F611A62A724004C3E90 /* ControlsBar.m in Sources */, + 1CCB5F601A62A724004C3E90 /* VLCControlsBarCommon.h in Sources */, + 1CCB5F611A62A724004C3E90 /* VLCControlsBarCommon.m in Sources */, 1CCB5F621A62A724004C3E90 /* VLCConvertAndSaveWindowController.h in Sources */, 1CCB5F631A62A724004C3E90 /* VLCConvertAndSaveWindowController.m in Sources */, 1CCB5F641A62A724004C3E90 /* VLCCoreDialogProvider.h in Sources */, diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am index f796f877552f2db0ee84931bca1d0b21de037089..de2ef9c5a561a41cd57c93e367a18708a8f73da6 100644 --- a/modules/gui/macosx/Makefile.am +++ b/modules/gui/macosx/Makefile.am @@ -28,7 +28,8 @@ libmacosx_plugin_la_SOURCES = \ BWQuincyManager.h BWQuincyManager.m \ BWQuincyUI.h BWQuincyUI.m \ CompatibilityFixes.h \ - ControlsBar.m ControlsBar.h \ + VLCControlsBarCommon.m VLCControlsBarCommon.h \ + VLCMainWindowControlsBar.m VLCMainWindowControlsBar.h \ VLCConvertAndSaveWindowController.h VLCConvertAndSaveWindowController.m \ VLCCoreInteraction.h VLCCoreInteraction.m \ ExtensionsDialogProvider.h ExtensionsDialogProvider.m \ diff --git a/modules/gui/macosx/ControlsBar.h b/modules/gui/macosx/VLCControlsBarCommon.h similarity index 67% rename from modules/gui/macosx/ControlsBar.h rename to modules/gui/macosx/VLCControlsBarCommon.h index edc8819653f45ea2c70d4e7f32f5d4f87d9f1c04..f64ff03b51ffba6deccc68dbd7d561e6c5553487 100644 --- a/modules/gui/macosx/ControlsBar.h +++ b/modules/gui/macosx/VLCControlsBarCommon.h @@ -1,5 +1,5 @@ /***************************************************************************** - * ControlsBar.h: MacOS X interface module + * VLCControlsBarCommon.h: MacOS X interface module ***************************************************************************** * Copyright (C) 2012-2016 VLC authors and VideoLAN * $Id$ @@ -76,51 +76,3 @@ - (void)setFullscreenState:(BOOL)b_fullscreen; @end - - -/***************************************************************************** - * VLCMainWindowControlsBar - * - * Holds all specific outlets, actions and code for the main window controls bar. - *****************************************************************************/ - -@interface VLCMainWindowControlsBar : VLCControlsBarCommon - -@property (readwrite, strong) IBOutlet NSButton *stopButton; - -@property (readwrite, strong) IBOutlet NSButton *playlistButton; -@property (readwrite, strong) IBOutlet NSButton *repeatButton; -@property (readwrite, strong) IBOutlet NSButton *shuffleButton; - -@property (readwrite, strong) IBOutlet VLCVolumeSliderCommon * volumeSlider; -@property (readwrite, strong) IBOutlet NSImageView *volumeTrackImageView; -@property (readwrite, strong) IBOutlet NSButton *volumeDownButton; -@property (readwrite, strong) IBOutlet NSButton *volumeUpButton; - -@property (readwrite, strong) IBOutlet NSButton *effectsButton; - -- (IBAction)stop:(id)sender; - -- (IBAction)shuffle:(id)sender; -- (IBAction)volumeAction:(id)sender; -- (IBAction)effects:(id)sender; - -- (void)setRepeatOne; -- (void)setRepeatAll; -- (void)setRepeatOff; -- (IBAction)repeat:(id)sender; - -- (void)setShuffle; -- (IBAction)shuffle:(id)sender; - -- (IBAction)togglePlaylist:(id)sender; - -- (void)toggleEffectsButton; -- (void)toggleJumpButtons; -- (void)togglePlaymodeButtons; - -- (void)updateVolumeSlider; -- (void)updateControls; - -@end - diff --git a/modules/gui/macosx/VLCControlsBarCommon.m b/modules/gui/macosx/VLCControlsBarCommon.m new file mode 100644 index 0000000000000000000000000000000000000000..1f7684a891a0e565eb98b8e8b91140a83db13f86 --- /dev/null +++ b/modules/gui/macosx/VLCControlsBarCommon.m @@ -0,0 +1,453 @@ +/***************************************************************************** + * VLCControlsBarCommon.m: MacOS X interface module + ***************************************************************************** + * Copyright (C) 2012-2016 VLC authors and VideoLAN + * $Id$ + * + * 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 "VLCControlsBarCommon.h" +#import "VLCMain.h" +#import "VLCCoreInteraction.h" +#import "VLCMainMenu.h" +#import "VLCFSPanel.h" +#import "VLCPlaylist.h" +#import "CompatibilityFixes.h" + +/***************************************************************************** + * VLCControlsBarCommon + * + * Holds all outlets, actions and code common for controls bar in detached + * and in main window. + *****************************************************************************/ + +@interface VLCControlsBarCommon () +{ + NSImage * _pauseImage; + NSImage * _pressedPauseImage; + NSImage * _playImage; + NSImage * _pressedPlayImage; + + NSTimeInterval last_fwd_event; + NSTimeInterval last_bwd_event; + BOOL just_triggered_next; + BOOL just_triggered_previous; +} +@end + +@implementation VLCControlsBarCommon + +- (void)awakeFromNib +{ + _darkInterface = config_GetInt(getIntf(), "macosx-interfacestyle"); + _nativeFullscreenMode = NO; + + [self.dropView setDrawBorder: NO]; + + [self.playButton setToolTip: _NS("Play/Pause")]; + [[self.playButton cell] accessibilitySetOverrideValue:_NS("Click to play or pause the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; + [[self.playButton cell] accessibilitySetOverrideValue:[self.playButton toolTip] forAttribute:NSAccessibilityTitleAttribute]; + + [self.backwardButton setToolTip: _NS("Backward")]; + [[self.backwardButton cell] accessibilitySetOverrideValue:_NS("Click to go to the previous playlist item. Hold to skip backward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; + [[self.backwardButton cell] accessibilitySetOverrideValue:[self.backwardButton toolTip] forAttribute:NSAccessibilityTitleAttribute]; + + [self.forwardButton setToolTip: _NS("Forward")]; + [[self.forwardButton cell] accessibilitySetOverrideValue:_NS("Click to go to the next playlist item. Hold to skip forward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; + [[self.forwardButton cell] accessibilitySetOverrideValue:[self.forwardButton toolTip] forAttribute:NSAccessibilityTitleAttribute]; + + [self.timeSlider setToolTip: _NS("Position")]; + [[self.timeSlider cell] accessibilitySetOverrideValue:_NS("Click and move the mouse while keeping the button pressed to use this slider to change current playback position.") forAttribute:NSAccessibilityDescriptionAttribute]; + [[self.timeSlider cell] accessibilitySetOverrideValue:[self.timeSlider toolTip] forAttribute:NSAccessibilityTitleAttribute]; + + [self.fullscreenButton setToolTip: _NS("Toggle Fullscreen mode")]; + [[self.fullscreenButton cell] accessibilitySetOverrideValue:_NS("Click to enable fullscreen video playback.") forAttribute:NSAccessibilityDescriptionAttribute]; + [[self.fullscreenButton cell] accessibilitySetOverrideValue:[self.fullscreenButton toolTip] forAttribute:NSAccessibilityTitleAttribute]; + + if (!_darkInterface) { + [self.bottomBarView setImagesLeft: imageFromRes(@"bottom-background") middle: imageFromRes(@"bottom-background") right: imageFromRes(@"bottom-background")]; + + [self.backwardButton setImage: imageFromRes(@"backward-3btns")]; + [self.backwardButton setAlternateImage: imageFromRes(@"backward-3btns-pressed")]; + _playImage = imageFromRes(@"play"); + _pressedPlayImage = imageFromRes(@"play-pressed"); + _pauseImage = imageFromRes(@"pause"); + _pressedPauseImage = imageFromRes(@"pause-pressed"); + [self.forwardButton setImage: imageFromRes(@"forward-3btns")]; + [self.forwardButton setAlternateImage: imageFromRes(@"forward-3btns-pressed")]; + + [self.timeSliderBackgroundView setImagesLeft: imageFromRes(@"progression-track-wrapper-left") middle: imageFromRes(@"progression-track-wrapper-middle") right: imageFromRes(@"progression-track-wrapper-right")]; + [self.timeSliderGradientView setImagesLeft:imageFromRes(@"progression-fill-left") middle:imageFromRes(@"progression-fill-middle") right:imageFromRes(@"progression-fill-right")]; + + [self.fullscreenButton setImage: imageFromRes(@"fullscreen-one-button")]; + [self.fullscreenButton setAlternateImage: imageFromRes(@"fullscreen-one-button-pressed")]; + } else { + [self.bottomBarView setImagesLeft: imageFromRes(@"bottomdark-left") middle: imageFromRes(@"bottom-background_dark") right: imageFromRes(@"bottomdark-right")]; + + [self.backwardButton setImage: imageFromRes(@"backward-3btns-dark")]; + [self.backwardButton setAlternateImage: imageFromRes(@"backward-3btns-dark-pressed")]; + _playImage = imageFromRes(@"play_dark"); + _pressedPlayImage = imageFromRes(@"play-pressed_dark"); + _pauseImage = imageFromRes(@"pause_dark"); + _pressedPauseImage = imageFromRes(@"pause-pressed_dark"); + [self.forwardButton setImage: imageFromRes(@"forward-3btns-dark")]; + [self.forwardButton setAlternateImage: imageFromRes(@"forward-3btns-dark-pressed")]; + + [self.timeSliderBackgroundView setImagesLeft: imageFromRes(@"progression-track-wrapper-left_dark") middle: imageFromRes(@"progression-track-wrapper-middle_dark") right: imageFromRes(@"progression-track-wrapper-right_dark")]; + [self.timeSliderGradientView setImagesLeft:imageFromRes(@"progressbar-fill-left_dark") middle:imageFromRes(@"progressbar-fill-middle_dark") right:imageFromRes(@"progressbar-fill-right_dark")]; + + [self.fullscreenButton setImage: imageFromRes(@"fullscreen-one-button-pressed_dark")]; + [self.fullscreenButton setAlternateImage: imageFromRes(@"fullscreen-one-button-pressed_dark")]; + } + + [self.playButton setImage: _playImage]; + [self.playButton setAlternateImage: _pressedPlayImage]; + + NSColor *timeFieldTextColor; + if (!var_InheritBool(getIntf(), "macosx-interfacestyle")) + timeFieldTextColor = [NSColor colorWithCalibratedRed:0.229 green:0.229 blue:0.229 alpha:100.0]; + else + timeFieldTextColor = [NSColor colorWithCalibratedRed:0.64 green:0.64 blue:0.64 alpha:100.0]; + [self.timeField setTextColor: timeFieldTextColor]; + [self.timeField setFont:[NSFont titleBarFontOfSize:10.0]]; + [self.timeField setAlignment: NSCenterTextAlignment]; + [self.timeField setNeedsDisplay:YES]; + [self.timeField setRemainingIdentifier:@"DisplayTimeAsTimeRemaining"]; + + // prepare time slider fance gradient view + if (!_darkInterface) { + NSRect frame; + frame = [self.timeSliderGradientView frame]; + frame.size.height = frame.size.height - 1; + frame.origin.y = frame.origin.y + 1; + [self.timeSliderGradientView setFrame: frame]; + } + + NSRect frame; + frame = [_timeSliderGradientView frame]; + frame.size.width = 0; + [_timeSliderGradientView setFrame: frame]; + + // hide resize view if necessary + [self.resizeView setImage: NULL]; + + if ([[self.bottomBarView window] styleMask] & NSResizableWindowMask) + [self.resizeView removeFromSuperviewWithoutNeedingDisplay]; + + + // remove fullscreen button for lion fullscreen + if (_nativeFullscreenMode) { + CGFloat f_width = [self.fullscreenButton frame].size.width; + + NSRect frame = [self.timeField frame]; + frame.origin.x += f_width; + [self.timeField setFrame: frame]; + + frame = [self.progressView frame]; + frame.size.width = f_width + frame.size.width; + [self.progressView setFrame: frame]; + + [self.fullscreenButton removeFromSuperviewWithoutNeedingDisplay]; + } + + if (config_GetInt(getIntf(), "macosx-show-playback-buttons")) + [self toggleForwardBackwardMode: YES]; + +} + +- (CGFloat)height +{ + 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 cell] accessibilitySetOverrideValue:_NS("Click and hold to skip backward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; + [[self.forwardButton cell] accessibilitySetOverrideValue:_NS("Click and hold to skip forward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; + + [self.forwardButton setAction:@selector(alternateForward:)]; + [self.backwardButton setAction:@selector(alternateBackward:)]; + + } else { + /* change the accessibility help for the backward/forward buttons accordingly */ + [[self.backwardButton cell] accessibilitySetOverrideValue:_NS("Click to go to the previous playlist item. Hold to skip backward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; + [[self.forwardButton cell] accessibilitySetOverrideValue:_NS("Click to go to the next playlist item. Hold to skip forward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; + + [self.forwardButton setAction:@selector(fwd:)]; + [self.backwardButton 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(getIntf()); + if (p_input != NULL) { + vlc_value_t pos; + NSString * o_time; + + pos.f_float = f_updated / 10000.; + var_Set(p_input, "position", pos); + [self.timeSlider setFloatValue: f_updated]; + + o_time = [[VLCStringUtility sharedInstance] getCurrentTimeAsString: p_input negative:[self.timeField timeRemaining]]; + [self.timeField 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(getIntf()); + 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; + [self.timeSlider setFloatValue: f_updated]; + + o_time = [[VLCStringUtility sharedInstance] getCurrentTimeAsString: p_input negative:[self.timeField timeRemaining]]; + + mtime_t dur = input_item_GetDuration(input_GetItem(p_input)); + if (dur == -1) { + [self.timeSlider setHidden: YES]; + [self.timeSliderGradientView setHidden: YES]; + } else { + if ([self.timeSlider isHidden] == YES) { + bool b_buffering = false; + input_state_e inputState = input_GetState(p_input); + if (inputState == INIT_S || inputState == OPENING_S) + b_buffering = YES; + + [self.timeSlider setHidden: b_buffering]; + [self.timeSliderGradientView setHidden: b_buffering]; + } + } + [self.timeField setStringValue: o_time]; + [self.timeField setNeedsDisplay:YES]; + + vlc_object_release(p_input); + } else { + [self.timeSlider setFloatValue: 0.0]; + [self.timeField setStringValue: @"00:00"]; + [self.timeSlider setHidden: YES]; + [self.timeSliderGradientView setHidden: YES]; + } +} + +- (void)drawFancyGradientEffectForTimeSlider +{ + CGFloat f_value = [self.timeSlider knobPosition]; + if (f_value > 7.5) { + NSRect oldFrame = [self.timeSliderGradientView frame]; + if (f_value != oldFrame.size.width) { + if ([self.timeSliderGradientView isHidden]) + [self.timeSliderGradientView setHidden: NO]; + [self.timeSliderGradientView setFrame: NSMakeRect(oldFrame.origin.x, oldFrame.origin.y, f_value, oldFrame.size.height)]; + } + } else { + NSRect frame; + frame = [self.timeSliderGradientView frame]; + if (frame.size.width > 0) { + frame.size.width = 0; + [self.timeSliderGradientView setFrame: frame]; + } + [self.timeSliderGradientView setHidden: YES]; + } +} + +- (void)updateControls +{ + bool b_plmul = false; + bool b_seekable = false; + bool b_chapters = false; + bool b_buffering = false; + + playlist_t * p_playlist = pl_Get(getIntf()); + + 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) { + [self.progressBar startAnimation:self]; + [self.progressBar setIndeterminate:YES]; + [self.progressBar setHidden:NO]; + } else { + [self.progressBar stopAnimation:self]; + [self.progressBar setHidden:YES]; + } + + [self.timeSlider setEnabled: b_seekable]; + + [self.forwardButton setEnabled: (b_seekable || b_plmul || b_chapters)]; + [self.backwardButton setEnabled: (b_seekable || b_plmul || b_chapters)]; +} + +- (void)setPause +{ + [self.playButton setImage: _pauseImage]; + [self.playButton setAlternateImage: _pressedPauseImage]; + [self.playButton setToolTip: _NS("Pause")]; +} + +- (void)setPlay +{ + [self.playButton setImage: _playImage]; + [self.playButton setAlternateImage: _pressedPlayImage]; + [self.playButton setToolTip: _NS("Play")]; +} + +- (void)setFullscreenState:(BOOL)b_fullscreen +{ + if (!self.nativeFullscreenMode) + [self.fullscreenButton setState:b_fullscreen]; +} + +@end diff --git a/modules/gui/macosx/VLCMainMenu.m b/modules/gui/macosx/VLCMainMenu.m index 7581e4311d18aaa707c42fd0f39226482e44ec83..e54acad993a31d6bd0037cd1e51a75ce18d6e94d 100644 --- a/modules/gui/macosx/VLCMainMenu.m +++ b/modules/gui/macosx/VLCMainMenu.m @@ -41,7 +41,7 @@ #import "VLCVoutView.h" #import "VLCCoreInteraction.h" #import "VLCMainWindow.h" -#import "ControlsBar.h" +#import "VLCMainWindowControlsBar.h" #import "ExtensionsManager.h" #import "VLCConvertAndSaveWindowController.h" #import "VLCDebugMessageWindowController.h" diff --git a/modules/gui/macosx/VLCMainWindow.m b/modules/gui/macosx/VLCMainWindow.m index 893eac1edb133073d3f4a851c2dca4237088d9ba..283c6a0243faa0087137499b70d77b84cc618bfa 100644 --- a/modules/gui/macosx/VLCMainWindow.m +++ b/modules/gui/macosx/VLCMainWindow.m @@ -45,7 +45,7 @@ #import "PXSourceList.h" #import "PXSourceListDataSource.h" -#import "ControlsBar.h" +#import "VLCMainWindowControlsBar.h" #import "VLCVoutView.h" #import "VLCVoutWindowController.h" diff --git a/modules/gui/macosx/VLCMainWindowControlsBar.h b/modules/gui/macosx/VLCMainWindowControlsBar.h new file mode 100644 index 0000000000000000000000000000000000000000..83fb4ebda3ca1c3fc21e7103d39106e4fac5cc10 --- /dev/null +++ b/modules/gui/macosx/VLCMainWindowControlsBar.h @@ -0,0 +1,77 @@ +/***************************************************************************** + * ControlsBar.h: MacOS X interface module + ***************************************************************************** + * Copyright (C) 2012-2016 VLC authors and VideoLAN + * $Id$ + * + * 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 <Cocoa/Cocoa.h> +#import "misc.h" +#import "VLCControlsBarCommon.h" + +@class VLCFSPanel; +@class VLCResizeControl; + +/***************************************************************************** + * VLCMainWindowControlsBar + * + * Holds all specific outlets, actions and code for the main window controls bar. + *****************************************************************************/ + +@interface VLCMainWindowControlsBar : VLCControlsBarCommon + +@property (readwrite, strong) IBOutlet NSButton *stopButton; + +@property (readwrite, strong) IBOutlet NSButton *playlistButton; +@property (readwrite, strong) IBOutlet NSButton *repeatButton; +@property (readwrite, strong) IBOutlet NSButton *shuffleButton; + +@property (readwrite, strong) IBOutlet VLCVolumeSliderCommon * volumeSlider; +@property (readwrite, strong) IBOutlet NSImageView *volumeTrackImageView; +@property (readwrite, strong) IBOutlet NSButton *volumeDownButton; +@property (readwrite, strong) IBOutlet NSButton *volumeUpButton; + +@property (readwrite, strong) IBOutlet NSButton *effectsButton; + +- (IBAction)stop:(id)sender; + +- (IBAction)shuffle:(id)sender; +- (IBAction)volumeAction:(id)sender; +- (IBAction)effects:(id)sender; + +- (void)setRepeatOne; +- (void)setRepeatAll; +- (void)setRepeatOff; +- (IBAction)repeat:(id)sender; + +- (void)setShuffle; +- (IBAction)shuffle:(id)sender; + +- (IBAction)togglePlaylist:(id)sender; + +- (void)toggleEffectsButton; +- (void)toggleJumpButtons; +- (void)togglePlaymodeButtons; + +- (void)updateVolumeSlider; +- (void)updateControls; + +@end + diff --git a/modules/gui/macosx/ControlsBar.m b/modules/gui/macosx/VLCMainWindowControlsBar.m similarity index 63% rename from modules/gui/macosx/ControlsBar.m rename to modules/gui/macosx/VLCMainWindowControlsBar.m index b029ea1185e92aaf1c4096630862d33fe83cfe4f..3ba68f92a210445852a21dd0ebe18cd6cab25698 100644 --- a/modules/gui/macosx/ControlsBar.m +++ b/modules/gui/macosx/VLCMainWindowControlsBar.m @@ -22,7 +22,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ -#import "ControlsBar.h" +#import "VLCControlsBarCommon.h" +#import "VLCMainWindowControlsBar.h" #import "VLCMain.h" #import "VLCCoreInteraction.h" #import "VLCMainMenu.h" @@ -30,429 +31,6 @@ #import "VLCPlaylist.h" #import "CompatibilityFixes.h" -/***************************************************************************** - * VLCControlsBarCommon - * - * Holds all outlets, actions and code common for controls bar in detached - * and in main window. - *****************************************************************************/ - -@interface VLCControlsBarCommon () -{ - NSImage * _pauseImage; - NSImage * _pressedPauseImage; - NSImage * _playImage; - NSImage * _pressedPlayImage; - - NSTimeInterval last_fwd_event; - NSTimeInterval last_bwd_event; - BOOL just_triggered_next; - BOOL just_triggered_previous; -} -@end - -@implementation VLCControlsBarCommon - -- (void)awakeFromNib -{ - _darkInterface = config_GetInt(getIntf(), "macosx-interfacestyle"); - _nativeFullscreenMode = NO; - - [self.dropView setDrawBorder: NO]; - - [self.playButton setToolTip: _NS("Play/Pause")]; - [[self.playButton cell] accessibilitySetOverrideValue:_NS("Click to play or pause the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; - [[self.playButton cell] accessibilitySetOverrideValue:[self.playButton toolTip] forAttribute:NSAccessibilityTitleAttribute]; - - [self.backwardButton setToolTip: _NS("Backward")]; - [[self.backwardButton cell] accessibilitySetOverrideValue:_NS("Click to go to the previous playlist item. Hold to skip backward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; - [[self.backwardButton cell] accessibilitySetOverrideValue:[self.backwardButton toolTip] forAttribute:NSAccessibilityTitleAttribute]; - - [self.forwardButton setToolTip: _NS("Forward")]; - [[self.forwardButton cell] accessibilitySetOverrideValue:_NS("Click to go to the next playlist item. Hold to skip forward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; - [[self.forwardButton cell] accessibilitySetOverrideValue:[self.forwardButton toolTip] forAttribute:NSAccessibilityTitleAttribute]; - - [self.timeSlider setToolTip: _NS("Position")]; - [[self.timeSlider cell] accessibilitySetOverrideValue:_NS("Click and move the mouse while keeping the button pressed to use this slider to change current playback position.") forAttribute:NSAccessibilityDescriptionAttribute]; - [[self.timeSlider cell] accessibilitySetOverrideValue:[self.timeSlider toolTip] forAttribute:NSAccessibilityTitleAttribute]; - - [self.fullscreenButton setToolTip: _NS("Toggle Fullscreen mode")]; - [[self.fullscreenButton cell] accessibilitySetOverrideValue:_NS("Click to enable fullscreen video playback.") forAttribute:NSAccessibilityDescriptionAttribute]; - [[self.fullscreenButton cell] accessibilitySetOverrideValue:[self.fullscreenButton toolTip] forAttribute:NSAccessibilityTitleAttribute]; - - if (!_darkInterface) { - [self.bottomBarView setImagesLeft: imageFromRes(@"bottom-background") middle: imageFromRes(@"bottom-background") right: imageFromRes(@"bottom-background")]; - - [self.backwardButton setImage: imageFromRes(@"backward-3btns")]; - [self.backwardButton setAlternateImage: imageFromRes(@"backward-3btns-pressed")]; - _playImage = imageFromRes(@"play"); - _pressedPlayImage = imageFromRes(@"play-pressed"); - _pauseImage = imageFromRes(@"pause"); - _pressedPauseImage = imageFromRes(@"pause-pressed"); - [self.forwardButton setImage: imageFromRes(@"forward-3btns")]; - [self.forwardButton setAlternateImage: imageFromRes(@"forward-3btns-pressed")]; - - [self.timeSliderBackgroundView setImagesLeft: imageFromRes(@"progression-track-wrapper-left") middle: imageFromRes(@"progression-track-wrapper-middle") right: imageFromRes(@"progression-track-wrapper-right")]; - [self.timeSliderGradientView setImagesLeft:imageFromRes(@"progression-fill-left") middle:imageFromRes(@"progression-fill-middle") right:imageFromRes(@"progression-fill-right")]; - - [self.fullscreenButton setImage: imageFromRes(@"fullscreen-one-button")]; - [self.fullscreenButton setAlternateImage: imageFromRes(@"fullscreen-one-button-pressed")]; - } else { - [self.bottomBarView setImagesLeft: imageFromRes(@"bottomdark-left") middle: imageFromRes(@"bottom-background_dark") right: imageFromRes(@"bottomdark-right")]; - - [self.backwardButton setImage: imageFromRes(@"backward-3btns-dark")]; - [self.backwardButton setAlternateImage: imageFromRes(@"backward-3btns-dark-pressed")]; - _playImage = imageFromRes(@"play_dark"); - _pressedPlayImage = imageFromRes(@"play-pressed_dark"); - _pauseImage = imageFromRes(@"pause_dark"); - _pressedPauseImage = imageFromRes(@"pause-pressed_dark"); - [self.forwardButton setImage: imageFromRes(@"forward-3btns-dark")]; - [self.forwardButton setAlternateImage: imageFromRes(@"forward-3btns-dark-pressed")]; - - [self.timeSliderBackgroundView setImagesLeft: imageFromRes(@"progression-track-wrapper-left_dark") middle: imageFromRes(@"progression-track-wrapper-middle_dark") right: imageFromRes(@"progression-track-wrapper-right_dark")]; - [self.timeSliderGradientView setImagesLeft:imageFromRes(@"progressbar-fill-left_dark") middle:imageFromRes(@"progressbar-fill-middle_dark") right:imageFromRes(@"progressbar-fill-right_dark")]; - - [self.fullscreenButton setImage: imageFromRes(@"fullscreen-one-button-pressed_dark")]; - [self.fullscreenButton setAlternateImage: imageFromRes(@"fullscreen-one-button-pressed_dark")]; - } - - [self.playButton setImage: _playImage]; - [self.playButton setAlternateImage: _pressedPlayImage]; - - NSColor *timeFieldTextColor; - if (!var_InheritBool(getIntf(), "macosx-interfacestyle")) - timeFieldTextColor = [NSColor colorWithCalibratedRed:0.229 green:0.229 blue:0.229 alpha:100.0]; - else - timeFieldTextColor = [NSColor colorWithCalibratedRed:0.64 green:0.64 blue:0.64 alpha:100.0]; - [self.timeField setTextColor: timeFieldTextColor]; - [self.timeField setFont:[NSFont titleBarFontOfSize:10.0]]; - [self.timeField setAlignment: NSCenterTextAlignment]; - [self.timeField setNeedsDisplay:YES]; - [self.timeField setRemainingIdentifier:@"DisplayTimeAsTimeRemaining"]; - - // prepare time slider fance gradient view - if (!_darkInterface) { - NSRect frame; - frame = [self.timeSliderGradientView frame]; - frame.size.height = frame.size.height - 1; - frame.origin.y = frame.origin.y + 1; - [self.timeSliderGradientView setFrame: frame]; - } - - NSRect frame; - frame = [_timeSliderGradientView frame]; - frame.size.width = 0; - [_timeSliderGradientView setFrame: frame]; - - // hide resize view if necessary - [self.resizeView setImage: NULL]; - - if ([[self.bottomBarView window] styleMask] & NSResizableWindowMask) - [self.resizeView removeFromSuperviewWithoutNeedingDisplay]; - - - // remove fullscreen button for lion fullscreen - if (_nativeFullscreenMode) { - CGFloat f_width = [self.fullscreenButton frame].size.width; - - NSRect frame = [self.timeField frame]; - frame.origin.x += f_width; - [self.timeField setFrame: frame]; - - frame = [self.progressView frame]; - frame.size.width = f_width + frame.size.width; - [self.progressView setFrame: frame]; - - [self.fullscreenButton removeFromSuperviewWithoutNeedingDisplay]; - } - - if (config_GetInt(getIntf(), "macosx-show-playback-buttons")) - [self toggleForwardBackwardMode: YES]; - -} - -- (CGFloat)height -{ - 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 cell] accessibilitySetOverrideValue:_NS("Click and hold to skip backward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; - [[self.forwardButton cell] accessibilitySetOverrideValue:_NS("Click and hold to skip forward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; - - [self.forwardButton setAction:@selector(alternateForward:)]; - [self.backwardButton setAction:@selector(alternateBackward:)]; - - } else { - /* change the accessibility help for the backward/forward buttons accordingly */ - [[self.backwardButton cell] accessibilitySetOverrideValue:_NS("Click to go to the previous playlist item. Hold to skip backward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; - [[self.forwardButton cell] accessibilitySetOverrideValue:_NS("Click to go to the next playlist item. Hold to skip forward through the current media.") forAttribute:NSAccessibilityDescriptionAttribute]; - - [self.forwardButton setAction:@selector(fwd:)]; - [self.backwardButton 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(getIntf()); - if (p_input != NULL) { - vlc_value_t pos; - NSString * o_time; - - pos.f_float = f_updated / 10000.; - var_Set(p_input, "position", pos); - [self.timeSlider setFloatValue: f_updated]; - - o_time = [[VLCStringUtility sharedInstance] getCurrentTimeAsString: p_input negative:[self.timeField timeRemaining]]; - [self.timeField 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(getIntf()); - 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; - [self.timeSlider setFloatValue: f_updated]; - - o_time = [[VLCStringUtility sharedInstance] getCurrentTimeAsString: p_input negative:[self.timeField timeRemaining]]; - - mtime_t dur = input_item_GetDuration(input_GetItem(p_input)); - if (dur == -1) { - [self.timeSlider setHidden: YES]; - [self.timeSliderGradientView setHidden: YES]; - } else { - if ([self.timeSlider isHidden] == YES) { - bool b_buffering = false; - input_state_e inputState = input_GetState(p_input); - if (inputState == INIT_S || inputState == OPENING_S) - b_buffering = YES; - - [self.timeSlider setHidden: b_buffering]; - [self.timeSliderGradientView setHidden: b_buffering]; - } - } - [self.timeField setStringValue: o_time]; - [self.timeField setNeedsDisplay:YES]; - - vlc_object_release(p_input); - } else { - [self.timeSlider setFloatValue: 0.0]; - [self.timeField setStringValue: @"00:00"]; - [self.timeSlider setHidden: YES]; - [self.timeSliderGradientView setHidden: YES]; - } -} - -- (void)drawFancyGradientEffectForTimeSlider -{ - CGFloat f_value = [self.timeSlider knobPosition]; - if (f_value > 7.5) { - NSRect oldFrame = [self.timeSliderGradientView frame]; - if (f_value != oldFrame.size.width) { - if ([self.timeSliderGradientView isHidden]) - [self.timeSliderGradientView setHidden: NO]; - [self.timeSliderGradientView setFrame: NSMakeRect(oldFrame.origin.x, oldFrame.origin.y, f_value, oldFrame.size.height)]; - } - } else { - NSRect frame; - frame = [self.timeSliderGradientView frame]; - if (frame.size.width > 0) { - frame.size.width = 0; - [self.timeSliderGradientView setFrame: frame]; - } - [self.timeSliderGradientView setHidden: YES]; - } -} - -- (void)updateControls -{ - bool b_plmul = false; - bool b_seekable = false; - bool b_chapters = false; - bool b_buffering = false; - - playlist_t * p_playlist = pl_Get(getIntf()); - - 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) { - [self.progressBar startAnimation:self]; - [self.progressBar setIndeterminate:YES]; - [self.progressBar setHidden:NO]; - } else { - [self.progressBar stopAnimation:self]; - [self.progressBar setHidden:YES]; - } - - [self.timeSlider setEnabled: b_seekable]; - - [self.forwardButton setEnabled: (b_seekable || b_plmul || b_chapters)]; - [self.backwardButton setEnabled: (b_seekable || b_plmul || b_chapters)]; -} - -- (void)setPause -{ - [self.playButton setImage: _pauseImage]; - [self.playButton setAlternateImage: _pressedPauseImage]; - [self.playButton setToolTip: _NS("Pause")]; -} - -- (void)setPlay -{ - [self.playButton setImage: _playImage]; - [self.playButton setAlternateImage: _pressedPlayImage]; - [self.playButton setToolTip: _NS("Play")]; -} - -- (void)setFullscreenState:(BOOL)b_fullscreen -{ - if (!self.nativeFullscreenMode) - [self.fullscreenButton setState:b_fullscreen]; -} - -@end - - /***************************************************************************** * VLCMainWindowControlsBar * diff --git a/modules/gui/macosx/VLCPLModel.m b/modules/gui/macosx/VLCPLModel.m index d87d4c90ec48c69f2bc37a0433b180ae38d128d4..b014373653ee9302a34f716790d690006fb1aa01 100644 --- a/modules/gui/macosx/VLCPLModel.m +++ b/modules/gui/macosx/VLCPLModel.m @@ -26,7 +26,7 @@ #import "VLCPlaylist.h" #import "VLCStringUtility.h" #import "VLCMain.h" -#import "ControlsBar.h" +#import "VLCMainWindowControlsBar.h" #import "VLCMainMenu.h" #import "VLCPlaylistInfo.h" #import "VLCMainWindow.h" diff --git a/modules/gui/macosx/Windows.m b/modules/gui/macosx/Windows.m index 00dc9284a06dc938fecf3566269756a7869ad5c7..7a926aafb2fab8e1562b0e8303471bd5216b5753 100644 --- a/modules/gui/macosx/Windows.m +++ b/modules/gui/macosx/Windows.m @@ -25,7 +25,7 @@ #import "Windows.h" #import "VLCMain.h" #import "VLCCoreInteraction.h" -#import "ControlsBar.h" +#import "VLCControlsBarCommon.h" #import "VLCVoutView.h" #import "CompatibilityFixes.h" diff --git a/modules/gui/macosx/misc.m b/modules/gui/macosx/misc.m index 5a9366d29235007629fe8bb393c46eea6375ea9f..e98411359146ac231398e22b004f0099c0f0f339 100644 --- a/modules/gui/macosx/misc.m +++ b/modules/gui/macosx/misc.m @@ -27,7 +27,7 @@ #import "VLCMain.h" /* VLCApplication */ #import "VLCMainWindow.h" #import "VLCMainMenu.h" -#import "ControlsBar.h" +#import "VLCControlsBarCommon.h" #import "VLCCoreInteraction.h" #import <CoreAudio/CoreAudio.h> #import <vlc_keys.h> diff --git a/po/POTFILES.in b/po/POTFILES.in index d97cc7d34fb655d0d51786736321f9499b9163db..f3a2af6b92e03b8dd363b4e657796b302a60b598 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -546,8 +546,8 @@ modules/gui/macosx/VLCBookmarksWindowController.h modules/gui/macosx/VLCBookmarksWindowController.m modules/gui/macosx/BWQuincyUI.h modules/gui/macosx/BWQuincyUI.m -modules/gui/macosx/ControlsBar.h -modules/gui/macosx/ControlsBar.m +modules/gui/macosx/VLCControlsBarCommon.h +modules/gui/macosx/VLCControlsBarCommon.m modules/gui/macosx/VLCConvertAndSaveWindowController.h modules/gui/macosx/VLCConvertAndSaveWindowController.m modules/gui/macosx/VLCCoreDialogProvider.h @@ -572,6 +572,8 @@ modules/gui/macosx/VLCMainMenu.h modules/gui/macosx/VLCMainMenu.m modules/gui/macosx/VLCMainWindow.h modules/gui/macosx/VLCMainWindow.m +modules/gui/macosx/VLCMainWindowControlsBar.h +modules/gui/macosx/VLCMainWindowControlsBar.m modules/gui/macosx/MainWindowTitle.h modules/gui/macosx/MainWindowTitle.m modules/gui/macosx/misc.h