diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj index eaa620367a..c5738cf800 100644 --- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj +++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj @@ -33,7 +33,6 @@ 1C3113BC1E508C6900D4DD76 /* VLCKeyboardBacklightControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DF812F01B555C8E0052293C /* VLCKeyboardBacklightControl.m */; }; 1C3113BD1E508C6900D4DD76 /* macosx.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ED6C27E03E2EB1C0059A3A7 /* macosx.m */; }; 1C3113C11E508C6900D4DD76 /* VLCMainWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CC448A6313B68A0B009F72E0 /* VLCMainWindow.m */; }; - 1C3113C31E508C6900D4DD76 /* VLCMainWindowTitleView.m in Sources */ = {isa = PBXBuildFile; fileRef = CC017A0C14A4C8AF00C09A4F /* VLCMainWindowTitleView.m */; }; 1C3113C51E508C6900D4DD76 /* misc.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ED6C28003E2EB1C0059A3A7 /* misc.m */; }; 1C3113C71E508C6900D4DD76 /* VLCOpenWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ED6C28203E2EB1C0059A3A7 /* VLCOpenWindowController.m */; }; 1C3113C91E508C6900D4DD76 /* VLCOutput.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E55FB800459B0FD00FB3317 /* VLCOutput.m */; }; @@ -459,8 +458,6 @@ 8ED6C28403E2EB1C0059A3A7 /* VLCPlaylist.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCPlaylist.m; sourceTree = ""; }; 8ED6C28503E2EB1C0059A3A7 /* prefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = prefs.h; sourceTree = ""; }; 8ED6C28603E2EB1C0059A3A7 /* prefs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = prefs.m; sourceTree = ""; }; - CC017A0B14A4C8AF00C09A4F /* VLCMainWindowTitleView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCMainWindowTitleView.h; sourceTree = ""; }; - CC017A0C14A4C8AF00C09A4F /* VLCMainWindowTitleView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCMainWindowTitleView.m; sourceTree = ""; }; CC0663341566C34C003A411C /* VLCConvertAndSaveWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = VLCConvertAndSaveWindowController.h; sourceTree = ""; }; CC0663351566C34C003A411C /* VLCConvertAndSaveWindowController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = VLCConvertAndSaveWindowController.m; sourceTree = ""; }; CC0CD0DF13DE0EAE00B0D90D /* PXSourceList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PXSourceList.h; sourceTree = ""; }; @@ -1060,8 +1057,6 @@ 7D5678EF1D5BA397002698F3 /* VLCMainWindowControlsBar.m */, CC448A6213B68A0B009F72E0 /* VLCMainWindow.h */, CC448A6313B68A0B009F72E0 /* VLCMainWindow.m */, - CC017A0B14A4C8AF00C09A4F /* VLCMainWindowTitleView.h */, - CC017A0C14A4C8AF00C09A4F /* VLCMainWindowTitleView.m */, ); name = "Main Window"; sourceTree = ""; @@ -1488,7 +1483,7 @@ }; }; }; - buildConfigurationList = C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "VLC" */; + buildConfigurationList = C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "vlc" */; compatibilityVersion = "Xcode 6.3"; developmentRegion = English; hasScannedForEncodings = 1; @@ -1593,7 +1588,6 @@ 1C3113BD1E508C6900D4DD76 /* macosx.m in Sources */, 1C3113C11E508C6900D4DD76 /* VLCMainWindow.m in Sources */, 6B0292E61F43256300A50082 /* VLCBottomBarView.m in Sources */, - 1C3113C31E508C6900D4DD76 /* VLCMainWindowTitleView.m in Sources */, 1C3113C51E508C6900D4DD76 /* misc.m in Sources */, 1C3113C71E508C6900D4DD76 /* VLCOpenWindowController.m in Sources */, 1C3113C91E508C6900D4DD76 /* VLCOutput.m in Sources */, @@ -1869,7 +1863,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Default; }; - C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "VLC" */ = { + C2F2A6EA09588F1B00018C74 /* Build configuration list for PBXProject "vlc" */ = { isa = XCConfigurationList; buildConfigurations = ( C2F2A6EB09588F1B00018C74 /* Development */, diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am index 203c02391f..bba7d44d03 100644 --- a/modules/gui/macosx/Makefile.am +++ b/modules/gui/macosx/Makefile.am @@ -1,6 +1,6 @@ SUFFIXES += .xib -libmacosx_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) -fobjc-exceptions -fobjc-arc +libmacosx_plugin_la_OBJCFLAGS = $(AM_OBJCFLAGS) -fobjc-exceptions -fobjc-arc libmacosx_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(guidir)' \ -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,CoreServices \ -Wl,-framework,AVFoundation -Wl,-framework,CoreMedia -Wl,-framework,IOKit \ @@ -36,7 +36,6 @@ libmacosx_plugin_la_SOURCES = \ gui/macosx/VLCKeyboardBacklightControl.h gui/macosx/VLCKeyboardBacklightControl.m \ gui/macosx/macosx.m \ gui/macosx/VLCMainMenu.h gui/macosx/VLCMainMenu.m \ - gui/macosx/VLCMainWindowTitleView.h gui/macosx/VLCMainWindowTitleView.m \ gui/macosx/misc.h gui/macosx/misc.m \ gui/macosx/NSSound+VLCAdditions.h gui/macosx/NSSound+VLCAdditions.m \ gui/macosx/NSScreen+VLCAdditions.h gui/macosx/NSScreen+VLCAdditions.m \ diff --git a/modules/gui/macosx/UI/DetachedVideoWindow.xib b/modules/gui/macosx/UI/DetachedVideoWindow.xib index b960c0bcea..ef425297b6 100644 --- a/modules/gui/macosx/UI/DetachedVideoWindow.xib +++ b/modules/gui/macosx/UI/DetachedVideoWindow.xib @@ -1,7 +1,9 @@ - + - + + + @@ -20,95 +22,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -224,15 +137,12 @@ - + - - - - + @@ -248,15 +158,12 @@ - - - diff --git a/modules/gui/macosx/UI/MainWindow.xib b/modules/gui/macosx/UI/MainWindow.xib index 3a1b906a65..5c004ab205 100644 --- a/modules/gui/macosx/UI/MainWindow.xib +++ b/modules/gui/macosx/UI/MainWindow.xib @@ -1,9 +1,10 @@ - + - - + + + @@ -22,116 +23,27 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + @@ -173,11 +85,11 @@ - + - + @@ -219,20 +131,20 @@ - + - + - + - + - - + + @@ -298,13 +210,13 @@ - + - + - + @@ -720,17 +632,13 @@ - - - + - - @@ -766,10 +674,8 @@ - - diff --git a/modules/gui/macosx/VLCMainWindow.h b/modules/gui/macosx/VLCMainWindow.h index 7129b2e5c6..ae7fce903d 100644 --- a/modules/gui/macosx/VLCMainWindow.h +++ b/modules/gui/macosx/VLCMainWindow.h @@ -33,7 +33,6 @@ #import "Windows.h" #import "misc.h" #import "VLCFSPanelController.h" -#import "VLCMainWindowTitleView.h" @class VLCDetachedVideoWindow; @class VLCMainWindowControlsBar; diff --git a/modules/gui/macosx/VLCMainWindowTitleView.h b/modules/gui/macosx/VLCMainWindowTitleView.h deleted file mode 100644 index 8a3d0efe0f..0000000000 --- a/modules/gui/macosx/VLCMainWindowTitleView.h +++ /dev/null @@ -1,90 +0,0 @@ -/***************************************************************************** - * MainWindowTitle.h: MacOS X interface module - ***************************************************************************** - * Copyright (C) 2011-2012 Felix Paul Kühne - * $Id$ - * - * Authors: Felix Paul Kühne - * - * 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 -#import "misc.h" - -/***************************************************************************** - * VLCMainWindowTitleView - *****************************************************************************/ - -@class VLCCustomWindowCloseButton; -@class VLCCustomWindowMinimizeButton; -@class VLCCustomWindowZoomButton; -@class VLCCustomWindowFullscreenButton; -@class VLCWindowTitleTextField; - -@interface VLCMainWindowTitleView : VLCThreePartImageView - -@property (readwrite, strong) IBOutlet VLCCustomWindowCloseButton *redButton; -@property (readwrite, strong) IBOutlet VLCCustomWindowMinimizeButton *yellowButton; -@property (readwrite, strong) IBOutlet VLCCustomWindowZoomButton *greenButton; -@property (readwrite, strong) IBOutlet VLCCustomWindowFullscreenButton *fullscreenButton; -@property (readwrite, strong) IBOutlet VLCWindowTitleTextField *titleLabel; - -@property (readonly) NSButton * closeButton; -@property (readonly) NSButton * minimizeButton; -@property (readonly) NSButton * zoomButton; - -- (void)informModifierPressed:(BOOL)b_is_altkey; -- (void)loadButtonIcons; -- (IBAction)buttonAction:(id)sender; -- (void)setWindowTitle:(NSString *)title; -- (void)setWindowButtonOver:(BOOL)b_value; -- (void)setWindowFullscreenButtonOver:(BOOL)b_value; - -@end - -@interface VLCWindowButtonCell : NSButtonCell - -@end - -@interface VLCCustomWindowButtonPrototype : NSButton - -- (NSArray*)extendedAccessibilityAttributeNames: (NSArray*)theAttributeNames; -- (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName; -- (NSNumber*)extendedAccessibilityIsAttributeSettable: (NSString*)theAttributeName; - -@end - -@interface VLCCustomWindowCloseButton : VLCCustomWindowButtonPrototype - -@end - - -@interface VLCCustomWindowMinimizeButton : VLCCustomWindowButtonPrototype - -@end - - -@interface VLCCustomWindowZoomButton : VLCCustomWindowButtonPrototype - -@end - -@interface VLCCustomWindowFullscreenButton : VLCCustomWindowButtonPrototype - -@end - -@interface VLCWindowTitleTextField : NSTextField - -@end diff --git a/modules/gui/macosx/VLCMainWindowTitleView.m b/modules/gui/macosx/VLCMainWindowTitleView.m deleted file mode 100644 index 73e2bb960a..0000000000 --- a/modules/gui/macosx/VLCMainWindowTitleView.m +++ /dev/null @@ -1,566 +0,0 @@ -/***************************************************************************** - * MainWindowTitle.m: MacOS X interface module - ***************************************************************************** - * Copyright (C) 2011-2012 Felix Paul Kühne - * $Id$ - * - * Authors: Felix Paul Kühne - * - * 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 -#import "VLCMain.h" -#import "VLCMainWindowTitleView.h" -#import "VLCCoreInteraction.h" -#import "CompatibilityFixes.h" -#import // for the revealInFinder clone - -/***************************************************************************** - * VLCMainWindowTitleView - * - * this is our title bar, which can do anything a title should do - * it relies on the VLCWindowButtonCell to display the correct traffic light - * states, since we can't capture the mouse-moved events here correctly - *****************************************************************************/ - -@interface VLCMainWindowTitleView() -{ - NSImage *_redImage; - NSImage *_redHoverImage; - NSImage *_redOnClickImage; - NSImage * _yellowImage; - NSImage * _yellowHoverImage; - NSImage * _yellowOnClickImage; - NSImage * _greenImage; - NSImage * _greenHoverImage; - NSImage * _greenOnClickImage; - // yosemite fullscreen images - NSImage * _fullscreenImage; - NSImage * _fullscreenHoverImage; - NSImage * _fullscreenOnClickImage; - // old native fullscreen images - NSImage * _oldFullscreenImage; - NSImage * _oldFullscreenHoverImage; - NSImage * _oldFullscreenOnClickImage; - - NSShadow * _windowTitleShadow; - NSDictionary * _windowTitleAttributesDictionary; - - BOOL b_nativeFullscreenMode; - - // state to determine correct image for green bubble - BOOL b_alt_pressed; - BOOL b_mouse_over; -} -@end - -@implementation VLCMainWindowTitleView - -- (id)init -{ - self = [super init]; - - if (self) { - _windowTitleAttributesDictionary = [NSDictionary dictionaryWithObjectsAndKeys: [NSColor whiteColor], NSForegroundColorAttributeName, [NSFont titleBarFontOfSize:12.0], NSFontAttributeName, nil]; - } - - return self; -} - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver: self]; -} - -- (void)awakeFromNib -{ - b_nativeFullscreenMode = var_InheritBool(getIntf(), "macosx-nativefullscreenmode"); - - if (!b_nativeFullscreenMode || OSX_YOSEMITE_AND_HIGHER) { - [_fullscreenButton setHidden: YES]; - } - - [self setAutoresizesSubviews: YES]; - [self setImagesLeft:imageFromRes(@"topbar-dark-left") middle: imageFromRes(@"topbar-dark-center-fill") right:imageFromRes(@"topbar-dark-right")]; - - [self loadButtonIcons]; - [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(controlTintChanged:) name: NSControlTintDidChangeNotification object: nil]; -} - -- (void)controlTintChanged:(NSNotification *)notification -{ - [self loadButtonIcons]; - - [_redButton setNeedsDisplay]; - [_yellowButton setNeedsDisplay]; - [_greenButton setNeedsDisplay]; -} - -- (void)informModifierPressed:(BOOL)b_is_altkey; -{ - BOOL b_state_changed = b_alt_pressed != b_is_altkey; - - b_alt_pressed = b_is_altkey; - - if (b_state_changed) { - [self updateGreenButton]; - } -} - -- (NSImage *)getButtonImage:(NSString *)o_id -{ - NSString *o_name = @""; - if (OSX_YOSEMITE_AND_HIGHER) { - o_name = @"yosemite-"; - } else { // OSX_LION_AND_HIGHER, OSX_MOUNTAIN_LION_AND_HIGHER, OSX_MAVERICKS_AND_HIGHER - o_name = @"lion-"; - } - - o_name = [o_name stringByAppendingString:o_id]; - - if ([NSColor currentControlTint] != NSBlueControlTint) { - o_name = [o_name stringByAppendingString:@"-graphite"]; - } - - return [NSImage imageNamed:o_name]; -} - -- (void)loadButtonIcons -{ - _redImage = [self getButtonImage:@"window-close"]; - _redHoverImage = [self getButtonImage:@"window-close-over"]; - _redOnClickImage = [self getButtonImage:@"window-close-on"]; - _yellowImage = [self getButtonImage:@"window-minimize"]; - _yellowHoverImage = [self getButtonImage:@"window-minimize-over"]; - _yellowOnClickImage = [self getButtonImage:@"window-minimize-on"]; - _greenImage = [self getButtonImage:@"window-zoom"]; - _greenHoverImage = [self getButtonImage:@"window-zoom-over"]; - _greenOnClickImage = [self getButtonImage:@"window-zoom-on"]; - - // these files are only available in the yosemite variant - if (OSX_YOSEMITE_AND_HIGHER) { - _fullscreenImage = [self getButtonImage:@"window-fullscreen"]; - _fullscreenHoverImage = [self getButtonImage:@"window-fullscreen-over"]; - _fullscreenOnClickImage = [self getButtonImage:@"window-fullscreen-on"]; - } - - // old native fullscreen images are not available in graphite style - // thus they are loaded directly here - _oldFullscreenImage = [NSImage imageNamed:@"lion-window-fullscreen"]; - _oldFullscreenOnClickImage = [NSImage imageNamed:@"lion-window-fullscreen-on"]; - _oldFullscreenHoverImage = [NSImage imageNamed:@"lion-window-fullscreen-over"]; - - [_redButton setImage: _redImage]; - [_redButton setAlternateImage: _redHoverImage]; - [[_redButton cell] setShowsBorderOnlyWhileMouseInside: YES]; - [[_redButton cell] setTag: 0]; - [_yellowButton setImage: _yellowImage]; - [_yellowButton setAlternateImage: _yellowHoverImage]; - [[_yellowButton cell] setShowsBorderOnlyWhileMouseInside: YES]; - [[_yellowButton cell] setTag: 1]; - - [self updateGreenButton]; - [[_greenButton cell] setShowsBorderOnlyWhileMouseInside: YES]; - [[_greenButton cell] setTag: 2]; - - [_fullscreenButton setImage: _oldFullscreenImage]; - [_fullscreenButton setAlternateImage: _oldFullscreenHoverImage]; - [[_fullscreenButton cell] setShowsBorderOnlyWhileMouseInside: YES]; - [[_fullscreenButton cell] setTag: 3]; -} - -- (void)updateGreenButton -{ - // default image for old version, or if native fullscreen is - // disabled on yosemite, or if alt key is pressed - if (!OSX_YOSEMITE_AND_HIGHER || !b_nativeFullscreenMode || b_alt_pressed) { - - if (b_mouse_over) { - [_greenButton setImage: _greenHoverImage]; - [_greenButton setAlternateImage: _greenOnClickImage]; - } else { - [_greenButton setImage: _greenImage]; - [_greenButton setAlternateImage: _greenOnClickImage]; - } - } else { - - if (b_mouse_over) { - [_greenButton setImage: _fullscreenHoverImage]; - [_greenButton setAlternateImage: _fullscreenOnClickImage]; - } else { - [_greenButton setImage: _fullscreenImage]; - [_greenButton setAlternateImage: _fullscreenOnClickImage]; - } - } -} - -- (BOOL)mouseDownCanMoveWindow -{ - return YES; -} - -- (IBAction)buttonAction:(id)sender -{ - if (sender == _redButton) - [[self window] performClose: sender]; - else if (sender == _yellowButton) - [[self window] miniaturize: sender]; - else if (sender == _greenButton) { - if (OSX_YOSEMITE_AND_HIGHER && b_nativeFullscreenMode && !b_alt_pressed) { - [[self window] toggleFullScreen:self]; - } else { - [[self window] performZoom: sender]; - } - } else if (sender == _fullscreenButton) { - // same action as native fs button - [[self window] toggleFullScreen:self]; - - } else - msg_Err(getIntf(), "unknown button action sender"); - - [self setWindowButtonOver: NO]; - [self setWindowFullscreenButtonOver: NO]; -} - -- (void)setWindowTitle:(NSString *)title -{ - if (!_windowTitleShadow) { - _windowTitleShadow = [[NSShadow alloc] init]; - [_windowTitleShadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0 alpha:0.5]]; - [_windowTitleShadow setShadowOffset:NSMakeSize(0.0, -1.5)]; - [_windowTitleShadow setShadowBlurRadius:0.5]; - } - - NSMutableAttributedString *attributedTitleString = [[NSMutableAttributedString alloc] initWithString:title attributes: _windowTitleAttributesDictionary]; - NSUInteger i_titleLength = [title length]; - - [attributedTitleString addAttribute:NSShadowAttributeName value:_windowTitleShadow range:NSMakeRange(0, i_titleLength)]; - [attributedTitleString setAlignment: NSCenterTextAlignment range:NSMakeRange(0, i_titleLength)]; - [_titleLabel setAttributedStringValue:attributedTitleString]; -} - -- (void)setWindowButtonOver:(BOOL)b_value -{ - b_mouse_over = b_value; - if (b_value) { - [_redButton setImage: _redHoverImage]; - [_yellowButton setImage: _yellowHoverImage]; - } else { - [_redButton setImage: _redImage]; - [_yellowButton setImage: _yellowImage]; - } - - [self updateGreenButton]; -} - -- (void)setWindowFullscreenButtonOver:(BOOL)b_value -{ - if (b_value) - [_fullscreenButton setImage: _oldFullscreenHoverImage]; - else - [_fullscreenButton setImage: _oldFullscreenImage]; -} - -- (void)mouseDown:(NSEvent *)event -{ - NSPoint ml = [self convertPoint: [event locationInWindow] fromView: self]; - if (([[self window] frame].size.height - ml.y) <= 22. && [event clickCount] == 2) { - //Get settings from "System Preferences" > "Appearance" > "Double-click on windows title bar to minimize" - NSString *const MDAppleMiniaturizeOnDoubleClickKey = @"AppleMiniaturizeOnDoubleClick"; - NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; - [userDefaults addSuiteNamed:NSGlobalDomain]; - - if ([[userDefaults objectForKey:MDAppleMiniaturizeOnDoubleClickKey] boolValue]) - [[self window] miniaturize:self]; - } - - [super mouseDown: event]; -} - -- (NSButton*)closeButton -{ - return _redButton; -} - -- (NSButton*)minimizeButton -{ - return _yellowButton; -} - -- (NSButton*)zoomButton -{ - return _greenButton; -} - -@end - -/***************************************************************************** - * VLCWindowButtonCell - * - * since the title bar cannot fetch these mouse events (the more top-level - * NSButton is unable fetch them as well), we are using a subclass of the - * button cell to do so. It's set in the nib for the respective objects. - *****************************************************************************/ - -@implementation VLCWindowButtonCell - -- (void)mouseEntered:(NSEvent *)theEvent -{ - if ([self tag] == 3) - [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowFullscreenButtonOver: YES]; - else - [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: YES]; -} - -- (void)mouseExited:(NSEvent *)theEvent -{ - if ([self tag] == 3) - [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowFullscreenButtonOver: NO]; - else - [(VLCMainWindowTitleView *)[[self controlView] superview] setWindowButtonOver: NO]; -} - -/* accessibility stuff */ -- (NSArray*)accessibilityAttributeNames { - NSArray *theAttributeNames = [super accessibilityAttributeNames]; - id theControlView = [self controlView]; - return ([theControlView respondsToSelector: @selector(extendedAccessibilityAttributeNames:)] ? [theControlView extendedAccessibilityAttributeNames: theAttributeNames] : theAttributeNames); // ask the cell's control view (i.e., the button) for additional attribute values -} - -- (id)accessibilityAttributeValue: (NSString*)theAttributeName { - id theControlView = [self controlView]; - if ([theControlView respondsToSelector: @selector(extendedAccessibilityAttributeValue:)]) { - id theValue = [theControlView extendedAccessibilityAttributeValue: theAttributeName]; - if (theValue) { - return theValue; // if this is an extended attribute value we added, return that -- otherwise, fall back to super's implementation - } - } - return [super accessibilityAttributeValue: theAttributeName]; -} - -- (BOOL)accessibilityIsAttributeSettable: (NSString*)theAttributeName { - id theControlView = [self controlView]; - if ([theControlView respondsToSelector: @selector(extendedAccessibilityIsAttributeSettable:)]) { - NSNumber *theValue = [theControlView extendedAccessibilityIsAttributeSettable: theAttributeName]; - if (theValue) - return [theValue boolValue]; // same basic strategy we use in -accessibilityAttributeValue: - } - return [super accessibilityIsAttributeSettable: theAttributeName]; -} - -@end - - -/***************************************************************************** - * custom window buttons to support the accessibility stuff - *****************************************************************************/ - -@implementation VLCCustomWindowButtonPrototype -+ (Class)cellClass { - return [VLCWindowButtonCell class]; -} - -- (NSArray*)extendedAccessibilityAttributeNames: (NSArray*)theAttributeNames { - return ([theAttributeNames containsObject: NSAccessibilitySubroleAttribute] ? theAttributeNames : [theAttributeNames arrayByAddingObject: NSAccessibilitySubroleAttribute]); // run-of-the-mill button cells don't usually have a Subrole attribute, so we add that attribute -} - -- (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName { - return nil; -} - -- (NSNumber*)extendedAccessibilityIsAttributeSettable: (NSString*)theAttributeName { - return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? [NSNumber numberWithBool:NO] : nil); // make the Subrole attribute we added non-settable -} - -- (void)accessibilityPerformAction: (NSString*)theActionName { - if ([theActionName isEqualToString: NSAccessibilityPressAction]) { - if ([self isEnabled]) - [self performClick: nil]; - } else - [super accessibilityPerformAction: theActionName]; -} - -@end - -@implementation VLCCustomWindowCloseButton -- (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName { - return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityCloseButtonAttribute : nil); -} - -@end - - -@implementation VLCCustomWindowMinimizeButton -- (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName { - return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityMinimizeButtonAttribute : nil); -} - -@end - - -@implementation VLCCustomWindowZoomButton -- (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName { - return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityZoomButtonAttribute : nil); -} - -@end - - -@implementation VLCCustomWindowFullscreenButton -- (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName { - return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityFullScreenButtonAttribute : nil); -} -@end - - -@interface VLCWindowTitleTextField() -{ - NSMenu *_contextMenu; -} -@end - -@implementation VLCWindowTitleTextField - -- (void)showRightClickMenuWithEvent:(NSEvent *)o_event -{ - NSURL * representedURL = [[self window] representedURL]; - if (!representedURL) - return; - - NSArray * pathComponents; - pathComponents = [representedURL pathComponents]; - - if (!pathComponents) - return; - - _contextMenu = [[NSMenu alloc] initWithTitle: [[NSFileManager defaultManager] displayNameAtPath: [representedURL path]]]; - - NSUInteger count = [pathComponents count]; - NSImage * icon; - NSMenuItem * currentItem; - NSMutableString * currentPath; - NSSize iconSize = NSMakeSize(16., 16.); - for (NSUInteger i = count - 1; i > 0; i--) { - currentPath = [NSMutableString stringWithCapacity:1024]; - for (NSUInteger y = 0; y < i; y++) - [currentPath appendFormat: @"/%@", [pathComponents objectAtIndex:y + 1]]; - - [_contextMenu addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath: currentPath] action:@selector(revealInFinder:) keyEquivalent:@""]; - currentItem = [_contextMenu itemAtIndex:[_contextMenu numberOfItems] - 1]; - [currentItem setTarget: self]; - - icon = [[NSWorkspace sharedWorkspace] iconForFile:currentPath]; - [icon setSize: iconSize]; - [currentItem setImage: icon]; - } - - if ([[pathComponents objectAtIndex:1] isEqualToString:@"Volumes"]) { - /* we don't want to show the Volumes item, since the Cocoa does it neither */ - currentItem = [_contextMenu itemWithTitle:[[NSFileManager defaultManager] displayNameAtPath: @"/Volumes"]]; - if (currentItem) - [_contextMenu removeItem: currentItem]; - } else { - /* we're on the boot drive, so add it since it isn't part of the components */ - [_contextMenu addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath:@"/"] action:@selector(revealInFinder:) keyEquivalent:@""]; - currentItem = [_contextMenu itemAtIndex: [_contextMenu numberOfItems] - 1]; - icon = [[NSWorkspace sharedWorkspace] iconForFile:@"/"]; - [icon setSize: iconSize]; - [currentItem setImage: icon]; - [currentItem setTarget: self]; - } - - /* add the computer item */ - [_contextMenu addItemWithTitle:(NSString*)CFBridgingRelease(SCDynamicStoreCopyComputerName(NULL, NULL)) action:@selector(revealInFinder:) keyEquivalent:@""]; - currentItem = [_contextMenu itemAtIndex: [_contextMenu numberOfItems] - 1]; - icon = [NSImage imageNamed: NSImageNameComputer]; - [icon setSize: iconSize]; - [currentItem setImage: icon]; - [currentItem setTarget: self]; - - // center the context menu similar to the white interface - CGFloat menuWidth = [_contextMenu size].width; - NSRect windowFrame = [[self window] frame]; - NSPoint point; - - CGFloat fullButtonWidth = 0.; - if([[VLCMain sharedInstance] nativeFullscreenMode]) - fullButtonWidth = 20.; - - // assumes 60 px for the window buttons - point.x = (windowFrame.size.width - 60. - fullButtonWidth) / 2. - menuWidth / 2. + 60. - 20.; - point.y = windowFrame.size.height + 1.; - if (point.x < 0) - point.x = 10; - - NSEvent *fakeMouseEvent = [NSEvent mouseEventWithType:NSRightMouseDown - location:point - modifierFlags:0 - timestamp:0 - windowNumber:[[self window] windowNumber] - context:nil - eventNumber:0 - clickCount:0 - pressure:0]; - [NSMenu popUpContextMenu: _contextMenu withEvent: fakeMouseEvent forView: [self superview]]; -} - -- (IBAction)revealInFinder:(id)sender -{ - NSUInteger count = [_contextMenu numberOfItems]; - NSUInteger selectedItem = [_contextMenu indexOfItem: sender]; - - if (selectedItem == count - 1) { // the fake computer item - [[NSWorkspace sharedWorkspace] selectFile: @"/" inFileViewerRootedAtPath: @""]; - return; - } - - NSURL * representedURL = [[self window] representedURL]; - if (! representedURL) - return; - - if (selectedItem == 0) { // the actual file, let's save time - [[NSWorkspace sharedWorkspace] selectFile: [representedURL path] inFileViewerRootedAtPath: [representedURL path]]; - return; - } - - NSArray * pathComponents; - pathComponents = [representedURL pathComponents]; - if (!pathComponents) - return; - - NSMutableString * currentPath; - currentPath = [NSMutableString stringWithCapacity:1024]; - selectedItem = count - selectedItem; - - /* fix for non-startup volumes */ - if ([[pathComponents objectAtIndex:1] isEqualToString:@"Volumes"]) - selectedItem += 1; - - for (NSUInteger y = 1; y < selectedItem; y++) - [currentPath appendFormat: @"/%@", [pathComponents objectAtIndex:y]]; - - [[NSWorkspace sharedWorkspace] selectFile: currentPath inFileViewerRootedAtPath: currentPath]; -} - -- (void)rightMouseDown:(NSEvent *)o_event -{ - if ([o_event type] == NSRightMouseDown) - [self showRightClickMenuWithEvent:o_event]; - - [super mouseDown: o_event]; -} - -@end diff --git a/modules/gui/macosx/Windows.h b/modules/gui/macosx/Windows.h index c914be8668..6d0a9bfc04 100644 --- a/modules/gui/macosx/Windows.h +++ b/modules/gui/macosx/Windows.h @@ -62,8 +62,6 @@ static const float f_min_video_height = 70.0; @interface VLCVideoWindowCommon : VLCWindow -@property (nonatomic, weak) IBOutlet VLCMainWindowTitleView *titlebarView; // only set in main or detached window -@property (weak) IBOutlet NSLayoutConstraint *videoViewTopConstraint; @property (weak) IBOutlet NSLayoutConstraint *videoViewBottomConstraint; @property (nonatomic, weak) IBOutlet VLCVoutView* videoView; diff --git a/modules/gui/macosx/Windows.m b/modules/gui/macosx/Windows.m index 8d41fd1687..194b5de2f3 100644 --- a/modules/gui/macosx/Windows.m +++ b/modules/gui/macosx/Windows.m @@ -255,11 +255,6 @@ [self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; } - if (self.titlebarView) { - [self.titlebarView removeFromSuperview]; - self.titlebarView = nil; - } - [super awakeFromNib]; } @@ -528,17 +523,6 @@ [self setLevel: i_originalLevel]; } -#pragma mark - -#pragma mark Key events - -- (void)flagsChanged:(NSEvent *)theEvent -{ - BOOL b_alt_pressed = ([theEvent modifierFlags] & NSAlternateKeyMask) != 0; - [self.titlebarView informModifierPressed: b_alt_pressed]; - - [super flagsChanged:theEvent]; -} - #pragma mark - #pragma mark Lion native fullscreen handling @@ -1023,28 +1007,4 @@ [self hasBecomeFullscreen]; } -#pragma mark - -#pragma mark Accessibility stuff - -- (NSArray *)accessibilityAttributeNames -{ - if (!self.titlebarView) - return [super accessibilityAttributeNames]; - - static NSMutableArray *attributes = nil; - if (attributes == nil) { - attributes = [[super accessibilityAttributeNames] mutableCopy]; - NSArray *appendAttributes = [NSArray arrayWithObjects:NSAccessibilitySubroleAttribute, - NSAccessibilityCloseButtonAttribute, - NSAccessibilityMinimizeButtonAttribute, - NSAccessibilityZoomButtonAttribute, nil]; - - for(NSString *attribute in appendAttributes) { - if (![attributes containsObject:attribute]) - [attributes addObject:attribute]; - } - } - return attributes; -} - @end