diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj index 84bb08d28ea62a30ec53ffb60a20a5a0a640990b..c6a4fde941a3467de42aad5820f0287670ba29c7 100644 --- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj +++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj @@ -120,6 +120,7 @@ 7D445D8B22032B9200263D34 /* VLCPlaylistTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D445D8A22032B9200263D34 /* VLCPlaylistTableView.m */; }; 7D445D8E2203375100263D34 /* VLCPlaylistMenuController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D445D8D2203375100263D34 /* VLCPlaylistMenuController.m */; }; 7D460B0C229EB4C700097948 /* VLCDragDropView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D460B0B229EB4C700097948 /* VLCDragDropView.m */; }; + 7D61DCE4236C1937008133CF /* VLCCustomWindowButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D61DCE3236C1937008133CF /* VLCCustomWindowButton.m */; }; 7D66D4362200BC340040D04A /* VLCClickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D66D4352200BC340040D04A /* VLCClickerManager.m */; }; 7D66D4392200C5B80040D04A /* VLCVideoFilterHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D66D4382200C5B80040D04A /* VLCVideoFilterHelper.m */; }; 7D66D43C2200D6090040D04A /* VLCDetachedVideoWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D66D43B2200D6090040D04A /* VLCDetachedVideoWindow.m */; }; @@ -497,6 +498,8 @@ 7D5678EC1D5BA1DC002698F3 /* VLCApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCApplication.m; sourceTree = "<group>"; }; 7D5678EE1D5BA397002698F3 /* VLCMainWindowControlsBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCMainWindowControlsBar.h; sourceTree = "<group>"; }; 7D5678EF1D5BA397002698F3 /* VLCMainWindowControlsBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCMainWindowControlsBar.m; sourceTree = "<group>"; }; + 7D61DCE2236C1937008133CF /* VLCCustomWindowButton.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCCustomWindowButton.h; sourceTree = "<group>"; }; + 7D61DCE3236C1937008133CF /* VLCCustomWindowButton.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCCustomWindowButton.m; sourceTree = "<group>"; }; 7D66D4342200BC340040D04A /* VLCClickerManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCClickerManager.h; sourceTree = "<group>"; }; 7D66D4352200BC340040D04A /* VLCClickerManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCClickerManager.m; sourceTree = "<group>"; }; 7D66D4372200C5B80040D04A /* VLCVideoFilterHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCVideoFilterHelper.h; sourceTree = "<group>"; }; @@ -825,6 +828,8 @@ 1C1ED5062204AB7C00811EC0 /* views */ = { isa = PBXGroup; children = ( + 7D61DCE2236C1937008133CF /* VLCCustomWindowButton.h */, + 7D61DCE3236C1937008133CF /* VLCCustomWindowButton.m */, 6B0292E41F43256300A50082 /* VLCBottomBarView.h */, 6B0292E51F43256300A50082 /* VLCBottomBarView.m */, 6B6A499A1DFD9B23009128AC /* VLCDefaultValueSlider.h */, @@ -1658,6 +1663,7 @@ 7D2554C522C8E8B500F2D9C2 /* VLCMediaSourceDeviceCollectionViewItem.m in Sources */, 1CCC88F52078A3D500E5626F /* SyncTracks.xib in Sources */, 1CCC88F62078A3D500E5626F /* VLCInformationWindow.xib in Sources */, + 7D61DCE4236C1937008133CF /* VLCCustomWindowButton.m in Sources */, 7DFFF90123682D4800C8B0C9 /* VLCDetachedAudioWindow.m in Sources */, 7D66D4392200C5B80040D04A /* VLCVideoFilterHelper.m in Sources */, 7D445D812202524000263D34 /* VLCPlaylistController.m in Sources */, diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am index f4a2692001627dc27c9dbacdc659a53b3bda4200..ba42cc88006bcc42d9c52f596a7230f5a2a3f801 100644 --- a/modules/gui/macosx/Makefile.am +++ b/modules/gui/macosx/Makefile.am @@ -173,6 +173,8 @@ libmacosx_plugin_la_SOURCES = \ gui/macosx/preferences/prefs_widgets.m \ gui/macosx/views/VLCBottomBarView.h \ gui/macosx/views/VLCBottomBarView.m \ + gui/macosx/views/VLCCustomWindowButton.h \ + gui/macosx/views/VLCCustomWindowButton.m \ gui/macosx/views/VLCDefaultValueSlider.h \ gui/macosx/views/VLCDefaultValueSlider.m \ gui/macosx/views/VLCDefaultValueSliderCell.h \ @@ -456,7 +458,19 @@ libmacosx_plugin_la_RES = \ gui/macosx/Resources/Button-Icons/VLCVolumeOnTemplate.pdf \ gui/macosx/Resources/Button-Icons/VLCVolumeOffTemplate.pdf \ gui/macosx/Resources/Button-Icons/VLCClearLogTemplate.pdf \ - gui/macosx/Resources/Button-Icons/VLCSaveTemplate.pdf + gui/macosx/Resources/Button-Icons/VLCSaveTemplate.pdf \ + gui/macosx/Resources/Button-Icons/window-close-graphite.png \ + gui/macosx/Resources/Button-Icons/window-close-graphite@2x.png \ + gui/macosx/Resources/Button-Icons/window-close-on-graphite.png \ + gui/macosx/Resources/Button-Icons/window-close-on-graphite@2x.png \ + gui/macosx/Resources/Button-Icons/window-close-on.png \ + gui/macosx/Resources/Button-Icons/window-close-on@2x.png \ + gui/macosx/Resources/Button-Icons/window-close-over-graphite.png \ + gui/macosx/Resources/Button-Icons/window-close-over-graphite@2x.png \ + gui/macosx/Resources/Button-Icons/window-close-over.png \ + gui/macosx/Resources/Button-Icons/window-close-over@2x.png \ + gui/macosx/Resources/Button-Icons/window-close.png \ + gui/macosx/Resources/Button-Icons/window-close@2x.png libmacosx_plugin_la_RES += \ gui/macosx/Resources/dsa_pub.pem \ diff --git a/modules/gui/macosx/Resources/Button-Icons/window-close-graphite.png b/modules/gui/macosx/Resources/Button-Icons/window-close-graphite.png new file mode 100644 index 0000000000000000000000000000000000000000..af957723d7421de0e6c94527eaa043a3a5930025 Binary files /dev/null and b/modules/gui/macosx/Resources/Button-Icons/window-close-graphite.png differ diff --git a/modules/gui/macosx/Resources/Button-Icons/window-close-graphite@2x.png b/modules/gui/macosx/Resources/Button-Icons/window-close-graphite@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..1528672a46bdda844a19a3e89eaf16fd4a9fbd94 Binary files /dev/null and b/modules/gui/macosx/Resources/Button-Icons/window-close-graphite@2x.png differ diff --git a/modules/gui/macosx/Resources/Button-Icons/window-close-on-graphite.png b/modules/gui/macosx/Resources/Button-Icons/window-close-on-graphite.png new file mode 100644 index 0000000000000000000000000000000000000000..4e249d30dca285be9fed2bb587265373f1db3b86 Binary files /dev/null and b/modules/gui/macosx/Resources/Button-Icons/window-close-on-graphite.png differ diff --git a/modules/gui/macosx/Resources/Button-Icons/window-close-on-graphite@2x.png b/modules/gui/macosx/Resources/Button-Icons/window-close-on-graphite@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..bd21e24eff5df0a13736cab41966030e85952331 Binary files /dev/null and b/modules/gui/macosx/Resources/Button-Icons/window-close-on-graphite@2x.png differ diff --git a/modules/gui/macosx/Resources/Button-Icons/window-close-on.png b/modules/gui/macosx/Resources/Button-Icons/window-close-on.png new file mode 100644 index 0000000000000000000000000000000000000000..ffdd45feeafd28fa803a5bc98ee8ae990fbec877 Binary files /dev/null and b/modules/gui/macosx/Resources/Button-Icons/window-close-on.png differ diff --git a/modules/gui/macosx/Resources/Button-Icons/window-close-on@2x.png b/modules/gui/macosx/Resources/Button-Icons/window-close-on@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..f990e2bccc032a29e445405e7be6306997027007 Binary files /dev/null and b/modules/gui/macosx/Resources/Button-Icons/window-close-on@2x.png differ diff --git a/modules/gui/macosx/Resources/Button-Icons/window-close-over-graphite.png b/modules/gui/macosx/Resources/Button-Icons/window-close-over-graphite.png new file mode 100644 index 0000000000000000000000000000000000000000..4cfe9b990817874df3339219e91c0824fe2f88a4 Binary files /dev/null and b/modules/gui/macosx/Resources/Button-Icons/window-close-over-graphite.png differ diff --git a/modules/gui/macosx/Resources/Button-Icons/window-close-over-graphite@2x.png b/modules/gui/macosx/Resources/Button-Icons/window-close-over-graphite@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..d29b2144a0bb520a5a375c9939b50c58d5fa1949 Binary files /dev/null and b/modules/gui/macosx/Resources/Button-Icons/window-close-over-graphite@2x.png differ diff --git a/modules/gui/macosx/Resources/Button-Icons/window-close-over.png b/modules/gui/macosx/Resources/Button-Icons/window-close-over.png new file mode 100644 index 0000000000000000000000000000000000000000..7310bee4cffa41ad6555981c72c2482d029f5150 Binary files /dev/null and b/modules/gui/macosx/Resources/Button-Icons/window-close-over.png differ diff --git a/modules/gui/macosx/Resources/Button-Icons/window-close-over@2x.png b/modules/gui/macosx/Resources/Button-Icons/window-close-over@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..2be47eae525f58f1af0a305eb3d49ee0ac61e6a7 Binary files /dev/null and b/modules/gui/macosx/Resources/Button-Icons/window-close-over@2x.png differ diff --git a/modules/gui/macosx/Resources/Button-Icons/window-close.png b/modules/gui/macosx/Resources/Button-Icons/window-close.png new file mode 100644 index 0000000000000000000000000000000000000000..9c29567c51185a97924381d61b5502055e6cee22 Binary files /dev/null and b/modules/gui/macosx/Resources/Button-Icons/window-close.png differ diff --git a/modules/gui/macosx/Resources/Button-Icons/window-close@2x.png b/modules/gui/macosx/Resources/Button-Icons/window-close@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..f32df18a6c3eca03df8ec97a9a090aa3a3d4aebb Binary files /dev/null and b/modules/gui/macosx/Resources/Button-Icons/window-close@2x.png differ diff --git a/modules/gui/macosx/views/VLCCustomWindowButton.h b/modules/gui/macosx/views/VLCCustomWindowButton.h new file mode 100644 index 0000000000000000000000000000000000000000..4170008af490ac7c3720d9683681714f6e717a9e --- /dev/null +++ b/modules/gui/macosx/views/VLCCustomWindowButton.h @@ -0,0 +1,56 @@ +/***************************************************************************** +* VLCCustomWindowButton.h: MacOS X interface module +***************************************************************************** +* Copyright (C) 2011-2019 VLC authors and VideoLAN +* +* Authors: Felix Paul Kühne <fkuehne # videolan -dot- org> +* David Fuhrmann <dfuhrmann at 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 +* 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> + +NS_ASSUME_NONNULL_BEGIN + +@interface VLCWindowButtonCell : NSButtonCell + +@end + +@interface VLCCustomWindowButtonPrototype : NSButton + +- (void)performDefaultButtonAction:(id)sender; + +@end + +@interface VLCCustomWindowCloseButton : VLCCustomWindowButtonPrototype + +@end + + +@interface VLCCustomWindowMinimizeButton : VLCCustomWindowButtonPrototype + +@end + + +@interface VLCCustomWindowZoomButton : VLCCustomWindowButtonPrototype + +@end + +@interface VLCCustomWindowFullscreenButton : VLCCustomWindowButtonPrototype + +@end + +NS_ASSUME_NONNULL_END diff --git a/modules/gui/macosx/views/VLCCustomWindowButton.m b/modules/gui/macosx/views/VLCCustomWindowButton.m new file mode 100644 index 0000000000000000000000000000000000000000..260a70f74959ca9b7195049a4bb89c7ba199df30 --- /dev/null +++ b/modules/gui/macosx/views/VLCCustomWindowButton.m @@ -0,0 +1,262 @@ +/***************************************************************************** +* VLCCustomWindowButton.m: MacOS X interface module +***************************************************************************** +* Copyright (C) 2011-2019 VLC authors and VideoLAN +* +* Authors: Felix Paul Kühne <fkuehne # videolan -dot- org> +* David Fuhrmann <dfuhrmann at 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 +* 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 "VLCCustomWindowButton.h" + +@interface VLCCustomWindowButtonPrototype() + +@property (readwrite, retain) NSImage *buttonImage; +@property (readwrite, retain) NSImage *hoverButtonImage; +@property (readwrite, retain) NSImage *onClickButtonImage; + +- (void)loadButtonIcons; +- (NSArray *)extendedAccessibilityAttributeNames:(NSArray *)theAttributeNames; +- (id)extendedAccessibilityAttributeValue:(NSString *)theAttributeName; +- (NSNumber *)extendedAccessibilityIsAttributeSettable:(NSString *)theAttributeName; + +@end + +@implementation VLCWindowButtonCell + +- (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 + +@implementation VLCCustomWindowButtonPrototype + ++ (Class)cellClass +{ + return [VLCWindowButtonCell class]; +} + +- (instancetype)initWithCoder:(NSCoder *)coder +{ + self = [super initWithCoder:coder]; + if (self) { + [self commonInitializer]; + } + return self; +} + +- (instancetype)initWithFrame:(NSRect)frameRect +{ + self = [super initWithFrame:frameRect]; + if (self) { + [self commonInitializer]; + } + return self; +} + +- (void)commonInitializer +{ + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(controlTintChanged:) + name:NSControlTintDidChangeNotification + object:nil]; + [self loadButtonIcons]; + [self setTarget:self]; + [self setAction:@selector(performDefaultButtonAction:)]; +} + +- (NSImage *)getButtonImage:(NSString *)imageName +{ + if ([NSColor currentControlTint] != NSBlueControlTint) { + imageName = [imageName stringByAppendingString:@"-graphite"]; + } + + return [NSImage imageNamed:imageName]; +} + +- (void)controlTintChanged:(NSNotification *)notification +{ + [self loadButtonIcons]; + [self setNeedsDisplay]; +} + +- (void)loadButtonIcons +{ + [self setImage:self.buttonImage]; + [self setAlternateImage:self.hoverButtonImage]; +} + +- (void)mouseEntered:(NSEvent *)event +{ + [self setImage:self.hoverButtonImage]; + [super mouseEntered:event]; +} + +- (void)mouseExited:(NSEvent *)event +{ + [self setImage:self.buttonImage]; + [super mouseExited:event]; +} + +- (void)performDefaultButtonAction:(id)sender +{ +} + +- (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); +} + +- (void)loadButtonIcons +{ + self.buttonImage = [self getButtonImage:@"window-close"]; + self.hoverButtonImage = [self getButtonImage:@"window-close-over"]; + self.onClickButtonImage = [self getButtonImage:@"window-close-on"]; + + [super loadButtonIcons]; +} + +- (void)performDefaultButtonAction:(id)sender +{ + if (self.window.styleMask & NSWindowStyleMaskClosable) { + [[self window] performClose:sender]; + } else { + [[self window] close]; + } +} + +@end + +@implementation VLCCustomWindowMinimizeButton + +- (id)extendedAccessibilityAttributeValue:(NSString *)theAttributeName +{ + return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityMinimizeButtonAttribute : nil); +} + +- (void)loadButtonIcons +{ + self.buttonImage = [self getButtonImage:@"window-minimize"]; + self.hoverButtonImage = [self getButtonImage:@"window-minimize-over"]; + self.onClickButtonImage = [self getButtonImage:@"window-minimize-on"]; + + [super loadButtonIcons]; +} + +- (void)performDefaultButtonAction:(id)sender +{ + [[self window] miniaturize: sender]; +} + +@end + +@implementation VLCCustomWindowZoomButton + +- (id)extendedAccessibilityAttributeValue:(NSString *)theAttributeName +{ + return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityZoomButtonAttribute : nil); +} + +- (void)loadButtonIcons +{ + self.buttonImage = [self getButtonImage:@"window-zoom"]; + self.hoverButtonImage = [self getButtonImage:@"window-zoom-over"]; + self.onClickButtonImage = [self getButtonImage:@"window-zoom-on"]; + + [super loadButtonIcons]; +} + +- (void)performDefaultButtonAction:(id)sender +{ + [[self window] performZoom: sender]; +} + +@end + +@implementation VLCCustomWindowFullscreenButton + +- (id)extendedAccessibilityAttributeValue:(NSString *)theAttributeName +{ + return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? NSAccessibilityFullScreenButtonAttribute : nil); +} + +- (void)loadButtonIcons +{ + self.buttonImage = [self getButtonImage:@"window-fullscreen"]; + self.hoverButtonImage = [self getButtonImage:@"window-fullscreen-over"]; + self.onClickButtonImage = [self getButtonImage:@"window-fullscreen-on"]; + + [super loadButtonIcons]; +} + +- (void)performDefaultButtonAction:(id)sender +{ + [[self window] toggleFullScreen:self]; +} + +@end diff --git a/po/POTFILES.in b/po/POTFILES.in index 156bfd4837fae1985ed41ecca526af145f4fd581..d2771b57ec99fbdfff9547a15f26da17a7761d07 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -578,6 +578,8 @@ modules/gui/macosx/preferences/prefs_widgets.h modules/gui/macosx/preferences/prefs_widgets.m modules/gui/macosx/views/VLCBottomBarView.h modules/gui/macosx/views/VLCBottomBarView.m +modules/gui/macosx/views/VLCCustomWindowButton.h +modules/gui/macosx/views/VLCCustomWindowButton.m modules/gui/macosx/views/VLCDefaultValueSlider.h modules/gui/macosx/views/VLCDefaultValueSlider.m modules/gui/macosx/views/VLCDefaultValueSliderCell.h