[vlc-commits] [Git][videolan/vlc][master] 14 commits: macosx: Add starter VLCFileDragRecognisingView
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Sat Feb 8 09:57:28 UTC 2025
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
937f397d by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Add starter VLCFileDragRecognisingView
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
ae32aa8d by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Add setupDragRecognition method to VLCFileDragRecognisingView
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
4f4ecab3 by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Add inits for VLCFileDragRecognisingView
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
6d9fcd4e by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Set up drag recognition on awake from nib in file drag recognising view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
0f19d940 by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Constify, clean up pasteboard handling method in VLCLibraryWindow
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
e3ca629a by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Unregister dragged types on file drag recognising view on dealloc
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
9cbfb043 by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Implement draggingEntered in VLCFileDragRecognisingView
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
4b05dd97 by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Implement performDragOperation in FileDragRecognisingView
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
954b5a07 by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Return YES for prepareForDragOperation in file drag recognising view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
feeb4a98 by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Inherit VLCFileDragRecognisingView in VLCDragDropView
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
85bc3afe by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Implement standard pasteboard filename handling as playqueue items in file drag recognising view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
3e039431 by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Use play queue pasteboard handling method from file drag handling view in library window
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
91918e91 by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Inherit from file drag recognising view in VLCVoutView
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
20be0a1a by Claudio Cambra at 2025-02-08T08:43:32+00:00
macosx: Enable dropping files onto voutview to play them
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
9 changed files:
- extras/package/macosx/VLC.xcodeproj/project.pbxproj
- modules/gui/macosx/Makefile.am
- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/views/VLCDragDropView.h
- modules/gui/macosx/views/VLCDragDropView.m
- + modules/gui/macosx/views/VLCFileDragRecognisingView.h
- + modules/gui/macosx/views/VLCFileDragRecognisingView.m
- modules/gui/macosx/windows/video/VLCVoutView.h
- modules/gui/macosx/windows/video/VLCVoutView.m
Changes:
=====================================
extras/package/macosx/VLC.xcodeproj/project.pbxproj
=====================================
@@ -162,6 +162,7 @@
53F0E930299B17DF00491D49 /* VLCInputNodePathControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 53F0E92F299B17DF00491D49 /* VLCInputNodePathControl.m */; };
53F399802AC6D6B400B86241 /* VLCLibraryHomeViewVideoCarouselContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 53F3997F2AC6D6B400B86241 /* VLCLibraryHomeViewVideoCarouselContainerView.m */; };
53F7B23C2D545FCF00F3B38F /* VLCLibraryAbstractMediaLibrarySegmentViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 53F7B23B2D545FCF00F3B38F /* VLCLibraryAbstractMediaLibrarySegmentViewController.m */; };
+ 53F7B2372D4D499400F3B38F /* VLCFileDragRecognisingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 53F7B2362D4D499400F3B38F /* VLCFileDragRecognisingView.m */; };
6B0292E61F43256300A50082 /* VLCBottomBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B0292E51F43256300A50082 /* VLCBottomBarView.m */; };
6B0AB0F01F1AC8B3003A1B4E /* VLCPlaybackProgressSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B0AB0ED1F1AC8B3003A1B4E /* VLCPlaybackProgressSlider.m */; };
6B0AB0F11F1AC8B3003A1B4E /* VLCPlaybackProgressSliderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 6B0AB0EF1F1AC8B3003A1B4E /* VLCPlaybackProgressSliderCell.m */; };
@@ -489,6 +490,8 @@
53F3997F2AC6D6B400B86241 /* VLCLibraryHomeViewVideoCarouselContainerView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryHomeViewVideoCarouselContainerView.m; sourceTree = "<group>"; };
53F7B23A2D545FCF00F3B38F /* VLCLibraryAbstractMediaLibrarySegmentViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryAbstractMediaLibrarySegmentViewController.h; sourceTree = "<group>"; };
53F7B23B2D545FCF00F3B38F /* VLCLibraryAbstractMediaLibrarySegmentViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryAbstractMediaLibrarySegmentViewController.m; sourceTree = "<group>"; };
+ 53F7B2352D4D499400F3B38F /* VLCFileDragRecognisingView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCFileDragRecognisingView.h; sourceTree = "<group>"; };
+ 53F7B2362D4D499400F3B38F /* VLCFileDragRecognisingView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCFileDragRecognisingView.m; sourceTree = "<group>"; };
5CCED71014C0D4A90057F8D1 /* VLCExtensionsDialogProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCExtensionsDialogProvider.h; sourceTree = "<group>"; };
5CCED71114C0D4A90057F8D1 /* VLCExtensionsDialogProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCExtensionsDialogProvider.m; sourceTree = "<group>"; };
5CCED71214C0D4A90057F8D1 /* VLCExtensionsManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCExtensionsManager.h; sourceTree = "<group>"; };
@@ -1126,6 +1129,8 @@
6B6A499D1DFD9B23009128AC /* VLCDefaultValueSliderCell.m */,
7D460B0A229EB4C700097948 /* VLCDragDropView.h */,
7D460B0B229EB4C700097948 /* VLCDragDropView.m */,
+ 53F7B2352D4D499400F3B38F /* VLCFileDragRecognisingView.h */,
+ 53F7B2362D4D499400F3B38F /* VLCFileDragRecognisingView.m */,
6B3BE42A1E6217CB008D098A /* VLCImageButton.h */,
6B3BE42B1E6217CB008D098A /* VLCImageButton.m */,
7DFBDCB5226CDFD600B700A5 /* VLCImageView.h */,
@@ -2387,6 +2392,7 @@
6B4D50A71E7AB52C004479B5 /* NSScreen+VLCAdditions.m in Sources */,
1C3113DD1E508C6900D4DD76 /* VLCTrackSynchronizationWindowController.m in Sources */,
7D0F5A9B2264EB410009C48A /* VLCHotkeysController.m in Sources */,
+ 53F7B2372D4D499400F3B38F /* VLCFileDragRecognisingView.m in Sources */,
5362550D293FD639005D64FA /* VLCLibraryWindowController.m in Sources */,
6B6FFF701EF9EC350001CEB1 /* CompatibilityFixes.m in Sources */,
7D1BF28A22A153E20027C50F /* VLCRoundedCornerTextField.m in Sources */,
=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -376,6 +376,8 @@ libmacosx_plugin_la_SOURCES = \
gui/macosx/views/VLCDefaultValueSliderCell.m \
gui/macosx/views/VLCDragDropView.h \
gui/macosx/views/VLCDragDropView.m \
+ gui/macosx/views/VLCFileDragRecognisingView.h \
+ gui/macosx/views/VLCFileDragRecognisingView.m \
gui/macosx/views/VLCImageButton.h \
gui/macosx/views/VLCImageButton.m \
gui/macosx/views/VLCImageView.h \
=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -405,31 +405,7 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
- (BOOL)handlePasteBoardFromDragSession:(NSPasteboard *)paste
{
- id propertyList = [paste propertyListForType:NSFilenamesPboardType];
- if (propertyList == nil) {
- return NO;
- }
-
- NSArray *values = [propertyList sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
- NSUInteger valueCount = [values count];
- if (valueCount > 0) {
- NSMutableArray *metadataArray = [NSMutableArray arrayWithCapacity:valueCount];
-
- for (NSString *filepath in values) {
- VLCOpenInputMetadata *inputMetadata;
-
- inputMetadata = [VLCOpenInputMetadata inputMetaWithPath:filepath];
- if (!inputMetadata)
- continue;
-
- [metadataArray addObject:inputMetadata];
- }
- [_playQueueController addPlayQueueItems:metadataArray];
-
- return YES;
- }
-
- return NO;
+ return [VLCFileDragRecognisingView handlePasteboardFromDragSessionAsPlayQueueItems:paste];
}
- (IBAction)goToBrowseSection:(id)sender
=====================================
modules/gui/macosx/views/VLCDragDropView.h
=====================================
@@ -24,6 +24,8 @@
#import <Cocoa/Cocoa.h>
+#import "views/VLCFileDragRecognisingView.h"
+
NS_ASSUME_NONNULL_BEGIN
/*****************************************************************************
@@ -34,14 +36,8 @@ NS_ASSUME_NONNULL_BEGIN
@end
- at protocol VLCDragDropTarget
- at required
-- (BOOL)handlePasteBoardFromDragSession:(NSPasteboard *)aPasteboard;
- at end
-
- at interface VLCDragDropView : NSView
+ at interface VLCDragDropView : VLCFileDragRecognisingView
- at property (nonatomic, assign) id<VLCDragDropTarget> dropTarget;
@property (nonatomic, assign) BOOL drawBorder;
- (void)enablePlayQueueItems;
=====================================
modules/gui/macosx/views/VLCDragDropView.m
=====================================
@@ -47,7 +47,7 @@
- (void)enablePlayQueueItems
{
- [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
+ [self setupDragRecognition];
}
- (BOOL)mouseDownCanMoveWindow
@@ -55,14 +55,9 @@
return YES;
}
-- (void)dealloc
-{
- [self unregisterDraggedTypes];
-}
-
- (void)awakeFromNib
{
- [self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
+ [super awakeFromNib];
self.wantsLayer = YES;
self.layer.cornerRadius = 5.;
[self updateBorderColor];
@@ -75,14 +70,11 @@
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
- if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric) {
- if (self.drawBorder) {
- self.layer.borderWidth = 5.;
- }
- return NSDragOperationCopy;
+ const NSDragOperation operation = [super draggingEntered:sender];
+ if (operation != NSDragOperationNone && self.drawBorder) {
+ self.layer.borderWidth = 5.;
}
-
- return NSDragOperationNone;
+ return operation;
}
- (void)draggingEnded:(id <NSDraggingInfo>)sender
@@ -95,27 +87,6 @@
self.layer.borderWidth = 0.;
}
-- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
-{
- return YES;
-}
-
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
-{
- BOOL returnValue = NO;
- NSPasteboard *pasteBoard = [sender draggingPasteboard];
- if (!pasteBoard) {
- return NO;
- }
-
- if (_dropTarget) {
- returnValue = [_dropTarget handlePasteBoardFromDragSession:pasteBoard];
- }
-
- [self setNeedsDisplay:YES];
- return returnValue;
-}
-
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
{
self.layer.borderWidth = 0.;
=====================================
modules/gui/macosx/views/VLCFileDragRecognisingView.h
=====================================
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * VLCFileDragRecognisingView.h
+ *****************************************************************************
+ * Copyright (C) 2025 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <developer at claudiocambra.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>
+
+NS_ASSUME_NONNULL_BEGIN
+
+ at protocol VLCDragDropTarget
+
+ at required
+- (BOOL)handlePasteBoardFromDragSession:(NSPasteboard *)pasteboard;
+
+ at end
+
+ at interface VLCFileDragRecognisingView : NSView
+
+ at property (nonatomic, assign) id<VLCDragDropTarget> dropTarget;
+
++ (BOOL)handlePasteboardFromDragSessionAsPlayQueueItems:(NSPasteboard *)pasteboard;
+- (void)setupDragRecognition;
+
+ at end
+
+NS_ASSUME_NONNULL_END
=====================================
modules/gui/macosx/views/VLCFileDragRecognisingView.m
=====================================
@@ -0,0 +1,126 @@
+/*****************************************************************************
+ * VLCFileDragRecognisingView.m
+ *****************************************************************************
+ * Copyright (C) 2025 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <developer at claudiocambra.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 "VLCFileDragRecognisingView.h"
+
+#import "main/VLCMain.h"
+#import "playqueue/VLCPlayQueueController.h"
+#import "windows/VLCOpenInputMetadata.h"
+
+ at implementation VLCFileDragRecognisingView
+
++ (BOOL)handlePasteboardFromDragSessionAsPlayQueueItems:(NSPasteboard *)pasteboard
+{
+ const id propertyList = [pasteboard propertyListForType:NSFilenamesPboardType];
+ if (propertyList == nil) {
+ return NO;
+ }
+
+ NSArray * const values = [propertyList sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
+ const NSUInteger valueCount = values.count;
+ if (valueCount <= 0) {
+ return NO;
+ }
+
+ NSMutableArray * const metadataArray = [NSMutableArray arrayWithCapacity:valueCount];
+
+ for (NSString * const filepath in values) {
+ VLCOpenInputMetadata * const inputMetadata = [VLCOpenInputMetadata inputMetaWithPath:filepath];
+ if (inputMetadata != nil) {
+ [metadataArray addObject:inputMetadata];
+ }
+ }
+
+ [VLCMain.sharedInstance.playQueueController addPlayQueueItems:metadataArray];
+ return YES;
+}
+
+- (instancetype)init
+{
+ self = [super init];
+ if (self) {
+ [self setupDragRecognition];
+ }
+ return self;
+}
+
+- (instancetype)initWithCoder:(NSCoder *)coder
+{
+ self = [super initWithCoder:coder];
+ if (self) {
+ [self setupDragRecognition];
+ }
+ return self;
+}
+
+- (instancetype)initWithFrame:(NSRect)frameRect
+{
+ self = [super initWithFrame:frameRect];
+ if (self) {
+ [self setupDragRecognition];
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [self unregisterDraggedTypes];
+}
+
+- (void)awakeFromNib
+{
+ [self setupDragRecognition];
+}
+
+- (void)setupDragRecognition
+{
+ [self registerForDraggedTypes:@[NSFilenamesPboardType]];
+}
+
+- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender
+{
+ if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric) {
+ return NSDragOperationCopy;
+ }
+ return NSDragOperationNone;
+}
+
+- (BOOL)prepareForDragOperation:(id<NSDraggingInfo>)sender
+{
+ return YES;
+}
+
+- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender
+{
+ NSPasteboard * const pasteboard = [sender draggingPasteboard];
+ if (pasteboard == nil) {
+ return NO;
+ }
+
+ [self setNeedsDisplay:YES];
+ if (self.dropTarget) {
+ return [self.dropTarget handlePasteBoardFromDragSession:pasteboard];
+ }
+ return NO;
+}
+
+ at end
=====================================
modules/gui/macosx/windows/video/VLCVoutView.h
=====================================
@@ -30,12 +30,14 @@
#import <vlc_vout.h>
#import <vlc_window.h>
+#import "views/VLCFileDragRecognisingView.h"
+
/*****************************************************************************
* VLCVoutView interface
*****************************************************************************/
- at interface VLCVoutView : NSView
+ at interface VLCVoutView : VLCFileDragRecognisingView<VLCDragDropTarget>
- at property (readwrite, assign) vout_thread_t * voutThread;
+ at property (readwrite, assign) vout_thread_t *voutThread;
@property (readwrite, assign) vlc_window_t *voutWindow;
- (void)releaseVoutThread;
=====================================
modules/gui/macosx/windows/video/VLCVoutView.m
=====================================
@@ -99,7 +99,7 @@
- (void)setup
{
- [self registerForDraggedTypes:@[NSFilenamesPboardType]];
+ self.dropTarget = self;
i_lastScrollWheelDirection = 0;
f_cumulated_magnification = 0.0;
@@ -109,7 +109,8 @@
vlc_mutex_init(&_mutex);
}
-- (void)layout {
+- (void)layout
+{
NSRect bounds = [self convertRectToBacking:self.bounds];
// dispatch the event async to prevent potential deadlock
// with video output's RenderPicture's display lock
@@ -129,32 +130,6 @@
NSRectFill(rect);
}
-- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
-{
- if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric)
- return NSDragOperationGeneric;
- return NSDragOperationNone;
-}
-
-- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
-{
- return YES;
-}
-
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
-{
- // FIXME: re-implement drag and drop of new input items to the playlist
- BOOL b_returned = NO;
-
- [self setNeedsDisplay:YES];
- return b_returned;
-}
-
-- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
-{
- [self setNeedsDisplay:YES];
-}
-
#pragma mark -
#pragma mark vout actions
@@ -424,4 +399,9 @@
f_cumulated_magnification = 0.0;
}
+- (BOOL)handlePasteBoardFromDragSession:(NSPasteboard *)pasteboard
+{
+ return [VLCFileDragRecognisingView handlePasteboardFromDragSessionAsPlayQueueItems:pasteboard];
+}
+
@end
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/62f11751edf76573dd77deaefeefdd795baa865e...20be0a1a74688cd6b4f7628f919c8b568f0c1ad1
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/62f11751edf76573dd77deaefeefdd795baa865e...20be0a1a74688cd6b4f7628f919c8b568f0c1ad1
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list