mirror of https://github.com/mpv-player/mpv
cocoa: handle files drag and drop on the player video view
This commit is contained in:
parent
69d44d992c
commit
1e988c595b
|
@ -36,6 +36,7 @@
|
|||
- (void)initialize_menu;
|
||||
- (void)registerSelector:(SEL)selector forKey:(MPMenuKey)key;
|
||||
- (void)stopPlayback;
|
||||
- (void)handleFilesArray:(NSArray *)files;
|
||||
|
||||
@property(nonatomic, assign) struct input_ctx *inputContext;
|
||||
@property(nonatomic, retain) EventsResponder *eventsResponder;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
- (void)putAxis:(int)mpkey delta:(float)delta;
|
||||
- (void)putCommand:(char*)cmd;
|
||||
- (void)performAsyncResize:(NSSize)size;
|
||||
- (void)handleFilesArray:(NSArray *)files;
|
||||
|
||||
- (BOOL)isInFullScreenMode;
|
||||
- (NSSize)videoSize;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
#import "video/out/cocoa/mpvadapter.h"
|
||||
|
||||
@interface MpvVideoView : NSView {
|
||||
@interface MpvVideoView : NSView <NSDraggingDestination> {
|
||||
BOOL hasMouseDown;
|
||||
}
|
||||
@property(nonatomic, retain) MpvCocoaAdapter *adapter;
|
||||
|
|
|
@ -30,6 +30,14 @@
|
|||
@synthesize adapter = _adapter;
|
||||
@synthesize tracker = _tracker;
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self registerForDraggedTypes:@[NSFilenamesPboardType]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setFullScreen:(BOOL)willBeFullscreen
|
||||
{
|
||||
if (willBeFullscreen && ![self isInFullScreenMode]) {
|
||||
|
@ -223,4 +231,17 @@
|
|||
[self.adapter performAsyncResize:[self frameInPixels].size];
|
||||
[self.adapter setNeedsResize];
|
||||
}
|
||||
|
||||
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
return NSDragOperationEvery;
|
||||
}
|
||||
|
||||
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *pboard = [sender draggingPasteboard];
|
||||
NSArray *pbitems = [pboard propertyListForType:NSFilenamesPboardType];
|
||||
[self.adapter handleFilesArray:pbitems];
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "osdep/macosx_compat.h"
|
||||
#include "osdep/macosx_application.h"
|
||||
#include "osdep/macosx_application_objc.h"
|
||||
#include "osdep/macosx_events.h"
|
||||
|
||||
#include "config.h"
|
||||
|
@ -660,4 +661,9 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
|
|||
struct vo_cocoa_state *s = self.vout->cocoa;
|
||||
return s->fs_screen;
|
||||
}
|
||||
|
||||
- (void)handleFilesArray:(NSArray *)files
|
||||
{
|
||||
[mpv_shared_app() handleFilesArray:files];
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue