macosx: split drag & drop view from misc

This commit is contained in:
Felix Paul Kühne 2019-05-29 14:50:19 +02:00
parent 519ed84544
commit 540f3a0073
11 changed files with 203 additions and 157 deletions

View File

@ -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 */,

View File

@ -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 \

View File

@ -23,31 +23,6 @@
#import <Cocoa/Cocoa.h>
/*****************************************************************************
* 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
*

View File

@ -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
*****************************************************************************/
@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 <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];
}
@end
#import "NSString+Helpers.h"
@interface PositionFormatter()
{

View File

@ -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.
*****************************************************************************/
@interface VLCDropDisabledImageView : NSImageView
@end
@interface VLCDragDropView : NSView
@property (nonatomic, assign) id dropHandler;
@property (nonatomic, assign) BOOL drawBorder;
- (void)enablePlaylistItems;
@end
NS_ASSUME_NONNULL_END

View File

@ -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"
@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 <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];
}
@end

View File

@ -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>

View File

@ -23,10 +23,10 @@
#import <Cocoa/Cocoa.h>
#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

View File

@ -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
*

View File

@ -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";

View File

@ -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