[vlc-commits] macosx: split drag & drop view from misc

Felix Paul Kühne git at videolan.org
Wed May 29 15:38:47 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Wed May 29 14:50:19 2019 +0200| [540f3a007378302b8eca03da2848d378313e59ce] | committer: Felix Paul Kühne

macosx: split drag & drop view from misc

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=540f3a007378302b8eca03da2848d378313e59ce
---

 .../package/macosx/VLC.xcodeproj/project.pbxproj   |   6 +
 modules/gui/macosx/Makefile.am                     |   2 +
 modules/gui/macosx/extensions/misc.h               |  25 ----
 modules/gui/macosx/extensions/misc.m               | 128 +------------------
 modules/gui/macosx/views/VLCDragDropView.h         |  46 +++++++
 modules/gui/macosx/views/VLCDragDropView.m         | 135 +++++++++++++++++++++
 .../VLCConvertAndSaveWindowController.m            |   2 +-
 .../windows/mainwindow/VLCControlsBarCommon.h      |   8 +-
 .../windows/mainwindow/VLCControlsBarCommon.m      |   5 +
 .../macosx/windows/video/VLCVideoWindowCommon.m    |   1 +
 po/POTFILES.in                                     |   2 +
 11 files changed, 203 insertions(+), 157 deletions(-)

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 = "<group>"; };
 		7D445D8D2203375100263D34 /* VLCPlaylistMenuController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCPlaylistMenuController.m; sourceTree = "<group>"; };
 		7D445D8F220339D400263D34 /* VLCPlaylistMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VLCPlaylistMenu.xib; sourceTree = "<group>"; };
+		7D460B0A229EB4C700097948 /* VLCDragDropView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCDragDropView.h; sourceTree = "<group>"; };
+		7D460B0B229EB4C700097948 /* VLCDragDropView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCDragDropView.m; sourceTree = "<group>"; };
 		7D5678EB1D5BA1DC002698F3 /* VLCApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCApplication.h; sourceTree = "<group>"; };
 		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>"; };
@@ -848,6 +851,8 @@
 				7D2FFA3F227B8A5B0085D649 /* VLCLinearProgressIndicator.m */,
 				7D2008182289835C002679DF /* VLCTrackingView.h */,
 				7D2008192289835C002679DF /* VLCTrackingView.m */,
+				7D460B0A229EB4C700097948 /* VLCDragDropView.h */,
+				7D460B0B229EB4C700097948 /* VLCDragDropView.m */,
 			);
 			path = views;
 			sourceTree = "<group>";
@@ -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
@@ -24,31 +24,6 @@
 #import <Cocoa/Cocoa.h>
 
 /*****************************************************************************
- * VLCDragDropView
- *
- * Disables default drag / drop behaviour of an NSImageView.
- * set it for all sub image views withing an VLCDragDropView.
- *****************************************************************************/
-
-
- at interface VLCDropDisabledImageView : NSImageView
-
- at end
-
-/*****************************************************************************
- * VLCDragDropView
- *****************************************************************************/
-
- at interface VLCDragDropView : NSView
-
- at property (nonatomic, assign) id dropHandler;
- at property (nonatomic, assign) BOOL drawBorder;
-
-- (void)enablePlaylistItems;
-
- at end
-
-/*****************************************************************************
  * PositionFormatter interface
  *
  * Formats a text field to only accept decimals and :
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 <vlc_common.h>
-#import <vlc_actions.h>
-
-#import "extensions/NSString+Helpers.h"
-#import "main/CompatibilityFixes.h"
-#import "main/VLCMain.h"
-#import "menus/VLCMainMenu.h"
-#import "windows/mainwindow/VLCControlsBarCommon.h"
-
-/*****************************************************************************
- * VLCDragDropView
- *****************************************************************************/
-
- at implementation VLCDropDisabledImageView
-
-- (void)awakeFromNib
-{
-    [self unregisterDraggedTypes];
-}
-
- at end
-
-/*****************************************************************************
- * VLCDragDropView
- *****************************************************************************/
-
- at interface VLCDragDropView()
-{
-    bool b_activeDragAndDrop;
-}
- at end
-
- at 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 <NSDraggingInfo>)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 <NSDraggingInfo>)sender
-{
-    return YES;
-}
-
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)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 <NSDraggingInfo>)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];
-}
-
- at 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 <hartman # videolan dot org>
+ *          Felix Paul Kühne <fkuehne # videolan dot org>
+ *          David Fuhrmann <dfuhrmann # videolan dot org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * 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
+
+/*****************************************************************************
+ * Disables default drag / drop behaviour of an NSImageView.
+ * set it for all sub image views withing an VLCDragDropView.
+ *****************************************************************************/
+ at interface VLCDropDisabledImageView : NSImageView
+
+ at end
+
+ at interface VLCDragDropView : NSView
+
+ at property (nonatomic, assign) id dropHandler;
+ at property (nonatomic, assign) BOOL drawBorder;
+
+- (void)enablePlaylistItems;
+
+ at 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 <hartman # videolan dot org>
+ *          Felix Paul Kühne <fkuehne # videolan dot org>
+ *          David Fuhrmann <dfuhrmann # videolan dot org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * 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"
+
+ at implementation VLCDropDisabledImageView
+
+- (void)awakeFromNib
+{
+    [self unregisterDraggedTypes];
+}
+
+ at end
+
+ at interface VLCDragDropView()
+{
+    bool b_activeDragAndDrop;
+}
+ at end
+
+ at 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 <NSDraggingInfo>)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 <NSDraggingInfo>)sender
+{
+    return YES;
+}
+
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)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 <NSDraggingInfo>)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];
+}
+
+ at 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 <vlc_url.h>
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 <Cocoa/Cocoa.h>
 
-#import "extensions/misc.h"
-#import "views/VLCBottomBarView.h"
-#import "views/VLCTimeField.h"
-#import "views/VLCSlider.h"
+ at class VLCDragDropView;
+ at class VLCSlider;
+ at class VLCTimeField;
+ at 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



More information about the vlc-commits mailing list