From ee6160e7962ddcb844517bdb6c822aae232c2416 Mon Sep 17 00:00:00 2001 From: Klaas Pieter Annema Date: Wed, 3 Feb 2010 15:06:42 +0100 Subject: [PATCH] - fixed some issues with variable sized - made CPOutlineView return the last index when dragging the row outside of it's bounds --- AppKit/CPOutlineView.j | 5 +++++ AppKit/CPTableView.j | 31 ++++++++++++++----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/AppKit/CPOutlineView.j b/AppKit/CPOutlineView.j index 59870af6f..aee074e09 100644 --- a/AppKit/CPOutlineView.j +++ b/AppKit/CPOutlineView.j @@ -842,6 +842,11 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt children = itemInfo.children, childIndex = [children indexOfObject:droppedItem]; + + // When no child is found the index we want to add the item below all it's children + // Think about dragging an item below the collectionview + if (childIndex === -1) + childIndex = [children count]; } else if (theOperation === CPTableViewDropOn) { diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 6631c721d..63450685c 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -846,7 +846,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; - (int)selectedRow { - return [_selectedRowIndexes lastIndex]; + return [_selectedRowIndexes lastIndex]; } - (CPIndexSet)selectedRowIndexes @@ -1050,8 +1050,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; if ((_implementedDelegateMethods & CPTableViewDelegate_tableView_heightOfRow_)) { rowHeight = [_delegate tableView:self heightOfRow:aRowIndex]; - if (rowHeight !== _rowHeight) - _hasVariableRowHeight = YES; + _hasVariableRowHeight = YES; } else _hasVariableRowHeight = NO; @@ -1193,7 +1192,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; { row = [rowArray objectAtIndex:rowIndex]; - if (CPRectContainsPoint([self rectOfRow:[rowArray objectAtIndex:rowIndex]], aPoint)) + if (CPRectContainsPoint([self rectOfRow:row], aPoint)) break; // Make sure that the row is not found if we exit the loop without breaking @@ -1202,7 +1201,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; } if (row >= _numberOfRows) - return -1; + row = -1; return row; } @@ -2587,20 +2586,18 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; */ - (CPInteger)_proposedRowAtPoint:(CGPoint)dragPoint { - var numberOfRows = [self numberOfRows], - row; - // cocoa seems to jump to the next row when we approach the below row - dragPoint.y += FLOOR(_rowHeight/4); + dragPoint.y += 5.0; - if (dragPoint.y > numberOfRows * (_rowHeight + _intercellSpacing.height)) - { - if ([self _proposedDropOperationAtPoint:dragPoint] === CPTableViewDropAbove) - row = numberOfRows; - else - row = numberOfRows - 1; - } - else + var numberOfRows = [self numberOfRows], row = [self rowAtPoint:dragPoint]; + + // cocoa seems to jump to the next row when we approach the below row + // dragPoint.y += FLOOR(CPRectGetHeight([self rectOfRow:row]) / 4); + + // Check if we are dragging outside the tableview + // if we are we want the drag highlight to be below the last row + if (row === -1) + row = numberOfRows + 1; return row; }