Commit 819d233b authored by David Fuhrmann's avatar David Fuhrmann

macosx: implement simpler and generic drop view for all drag / drop operations

- Use the new VLCDragDropView for both CAS and main window drop zone.
  This implements a drop highlight border the same way as in playlist view.
- Remove Brushed Metal Image view and its own drop implementation.
  When having a image view inside a drop zone, you need to use
  VLCDropDisabledImageView which disables the own drop handling of NSImageView.
- Removed more unneeded drop implementations for subviews from CAS
parent b1946d46
......@@ -171,18 +171,3 @@
- (void)updateDropView;
@end
@interface VLCDropEnabledBox : NSBox
{
BOOL b_activeDragAndDrop;
}
@end
@interface VLCDropEnabledImageView : NSImageView
@end
@interface VLCDropEnabledButton : NSButton
@end
......@@ -261,6 +261,10 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
[_ok_btn setEnabled: NO];
// setup drop view
[_drop_box enablePlaylistItems];
[_drop_box setDropHandler: self];
[self resetCustomizationSheetBasedOnProfile:[self.profileValueList objectAtIndex:0]];
}
......@@ -1057,130 +1061,3 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
}
@end
# pragma mark -
# pragma mark Drag and drop handling
@implementation VLCDropEnabledBox
- (void)awakeFromNib
{
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
b_activeDragAndDrop = YES;
[self setNeedsDisplay:YES];
[[NSCursor dragCopyCursor] set];
if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric)
return NSDragOperationGeneric;
return NSDragOperationNone;
}
- (void)draggingEnded:(id < NSDraggingInfo >)sender
{
[[NSCursor arrowCursor] set];
b_activeDragAndDrop = NO;
[self setNeedsDisplay:YES];
}
- (void)draggingExited:(id < NSDraggingInfo >)sender
{
[[NSCursor arrowCursor] set];
b_activeDragAndDrop = NO;
[self setNeedsDisplay:YES];
}
- (void)drawRect:(NSRect)dirtyRect
{
if (b_activeDragAndDrop) {
[[NSColor colorWithCalibratedRed:(.154/.255) green:(.154/.255) blue:(.154/.255) alpha:1.] setFill];
NSRect frameRect = [[self contentView] bounds];
frameRect.origin.x += 10;
frameRect.origin.y += 10;
frameRect.size.width -= 17;
frameRect.size.height -= 17;
NSFrameRectWithWidthUsingOperation(frameRect, 4., NSCompositeHighlight);
}
[super drawRect:dirtyRect];
}
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
{
return YES;
}
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
return [[VLCConvertAndSave sharedInstance] performDragOperation: sender];
}
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
{
[self setNeedsDisplay:YES];
}
@end
@implementation VLCDropEnabledImageView
- (void)awakeFromNib
{
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
return [[[self superview] superview] draggingEntered:sender];
}
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
{
return YES;
}
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
return [[VLCConvertAndSave sharedInstance] performDragOperation: sender];
}
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
{
[self setNeedsDisplay:YES];
}
@end
@implementation VLCDropEnabledButton
- (void)awakeFromNib
{
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
return [[[self superview] superview] draggingEntered:sender];
}
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
{
return YES;
}
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
return [[VLCConvertAndSave sharedInstance] performDragOperation: sender];
}
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
{
[self setNeedsDisplay:YES];
}
@end
......@@ -557,7 +557,7 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
}
#pragma mark -
#pragma mark drag and drop support for VLCVoutView, VLBrushedMetalImageView and VLCThreePartDropView
#pragma mark drag and drop support for VLCVoutView, VLCDragDropView and VLCThreePartDropView
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *o_paste = [sender draggingPasteboard];
......
......@@ -70,12 +70,32 @@
- (void)setNonFullscreenPresentationOptions;
@end
/*****************************************************************************
* VLCDragDropView
*
* Disables default drag / drop behaviour of an NSImageView.
* set it for all sub image views withing an VLCDragDropView.
*****************************************************************************/
@interface VLCDropDisabledImageView : NSImageView
@end
/*****************************************************************************
* VLBrushedMetalImageView
* VLCDragDropView
*****************************************************************************/
@interface VLBrushedMetalImageView : NSImageView
@interface VLCDragDropView : NSView
{
bool b_activeDragAndDrop;
id _dropHandler;
}
@property (nonatomic, assign) id dropHandler;
- (void)enablePlaylistItems;
@end
......
......@@ -300,10 +300,30 @@ static bool b_old_spaces_style = YES;
@end
/*****************************************************************************
* VLBrushedMetalImageView
* VLCDragDropView
*****************************************************************************/
@implementation VLBrushedMetalImageView
@implementation VLCDropDisabledImageView
- (void)awakeFromNib
{
[self unregisterDraggedTypes];
}
@end
/*****************************************************************************
* VLCDragDropView
*****************************************************************************/
@implementation VLCDragDropView
@synthesize dropHandler=_dropHandler;
- (void)enablePlaylistItems
{
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
}
- (BOOL)mouseDownCanMoveWindow
{
......@@ -319,19 +339,32 @@ static bool b_old_spaces_style = YES;
- (void)awakeFromNib
{
[self registerForDraggedTypes:[NSArray arrayWithObject:NSFilenamesPboardType]];
[self setImageScaling: NSScaleToFit];
[self setImageFrameStyle: NSImageFrameNone];
[self setImageAlignment: NSImageAlignCenter];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric)
return NSDragOperationGeneric;
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;
......@@ -340,7 +373,11 @@ static bool b_old_spaces_style = YES;
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
BOOL b_returned;
b_returned = [[VLCCoreInteraction sharedInstance] performDragOperation: sender];
if (_dropHandler && [_dropHandler respondsToSelector:@selector(performDragOperation:)])
b_returned = [_dropHandler performDragOperation: sender];
else // default
b_returned = [[VLCCoreInteraction sharedInstance] performDragOperation: sender];
[self setNeedsDisplay:YES];
return b_returned;
......@@ -351,6 +388,19 @@ static bool b_old_spaces_style = YES;
[self setNeedsDisplay:YES];
}
- (void)drawRect:(NSRect)dirtyRect
{
if (b_activeDragAndDrop) {
NSRect frameRect = [self bounds];
[[NSColor selectedControlColor] set];
NSFrameRectWithWidthUsingOperation(frameRect, 2., NSCompositeHighlight);
}
[super drawRect:dirtyRect];
}
@end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment