Revision: 28671
http://sourceforge.net/p/bibdesk/svn/28671
Author: hofman
Date: 2024-01-24 17:15:49 +0000 (Wed, 24 Jan 2024)
Log Message:
-----------
Save drop index and drop operation in drop highlight view, we only need them
during a drop when we have the drop highlight view
Modified Paths:
--------------
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h 2024-01-24
16:52:14 UTC (rev 28670)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.h 2024-01-24
17:15:49 UTC (rev 28671)
@@ -194,7 +194,7 @@
@end
-@class FVSliderWindow, FVOperationQueue, FVBackgroundView, FVArrowButton;
+@class FVSliderWindow, FVOperationQueue, FVBackgroundView, FVArrowButton,
FVDropHighlightView;
/**
FVFileView is the primary class in the framework.
@@ -221,12 +221,10 @@
NSIndexSet *_selectionIndexes;
CGLayerRef _selectionOverlay;
NSUInteger _lastClickedIndex;
- NSUInteger _dropIndex;
NSView *_rubberBandView;
- NSView *_dropHighlightView;
+ FVDropHighlightView *_dropHighlightView;
struct __fvFlags {
unsigned int displayMode:2;
- unsigned int dropOperation:2;
unsigned int isEditable:1;
unsigned int isMouseDown:1;
unsigned int isRescaling:1;
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2024-01-24
16:52:14 UTC (rev 28670)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2024-01-24
17:15:49 UTC (rev 28671)
@@ -155,8 +155,12 @@
@end
@interface FVDropHighlightView : NSView {
- __weak id<FVDropHighlightViewDelegate> _delegate;
+ NSUInteger _dropIndex;
+ FVDropOperation _dropOperation;
+ __weak id<FVDropHighlightViewDelegate> _delegate;
}
+@property (nonatomic) NSUInteger dropIndex;
+@property (nonatomic) FVDropOperation dropOperation;
@property (nonatomic, weak) id<FVDropHighlightViewDelegate> delegate;
@end
@@ -334,8 +338,6 @@
_padding = [self _paddingForScale:1.0];
_lastMouseDownLocInView = NSZeroPoint;
// the next two are set to an illegal combination to indicate that no drop
is in progress
- _dropIndex = NSNotFound;
- _fvFlags.dropOperation = FVDropBefore;
_fvFlags.isRescaling = NO;
_fvFlags.scheduledLiveResize = NO;
_fvFlags.controllingSharedPreviewer = NO;
@@ -2010,18 +2012,20 @@
NSUInteger r, c;
NSRect aRect = NSZeroRect;
BOOL isColumn = (_fvFlags.displayMode == FVDisplayModeColumn);
+ NSUInteger dropIndex = [_dropHighlightView dropIndex];
+ FVDropOperation dropOp = [_dropHighlightView dropOperation];
- switch (_fvFlags.dropOperation) {
+ switch (dropOp) {
case FVDropOn:
- if (_dropIndex == NSNotFound) {
+ if (dropIndex == NSNotFound) {
aRect = [self visibleRect];
} else {
- [self _getGridRow:&r column:&c ofIndex:_dropIndex];
+ [self _getGridRow:&r column:&c ofIndex:dropIndex];
aRect = NSInsetRect([self _rectOfIconInRow:r column:c],
HIGHLIGHT_INSET, HIGHLIGHT_INSET);
}
break;
case FVDropBefore:
- [self _getGridRow:&r column:&c ofIndex:_dropIndex];
+ [self _getGridRow:&r column:&c ofIndex:dropIndex];
aRect = [self _rectOfIconInRow:r column:c];
// aRect size is 6, and should be centered between icons
if (isColumn) {
@@ -2033,7 +2037,7 @@
}
break;
case FVDropAfter:
- [self _getGridRow:&r column:&c ofIndex:_dropIndex];
+ [self _getGridRow:&r column:&c ofIndex:dropIndex];
aRect = [self _rectOfIconInRow:r column:c];
// aRect size is 6, and should be centered between icons
if (isColumn) {
@@ -2055,7 +2059,7 @@
[[[NSColor alternateSelectedControlColor] colorWithAlphaComponent:0.2]
setFill];
[[[NSColor alternateSelectedControlColor] colorWithAlphaComponent:0.8]
setStroke];
- if (_fvFlags.dropOperation == FVDropOn) {
+ if (dropOp == FVDropOn) {
// it's either a drop on the whole table or on top of a cell
p = [NSBezierPath bezierPathWithRoundedRect:NSInsetRect(aRect, 0.5
* lineWidth, 0.5 * lineWidth) xRadius:7 yRadius:7];
[p fill];
@@ -2785,8 +2789,8 @@
- (void)setDropIndex:(NSUInteger)anIndex
dropOperation:(FVDropOperation)anOperation
{
- _dropIndex = anIndex;
- _fvFlags.dropOperation = anOperation;
+ [_dropHighlightView setDropIndex:anIndex];
+ [_dropHighlightView setDropOperation:anOperation];
}
- (BOOL)_isLocalDraggingInfo:(id <NSDraggingInfo>)sender
@@ -2800,20 +2804,20 @@
{
NSPoint dragLoc = [self convertPoint:[sender draggingLocation]
fromView:nil];
NSPoint p = dragLoc;
- NSUInteger dropOp;
NSDragOperation dragOp = [sender draggingSourceOperationMask] &
~NSDragOperationMove;
BOOL isCopy = [self allowsDownloading] && dragOp == NSDragOperationCopy;
NSUInteger insertIndex, firstIndex, endIndex;
+ NSUInteger dropIndex = NSNotFound;
+ FVDropOperation dropOp = FVDropBefore;
// !!! this is quite expensive to call repeatedly in -draggingUpdated
BOOL hasURLs = FVPasteboardHasURL([sender draggingPasteboard]);
// First determine the drop location, drop between rows in column mode,
and between columns otherwise
- _dropIndex = [self _indexAtPoint:p dropOperation:&dropOp];
- _fvFlags.dropOperation = dropOp;
+ dropIndex = [self _indexAtPoint:p dropOperation:&dropOp];
// Check whether the index is not NSNotFound, because the grid cell can be
empty
- if (_dropIndex == NSNotFound)
- _fvFlags.dropOperation = FVDropOn;
+ if (dropIndex == NSNotFound)
+ dropOp = FVDropOn;
// We won't reset the drop location info when we propose
NSDragOperationNone, because the delegate may want to override our decision, we
will reset it at the end
@@ -2823,13 +2827,13 @@
}
else if ([self _isLocalDraggingInfo:sender] && isCopy == NO) {
// invalidate some local drags, otherwise make sure we use a Move
operation
- if (FVDropOn == _fvFlags.dropOperation) {
+ if (FVDropOn == dropOp) {
// drop on the whole view (add operation) or an icon (replace
operation) makes no sense for a local drag, but the delegate may override
dragOp = NSDragOperationNone;
}
- else if (FVDropBefore == _fvFlags.dropOperation || FVDropAfter ==
_fvFlags.dropOperation) {
+ else if (FVDropBefore == dropOp || FVDropAfter == dropOp) {
// inserting inside the block we're dragging doesn't make sense;
this does allow dropping a disjoint selection at some locations within the
selection; the delegate may override
- insertIndex = FVDropAfter == _fvFlags.dropOperation ? _dropIndex +
1 : _dropIndex;
+ insertIndex = FVDropAfter == dropOp ? dropIndex + 1 : dropIndex;
firstIndex = [_selectionIndexes firstIndex], endIndex =
[_selectionIndexes lastIndex] + 1;
if ([_selectionIndexes
containsIndexesInRange:NSMakeRange(firstIndex, endIndex - firstIndex)] &&
insertIndex >= firstIndex && insertIndex <= endIndex) {
@@ -2844,21 +2848,24 @@
dragOp = NSDragOperationLink;
}
- // we allow the delegate to change the _dropIndex and
_fvFlags.dropOperation as NSTableView does
+ if (_dropHighlightView == nil) {
+ _dropHighlightView = [[FVDropHighlightView alloc] initWithFrame:[self
bounds]];
+ [(FVDropHighlightView *)_dropHighlightView setDelegate:self];
+ [self addSubview:_dropHighlightView];
+ }
+ [_dropHighlightView setDropIndex:dropIndex];
+ [_dropHighlightView setDropOperation:dropOp];
+
+ // we allow the delegate to change the dropIndex and dropOperation as
NSTableView does
if ([[self delegate]
respondsToSelector:@selector(fileView:validateDrop:proposedIndex:proposedDropOperation:proposedDragOperation:)])
- dragOp = [[self delegate] fileView:self validateDrop:sender
proposedIndex:_dropIndex proposedDropOperation:_fvFlags.dropOperation
proposedDragOperation:dragOp];
+ dragOp = [[self delegate] fileView:self validateDrop:sender
proposedIndex:dropIndex proposedDropOperation:dropOp
proposedDragOperation:dragOp];
// make sure we're consistent, also see comment above
if (dragOp == NSDragOperationNone) {
- _dropIndex = NSNotFound;
- _fvFlags.dropOperation = FVDropBefore;
+ [_dropHighlightView setDropIndex:NSNotFound];
+ [_dropHighlightView setDropOperation:FVDropBefore];
}
- if (dragOp != NSDragOperationNone && _dropHighlightView == nil) {
- _dropHighlightView = [[FVDropHighlightView alloc] initWithFrame:[self
bounds]];
- [(FVDropHighlightView *)_dropHighlightView setDelegate:self];
- [self addSubview:_dropHighlightView];
- }
[_dropHighlightView setNeedsDisplay:YES];
return dragOp;
}
@@ -2871,22 +2878,18 @@
- (void)draggingExited:(id <NSDraggingInfo>)sender
{
- _dropIndex = NSNotFound;
- _fvFlags.dropOperation = FVDropBefore;
+ [_dropHighlightView removeFromSuperview];
+ _dropHighlightView = nil;
if (_fvFlags.needsReload)
[self reloadIcons];
- [_dropHighlightView removeFromSuperview];
- _dropHighlightView = nil;
}
// only invoked if performDragOperation returned YES
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender;
{
- _dropIndex = NSNotFound;
- _fvFlags.dropOperation = FVDropBefore;
- [self reloadIcons];
[_dropHighlightView removeFromSuperview];
_dropHighlightView = nil;
+ [self reloadIcons];
}
static NSURL *makeCopyOfFileAtURL(NSURL *fileURL) {
@@ -2919,15 +2922,17 @@
NSArray *allURLs = draggedURLs;
NSMutableArray *downloads = nil;
NSUInteger insertIndex = 0;
+ NSUInteger dropIndex = [_dropHighlightView dropIndex];
+ FVDropOperation dropOp = [_dropHighlightView dropOperation];
- if (FVDropBefore == _fvFlags.dropOperation) {
- insertIndex = _dropIndex;
- } else if (FVDropAfter == _fvFlags.dropOperation) {
- insertIndex = _dropIndex + 1;
- } else if (_dropIndex == NSNotFound) {
+ if (FVDropBefore == dropOp) {
+ insertIndex = [_dropHighlightView dropIndex];
+ } else if (FVDropAfter == dropOp) {
+ insertIndex = dropIndex + 1;
+ } else if (dropIndex == NSNotFound) {
insertIndex = [self numberOfIcons];
} else {
- insertIndex = _dropIndex;
+ insertIndex = dropIndex;
if ([allURLs count] > 1)
allURLs = [NSArray arrayWithObject:[allURLs objectAtIndex:0]];
}
@@ -2956,13 +2961,13 @@
if (isMove) {
- didPerform = [[self dataSource] fileView:self
moveURLsAtIndexes:_selectionIndexes toIndex:insertIndex forDrop:sender
dropOperation:_fvFlags.dropOperation];
+ didPerform = [[self dataSource] fileView:self
moveURLsAtIndexes:_selectionIndexes toIndex:insertIndex forDrop:sender
dropOperation:dropOp];
- } else if (FVDropBefore == _fvFlags.dropOperation || FVDropAfter ==
_fvFlags.dropOperation || NSNotFound == _dropIndex) {
+ } else if (FVDropBefore == dropOp || FVDropAfter == dropOp || NSNotFound
== dropIndex) {
// drop on the whole view
NSIndexSet *insertSet = [NSIndexSet
indexSetWithIndexesInRange:NSMakeRange(insertIndex, [allURLs count])];
- [[self dataSource] fileView:self insertURLs:allURLs
atIndexes:insertSet forDrop:sender dropOperation:_fvFlags.dropOperation];
+ [[self dataSource] fileView:self insertURLs:allURLs
atIndexes:insertSet forDrop:sender dropOperation:dropOp];
didPerform = YES;
}
@@ -2977,7 +2982,7 @@
aURL = [NSURL fileURLWithPath:[[pboard
propertyListForType:NSFilenamesPboardType] lastObject]];
}
if (aURL)
- didPerform = [[self dataSource] fileView:self
replaceURLAtIndex:_dropIndex withURL:aURL forDrop:sender
dropOperation:_fvFlags.dropOperation];
+ didPerform = [[self dataSource] fileView:self
replaceURLAtIndex:dropIndex withURL:aURL forDrop:sender dropOperation:dropOp];
}
if ([downloads count]) {
@@ -2990,9 +2995,8 @@
}
// if we return NO, concludeDragOperation doesn't get called
- _dropIndex = NSNotFound;
- _fvFlags.dropOperation = FVDropBefore;
- [self setNeedsDisplay:YES];
+ [_dropHighlightView removeFromSuperview];
+ _dropHighlightView = nil;
// reload is handled in concludeDragOperation:
return didPerform;
@@ -5030,6 +5034,8 @@
@implementation FVDropHighlightView
+@synthesize dropIndex=_dropIndex;
+@synthesize dropOperation=_dropOperation;
@synthesize delegate=_delegate;
- (BOOL)isFlipped {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit