Finalized drag&drop on NSCollectionView, fixed a bug in NSTabView where the nextKeyView was being set to a dealloc'd view after closing all tabs and reopening one.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@36314 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Frank Le Grand 2013-03-08 22:59:40 +00:00
parent efc1c707a0
commit d3b8f3ae90
5 changed files with 60 additions and 43 deletions

View file

@ -1,3 +1,7 @@
2013-03-08 Frank Le Grand <frank.legrand@testplant.com>
* Source\NSCollectionView.m: Implemented drag & drop.
* Source\NSTabView.m: Fixed a bug where the nextKeyView was being set a dealloc'd view in some cases.
2013-02-28 Frank Le Grand <frank.legrand@testplant.com>
Continued work on Collection View: Applied more GNUstep coding standards (including
the use of macros), implemented selection.

View file

@ -2238,7 +2238,6 @@ static NSColor *dtxtCol;
// there's something wrong about telling the view to come
// back here and draw.
[controlView setKeyboardFocusRingNeedsDisplayInRect:NSMakeRect (aRect.origin.x - 2.0, aRect.origin.y - 2.0, aRect.size.width + 4.0, aRect.size.height + 4.0)];
NSLog(@"Edited Cell: %@", self);
}
/**<p>Ends any text editing. This method sets the text object's delegate

View file

@ -135,15 +135,25 @@ static NSString *placeholderItem = nil;
placeholderItem = @"Placeholder";
}
- (id) initWithFrame: (NSRect)frame
{
if ((self = [super initWithFrame:frame]))
{
[self _initDefaults];
}
return self;
}
-(void) _initDefaults
{
_draggingSourceOperationMaskForLocal = NSDragOperationCopy | NSDragOperationLink | NSDragOperationGeneric | NSDragOperationPrivate;
// _draggingSourceOperationMaskForRemote = NSDragOperationNone;
_draggingSourceOperationMaskForRemote = NSDragOperationCopy | NSDragOperationLink | NSDragOperationGeneric | NSDragOperationPrivate;
// _draggingSourceOperationMaskForLocal = NSDragOperationCopy | NSDragOperationLink | NSDragOperationGeneric | NSDragOperationPrivate;
_draggingSourceOperationMaskForLocal = NSDragOperationGeneric | NSDragOperationMove | NSDragOperationCopy;
_draggingSourceOperationMaskForRemote = NSDragOperationGeneric | NSDragOperationMove | NSDragOperationCopy;
[self _resetItemSize];
_content = [[NSArray alloc] init];
_items = [[NSMutableArray alloc] init];
_selectionIndexes = [[NSIndexSet alloc] init];
_draggingOnIndex = NSNotFound;
}
- (void) _resetItemSize
@ -197,7 +207,10 @@ static NSString *placeholderItem = nil;
//[[NSNotificationCenter defaultCenter] removeObserver:self];
DESTROY (_content);
//DESTROY (itemPrototype);
// FIXME: Not clear if we should destroy the top-level item "itemPrototype" loaded in the nib file.
DESTROY (itemPrototype);
DESTROY (_backgroundColors);
DESTROY (_selectionIndexes);
DESTROY (_items);
@ -503,7 +516,7 @@ static NSString *placeholderItem = nil;
ASSIGN(collectionItem, [itemPrototype copy]);
[collectionItem setRepresentedObject:object];
}
return collectionItem;
return AUTORELEASE (collectionItem);
}
- (void) _removeItemsViews
@ -1007,31 +1020,9 @@ static NSString *placeholderItem = nil;
endedAt: (NSPoint)point
operation: (NSDragOperation)operation
{
NSLog(@"draggedImage:endedAt:operation:");
}
- (NSDragOperation) draggingEntered: (id<NSDraggingInfo>)sender
{
NSLog(@"draggingEntered:");
if ([sender draggingSource] == self)
{
return NSDragOperationNone;
}
else
{
return NSDragOperationCopy;
}
}
- (void) draggingExited: (id<NSDraggingInfo>)sender
{
_draggingOnIndex = NSNotFound;
NSPoint location = [self convertPoint: [sender draggingLocation] fromView: nil];
int index = [self _indexAtPoint:location];
[self setNeedsDisplayInRect:[self _frameForRowOfItemAtIndex:index]];
}
- (NSDragOperation) draggingUpdated: (id<NSDraggingInfo>)sender
- (NSDragOperation) _draggingEnteredOrUpdated: (id<NSDraggingInfo>)sender
{
NSDragOperation result = NSDragOperationNone;
@ -1039,9 +1030,9 @@ static NSString *placeholderItem = nil;
{
NSPoint location = [self convertPoint: [sender draggingLocation] fromView: nil];
int index = [self _indexAtPoint:location];
index = (index > [_items count] - 1) ? [_items count] - 1 : index;
_draggingOnIndex = index;
[self setNeedsDisplayInRect:[self _frameForRowsAroundItemAtIndex:index]];
//NSLog (@">>> DRAGGING OVER INDEX %d", index);
NSInteger *proposedIndex = (NSInteger *)index;
@ -1054,6 +1045,22 @@ static NSString *placeholderItem = nil;
return result;
}
- (NSDragOperation) draggingEntered: (id<NSDraggingInfo>)sender
{
return [self _draggingEnteredOrUpdated:sender];
}
- (void) draggingExited: (id<NSDraggingInfo>)sender
{
[self setNeedsDisplayInRect:[self _frameForRowsAroundItemAtIndex:_draggingOnIndex]];
_draggingOnIndex = NSNotFound;
}
- (NSDragOperation) draggingUpdated: (id<NSDraggingInfo>)sender
{
return [self _draggingEnteredOrUpdated:sender];
}
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
{
_draggingOnIndex = NSNotFound;

View file

@ -109,7 +109,7 @@
- (void)setRepresentedObject:(id)anObject
{
[super setRepresentedObject:anObject];
[textField setStringValue:[self representedObject]];
//[textField setStringValue:[self representedObject]];
}
- (NSTextField *)textField

View file

@ -89,6 +89,7 @@
// Reset the _selected attribute to prevent crash when -dealloc calls
// -setNextKeyView:
_selected = nil;
_original_nextKeyView = nil;
RELEASE(_items);
RELEASE(_font);
[super dealloc];
@ -276,21 +277,27 @@
NSView *firstResponder;
[self addSubview: selectedView];
// FIXME: We should not change this mask
[selectedView setAutoresizingMask:
NSViewWidthSizable | NSViewHeightSizable];
[selectedView setFrame: [self contentRect]];
firstResponder = [_selected initialFirstResponder];
if (firstResponder == nil)
{
firstResponder = [_selected view];
[_selected setInitialFirstResponder: firstResponder];
[firstResponder _setUpKeyViewLoopWithNextKeyView:
_original_nextKeyView];
[firstResponder _setUpKeyViewLoopWithNextKeyView:_original_nextKeyView];
}
[self setNextKeyView: firstResponder];
[super setNextKeyView: firstResponder];
[_window makeFirstResponder: firstResponder];
}
else
{
[super setNextKeyView:_original_nextKeyView];
}
/* Will need to redraw tabs and content area. */
[self setNeedsDisplay: YES];