Fixed drop above indicator when the insertion level doesn't match the previous

row and is based on the horizontal pointer position.

NSOutlineView drag and drop behavior matches Mac OS X very closely now and all 
the bugs I was aware of have been corrected.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29103 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Quentin Mathe 2009-12-06 01:36:26 +00:00
parent 19dad5cba6
commit cd8dd3494f
2 changed files with 23 additions and 39 deletions

View file

@ -1,3 +1,14 @@
2009-12-06 Quentin Mathe <quentin.mathe@gmail.com>
* Source/NSOutlineView.m (-draggingUpdated:):
Fixed drop above as a child in the previous row (when this row is an
empty parent).
(-drawDropAboveIndicatorWithDropItem:atRow:childDropIndex:): Fixed the
drop above indicator drawing when the level doesn't match the previous
row. Done by including an extra row parameter which makes possible to
remove the row computation code that appears to partially duplicate
-parentRowForRow:atLevel:andReturnChildIndex:.
2009-12-05 Quentin Mathe <quentin.mathe@gmail.com>
* Source/NSTableView.m (-_startDragOperationWithEvent:): Modified to call

View file

@ -1015,47 +1015,12 @@ static NSImage *unexpandable = nil;
}
// TODO: Move the part that starts at 'Compute the indicator rect area' to GSTheme
- (void) drawDropAboveIndicatorWithDropItem: (id)currentDropItem childDropIndex: (int)currentDropIndex
- (void) drawDropAboveIndicatorWithDropItem: (id)currentDropItem atRow: (int)row childDropIndex: (int)currentDropIndex
{
int numberOfChildren = [_dataSource outlineView: self
numberOfChildrenOfItem: currentDropItem];
int row = 0;
int level = 0;
id item = nil;
NSBezierPath *path = nil;
NSRect newRect = NSZeroRect;
if (currentDropIndex >= numberOfChildren)
{
/* The index lies beyond the last item,
* so we get the last but one item and we
* use the row after it. If there are no
* children at all, we use the parent item row.
*/
if (numberOfChildren == 0)
{
row = [self rowForItem: currentDropItem];
}
else
{
item = [_dataSource outlineView: self
child: numberOfChildren - 1
ofItem: currentDropItem];
row = [self rowForItem: item] + 1;
}
}
else
{
/* Find the row for the item containing the child
* we will be dropping on.
*/
item = [_dataSource outlineView: self
child: currentDropIndex
ofItem: currentDropItem];
row = [self rowForItem: item];
}
/* Compute the indicator rect area */
if (currentDropItem == nil && currentDropIndex == 0)
{
@ -1078,7 +1043,7 @@ static NSImage *unexpandable = nil;
[self visibleRect].size.width,
2);
}
level = [self levelForItem: item] + 1;
level = [self levelForItem: currentDropItem] + 1;
newRect.origin.x += level * _indentationPerLevel;
newRect.size.width -= level * _indentationPerLevel;
@ -1273,7 +1238,7 @@ Also returns the child index relative to this parent. */
|| (lastHorizontalHalfPosition != horizontalHalfPosition))
{
int minInsertionLevel = levelAfter;
int maxInsertionLevel = MAX(levelBefore, levelAfter);
int maxInsertionLevel = levelBefore;
int pointerInsertionLevel = rint((float)horizontalHalfPosition / 2.);
/* Save positions to avoid executing this code when the general
@ -1282,6 +1247,14 @@ Also returns the child index relative to this parent. */
lastVerticalQuarterPosition = verticalQuarterPosition;
lastHorizontalHalfPosition = horizontalHalfPosition;
/* When the row before is an empty parent, we allow to insert the dragged
* item as its child.
*/
if ([self isExpandable: [self itemAtRow: (row - 1)]])
{
maxInsertionLevel++;
}
/* Find the insertion level to be used with a drop above
*
* In the outline below, when the pointer moves horizontally on
@ -1359,7 +1332,7 @@ Also returns the child index relative to this parent. */
if (currentDropIndex != NSOutlineViewDropOnItemIndex && currentDropItem != nil)
{
[self drawDropAboveIndicatorWithDropItem: currentDropItem childDropIndex: currentDropIndex];
[self drawDropAboveIndicatorWithDropItem: currentDropItem atRow: row childDropIndex: currentDropIndex];
}
else if (currentDropIndex == NSOutlineViewDropOnItemIndex && currentDropItem == nil)
{