diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj index 1f6a9b0930..21f1f6eab0 100644 --- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj +++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj @@ -115,6 +115,7 @@ 7D445D872202574B00263D34 /* VLCPlaylistModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D445D862202574B00263D34 /* VLCPlaylistModel.m */; }; 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 */; }; 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 */; }; @@ -484,6 +485,8 @@ 7D445D8C2203375100263D34 /* VLCPlaylistMenuController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCPlaylistMenuController.h; sourceTree = ""; }; 7D445D8D2203375100263D34 /* VLCPlaylistMenuController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCPlaylistMenuController.m; sourceTree = ""; }; 7D445D8F220339D400263D34 /* VLCPlaylistMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VLCPlaylistMenu.xib; sourceTree = ""; }; + 7D460B0A229EB4C700097948 /* VLCDragDropView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCDragDropView.h; sourceTree = ""; }; + 7D460B0B229EB4C700097948 /* VLCDragDropView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCDragDropView.m; sourceTree = ""; }; 7D5678EB1D5BA1DC002698F3 /* VLCApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCApplication.h; sourceTree = ""; }; 7D5678EC1D5BA1DC002698F3 /* VLCApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCApplication.m; sourceTree = ""; }; 7D5678EE1D5BA397002698F3 /* VLCMainWindowControlsBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCMainWindowControlsBar.h; sourceTree = ""; }; @@ -848,6 +851,8 @@ 7D2FFA3F227B8A5B0085D649 /* VLCLinearProgressIndicator.m */, 7D2008182289835C002679DF /* VLCTrackingView.h */, 7D2008192289835C002679DF /* VLCTrackingView.m */, + 7D460B0A229EB4C700097948 /* VLCDragDropView.h */, + 7D460B0B229EB4C700097948 /* VLCDragDropView.m */, ); path = views; sourceTree = ""; @@ -1703,6 +1708,7 @@ 1C3113A71E508C6900D4DD76 /* VLCLogWindowController.m in Sources */, 1C3113A91E508C6900D4DD76 /* VLCDocumentController.m in Sources */, 1C3113AB1E508C6900D4DD76 /* VLCExtensionsDialogProvider.m in Sources */, + 7D460B0C229EB4C700097948 /* VLCDragDropView.m in Sources */, 7D445D872202574B00263D34 /* VLCPlaylistModel.m in Sources */, 7DE2F0442282C84A0040DD0A /* VLCLibraryAudioDataSource.m in Sources */, 7D0F640C2202163E00FDB91F /* VLCPlaylistDataSource.m in Sources */, diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am index e4ed2335dd..83c986b778 100644 --- a/modules/gui/macosx/Makefile.am +++ b/modules/gui/macosx/Makefile.am @@ -171,6 +171,8 @@ libmacosx_plugin_la_SOURCES = \ gui/macosx/views/VLCDefaultValueSlider.m \ gui/macosx/views/VLCDefaultValueSliderCell.h \ gui/macosx/views/VLCDefaultValueSliderCell.m \ + gui/macosx/views/VLCDragDropView.h \ + gui/macosx/views/VLCDragDropView.m \ gui/macosx/views/VLCFSPanelDraggableView.h \ gui/macosx/views/VLCFSPanelDraggableView.m \ gui/macosx/views/VLCHUDOutlineView.h \ diff --git a/modules/gui/macosx/extensions/misc.h b/modules/gui/macosx/extensions/misc.h index afe4fdfe9b..0317ae718e 100644 --- a/modules/gui/macosx/extensions/misc.h +++ b/modules/gui/macosx/extensions/misc.h @@ -23,31 +23,6 @@ #import -/***************************************************************************** - * VLCDragDropView - * - * Disables default drag / drop behaviour of an NSImageView. - * set it for all sub image views withing an VLCDragDropView. - *****************************************************************************/ - - -@interface VLCDropDisabledImageView : NSImageView - -@end - -/***************************************************************************** - * VLCDragDropView - *****************************************************************************/ - -@interface VLCDragDropView : NSView - -@property (nonatomic, assign) id dropHandler; -@property (nonatomic, assign) BOOL drawBorder; - -- (void)enablePlaylistItems; - -@end - /***************************************************************************** * PositionFormatter interface * diff --git a/modules/gui/macosx/extensions/misc.m b/modules/gui/macosx/extensions/misc.m index 793346e956..d81d758c56 100644 --- a/modules/gui/macosx/extensions/misc.m +++ b/modules/gui/macosx/extensions/misc.m @@ -22,133 +22,7 @@ *****************************************************************************/ #import "misc.h" - -#import -#import - -#import "extensions/NSString+Helpers.h" -#import "main/CompatibilityFixes.h" -#import "main/VLCMain.h" -#import "menus/VLCMainMenu.h" -#import "windows/mainwindow/VLCControlsBarCommon.h" - -/***************************************************************************** - * VLCDragDropView - *****************************************************************************/ - -@implementation VLCDropDisabledImageView - -- (void)awakeFromNib -{ - [self unregisterDraggedTypes]; -} - -@end - -/***************************************************************************** - * VLCDragDropView - *****************************************************************************/ - -@interface VLCDragDropView() -{ - bool b_activeDragAndDrop; -} -@end - -@implementation VLCDragDropView - -- (id)initWithFrame:(NSRect)frame -{ - self = [super initWithFrame:frame]; - if (self) { - // default value - [self setDrawBorder:YES]; - } - - return self; -} - -- (void)enablePlaylistItems -{ - [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]]; -} - -- (BOOL)mouseDownCanMoveWindow -{ - return YES; -} - -- (void)dealloc -{ - [self unregisterDraggedTypes]; -} - -- (void)awakeFromNib -{ - [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]]; -} - -- (NSDragOperation)draggingEntered:(id )sender -{ - if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric) { - b_activeDragAndDrop = YES; - [self setNeedsDisplay:YES]; - - return NSDragOperationCopy; - } - - return NSDragOperationNone; -} - -- (void)draggingEnded:(id < NSDraggingInfo >)sender -{ - b_activeDragAndDrop = NO; - [self setNeedsDisplay:YES]; -} - -- (void)draggingExited:(id < NSDraggingInfo >)sender -{ - b_activeDragAndDrop = NO; - [self setNeedsDisplay:YES]; -} - -- (BOOL)prepareForDragOperation:(id )sender -{ - return YES; -} - -- (BOOL)performDragOperation:(id )sender -{ - BOOL b_returned = NO; - - if (_dropHandler && [_dropHandler respondsToSelector:@selector(performDragOperation:)]) - b_returned = [_dropHandler performDragOperation:sender]; - // default - // FIXME: implement drag and drop _on_ new playlist -// b_returned = [[[VLCMain sharedInstance] playlist] performDragOperation:sender]; - - [self setNeedsDisplay:YES]; - return b_returned; -} - -- (void)concludeDragOperation:(id )sender -{ - [self setNeedsDisplay:YES]; -} - -- (void)drawRect:(NSRect)dirtyRect -{ - if ([self drawBorder] && b_activeDragAndDrop) { - NSRect frameRect = [self bounds]; - - [[NSColor selectedControlColor] set]; - NSFrameRectWithWidthUsingOperation(frameRect, 2., NSCompositeSourceOver); - } - - [super drawRect:dirtyRect]; -} - -@end +#import "NSString+Helpers.h" @interface PositionFormatter() { diff --git a/modules/gui/macosx/views/VLCDragDropView.h b/modules/gui/macosx/views/VLCDragDropView.h new file mode 100644 index 0000000000..045979cdd6 --- /dev/null +++ b/modules/gui/macosx/views/VLCDragDropView.h @@ -0,0 +1,46 @@ +/***************************************************************************** + * VLCDragDropView.h: MacOS X interface module + ***************************************************************************** + * Copyright (C) 2003 - 2019 VLC authors and VideoLAN + * + * Authors: Derk-Jan Hartman + * Felix Paul Kühne + * David Fuhrmann + * + * 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 + +NS_ASSUME_NONNULL_BEGIN + +/***************************************************************************** + * Disables default drag / drop behaviour of an NSImageView. + * set it for all sub image views withing an VLCDragDropView. + *****************************************************************************/ +@interface VLCDropDisabledImageView : NSImageView + +@end + +@interface VLCDragDropView : NSView + +@property (nonatomic, assign) id dropHandler; +@property (nonatomic, assign) BOOL drawBorder; + +- (void)enablePlaylistItems; + +@end + +NS_ASSUME_NONNULL_END diff --git a/modules/gui/macosx/views/VLCDragDropView.m b/modules/gui/macosx/views/VLCDragDropView.m new file mode 100644 index 0000000000..e73b35d322 --- /dev/null +++ b/modules/gui/macosx/views/VLCDragDropView.m @@ -0,0 +1,135 @@ +/***************************************************************************** + * VLCDragDropView.m: MacOS X interface module + ***************************************************************************** + * Copyright (C) 2003 - 2019 VLC authors and VideoLAN + * + * Authors: Derk-Jan Hartman + * Felix Paul Kühne + * David Fuhrmann + * + * 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 "VLCDragDropView.h" + +@implementation VLCDropDisabledImageView + +- (void)awakeFromNib +{ + [self unregisterDraggedTypes]; +} + +@end + +@interface VLCDragDropView() +{ + bool b_activeDragAndDrop; +} +@end + +@implementation VLCDragDropView + +- (id)initWithFrame:(NSRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + // default value + [self setDrawBorder:YES]; + } + + return self; +} + +- (void)enablePlaylistItems +{ + [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]]; +} + +- (BOOL)mouseDownCanMoveWindow +{ + return YES; +} + +- (void)dealloc +{ + [self unregisterDraggedTypes]; +} + +- (void)awakeFromNib +{ + [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]]; +} + +- (NSDragOperation)draggingEntered:(id )sender +{ + if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric) { + b_activeDragAndDrop = YES; + [self setNeedsDisplay:YES]; + + return NSDragOperationCopy; + } + + return NSDragOperationNone; +} + +- (void)draggingEnded:(id < NSDraggingInfo >)sender +{ + b_activeDragAndDrop = NO; + [self setNeedsDisplay:YES]; +} + +- (void)draggingExited:(id < NSDraggingInfo >)sender +{ + b_activeDragAndDrop = NO; + [self setNeedsDisplay:YES]; +} + +- (BOOL)prepareForDragOperation:(id )sender +{ + return YES; +} + +- (BOOL)performDragOperation:(id )sender +{ + BOOL b_returned = NO; + + if (_dropHandler && [_dropHandler respondsToSelector:@selector(performDragOperation:)]) + b_returned = [_dropHandler performDragOperation:sender]; + // default + // FIXME: implement drag and drop _on_ new playlist + // b_returned = [[[VLCMain sharedInstance] playlist] performDragOperation:sender]; + + [self setNeedsDisplay:YES]; + return b_returned; +} + +- (void)concludeDragOperation:(id )sender +{ + [self setNeedsDisplay:YES]; +} + +- (void)drawRect:(NSRect)dirtyRect +{ + if ([self drawBorder] && b_activeDragAndDrop) { + NSRect frameRect = [self bounds]; + + [[NSColor selectedControlColor] set]; + NSFrameRectWithWidthUsingOperation(frameRect, 2., NSCompositeSourceOver); + } + + [super drawRect:dirtyRect]; +} + +@end diff --git a/modules/gui/macosx/windows/convertandsave/VLCConvertAndSaveWindowController.m b/modules/gui/macosx/windows/convertandsave/VLCConvertAndSaveWindowController.m index 78585bfa55..8d2ddcbc85 100644 --- a/modules/gui/macosx/windows/convertandsave/VLCConvertAndSaveWindowController.m +++ b/modules/gui/macosx/windows/convertandsave/VLCConvertAndSaveWindowController.m @@ -22,7 +22,6 @@ #import "VLCConvertAndSaveWindowController.h" -#import "extensions/misc.h" #import "extensions/NSString+Helpers.h" #import "extensions/NSView+VLCAdditions.h" #import "main/VLCMain.h" @@ -30,6 +29,7 @@ #import "panels/dialogs/VLCTextfieldPanelController.h" #import "playlist/VLCPlaylistController.h" #import "playlist/VLCPlaylistModel.h" +#import "views/VLCDragDropView.h" #import "windows/VLCOpenInputMetadata.h" #import diff --git a/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.h b/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.h index a99e9d8f35..a5e3ce3637 100644 --- a/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.h +++ b/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.h @@ -23,10 +23,10 @@ #import -#import "extensions/misc.h" -#import "views/VLCBottomBarView.h" -#import "views/VLCTimeField.h" -#import "views/VLCSlider.h" +@class VLCDragDropView; +@class VLCSlider; +@class VLCTimeField; +@class VLCBottomBarView; /***************************************************************************** * VLCControlsBarCommon diff --git a/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m b/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m index 2276450a11..2806825f46 100644 --- a/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m +++ b/modules/gui/macosx/windows/mainwindow/VLCControlsBarCommon.m @@ -28,6 +28,11 @@ #import "playlist/VLCPlaylistController.h" #import "playlist/VLCPlayerController.h" +#import "views/VLCBottomBarView.h" +#import "views/VLCDragDropView.h" +#import "views/VLCTimeField.h" +#import "views/VLCSlider.h" + /***************************************************************************** * VLCControlsBarCommon * diff --git a/modules/gui/macosx/windows/video/VLCVideoWindowCommon.m b/modules/gui/macosx/windows/video/VLCVideoWindowCommon.m index 9851a2f230..8c69578096 100644 --- a/modules/gui/macosx/windows/video/VLCVideoWindowCommon.m +++ b/modules/gui/macosx/windows/video/VLCVideoWindowCommon.m @@ -34,6 +34,7 @@ #import "playlist/VLCPlaylistController.h" #import "playlist/VLCPlayerController.h" #import "library/VLCLibraryWindow.h" +#import "views/VLCBottomBarView.h" const CGFloat VLCVideoWindowCommonMinimalHeight = 70.; NSString *VLCVideoWindowShouldShowFullscreenController = @"VLCVideoWindowShouldShowFullscreenController"; diff --git a/po/POTFILES.in b/po/POTFILES.in index 8c22bc2705..0f8804d3a9 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -575,6 +575,8 @@ modules/gui/macosx/views/VLCDefaultValueSlider.h modules/gui/macosx/views/VLCDefaultValueSlider.m modules/gui/macosx/views/VLCDefaultValueSliderCell.h modules/gui/macosx/views/VLCDefaultValueSliderCell.m +modules/gui/macosx/views/VLCDragDropView.h +modules/gui/macosx/views/VLCDragDropView.m modules/gui/macosx/views/VLCFSPanelDraggableView.h modules/gui/macosx/views/VLCFSPanelDraggableView.m modules/gui/macosx/views/VLCHUDOutlineView.h