mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-17 04:00:42 +00:00
- reduced the number of rows on the tableview sample so it works with the variable row heights
- made CPTableView ask for the rect of the drop highlight so CPOutlineView can adjust this - re factored some stuff in CPOutlineView's table delegate
This commit is contained in:
1 parent
766073f77a
commit
117ec9970c
4 files changed
+101
-69
No files matched your search
+82
-40
@@ -500,11 +500,11 @@ var CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_
|
||||
return [super frameOfDataViewAtColumn:aColumn row:aRow];
|
||||
}
|
||||
|
||||
- (CPRect)rectForDropHighlightViewBetweenUpperRow:(int)theUpperRowIndex andLowerRow:(int)theLowerRowIndex
|
||||
- (CPRect)_rectForDropHighlightViewBetweenUpperRow:(int)theUpperRowIndex andLowerRow:(int)theLowerRowIndex offset:(float)theXOffset
|
||||
{
|
||||
// Just call super and update the x to reflect the current indentation level
|
||||
var level = [self levelForRow:theLowerRowIndex],
|
||||
rect = [super rectForDropHighlightViewBetweenUpperRow:theUpperRowIndex andLowerRow:theLowerRowIndex];
|
||||
var level = [self levelForRow:theUpperRowIndex],
|
||||
rect = [super _rectForDropHighlightViewBetweenUpperRow:theUpperRowIndex andLowerRow:theLowerRowIndex offset:theXOffset];
|
||||
|
||||
rect.origin.x = level * [self indentationPerLevel];
|
||||
return rect;
|
||||
@@ -826,33 +826,68 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
return [_outlineView._outlineViewDataSource outlineView:_outlineView writeItems:items toPasteboard:thePasteboard];
|
||||
}
|
||||
|
||||
- (int)_childIndexForDropOperation:(CPTableViewDropOperation)theDropOperation item:(id)theItem
|
||||
{
|
||||
var parentItem = [_outlineView parentForItem:theItem],
|
||||
childIndex = CPNotFound;
|
||||
|
||||
if (theDropOperation === CPTableViewDropAbove)
|
||||
{
|
||||
var itemInfo = (parentItem !== nil) ? _outlineView._itemInfosForItems[[parentItem UID]] : _outlineView._rootItemInfo,
|
||||
children = itemInfo.children;
|
||||
|
||||
childIndex = [children indexOfObject:theItem];
|
||||
|
||||
// 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)
|
||||
childIndex = -1;
|
||||
|
||||
return childIndex;
|
||||
}
|
||||
|
||||
- (void)_parentItemForDropOperation:(CPTableViewDropOperation)theDropOperation item:(id)theItem
|
||||
{
|
||||
if (theDropOperation === CPTableViewDropAbove)
|
||||
return [_outlineView parentForItem:theItem];
|
||||
|
||||
else
|
||||
return theItem;
|
||||
}
|
||||
|
||||
- (CPDragOperation)tableView:(CPTableView)aTableView validateDrop:(id < CPDraggingInfo >)theInfo
|
||||
proposedRow:(int)theRow proposedDropOperation:(CPTableViewDropOperation)theOperation
|
||||
{
|
||||
if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_validateDrop_proposedItem_proposedChildIndex_))
|
||||
return CPDragOperationNone;
|
||||
|
||||
var droppedItem = [_outlineView itemAtRow:theRow],
|
||||
parentItem = [_outlineView parentForItem:droppedItem];
|
||||
childIndex = CPNotFound;
|
||||
|
||||
if (theOperation === CPTableViewDropAbove)
|
||||
{
|
||||
var itemInfo = (parentItem != nil) ? _outlineView._itemInfosForItems[[parentItem UID]] : _outlineView._rootItemInfo,
|
||||
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)
|
||||
{
|
||||
parentItem = droppedItem;
|
||||
childIndex = -1;
|
||||
}
|
||||
var childIndex = [self _childIndexForDropOperation:theOperation item:[_outlineView itemAtRow:theRow]],
|
||||
parentItem = [self _parentItemForDropOperation:theOperation item:[_outlineView itemAtRow:theRow]];
|
||||
|
||||
// var droppedItem = [_outlineView itemAtRow:theRow],
|
||||
// parentItem = [_outlineView parentForItem:droppedItem];
|
||||
// childIndex = CPNotFound;
|
||||
//
|
||||
// if (theOperation === CPTableViewDropAbove)
|
||||
// {
|
||||
// var itemInfo = (parentItem != nil) ? _outlineView._itemInfosForItems[[parentItem UID]] : _outlineView._rootItemInfo,
|
||||
// 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)
|
||||
// {
|
||||
// parentItem = droppedItem;
|
||||
// childIndex = -1;
|
||||
// }
|
||||
|
||||
return [_outlineView._outlineViewDataSource outlineView:_outlineView validateDrop:theInfo proposedItem:parentItem proposedChildIndex:childIndex];
|
||||
}
|
||||
@@ -862,22 +897,29 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt
|
||||
if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_acceptDrop_item_childIndex_))
|
||||
return NO;
|
||||
|
||||
var droppedItem = [_outlineView itemAtRow:theRow],
|
||||
parentItem = [_outlineView parentForItem:droppedItem];
|
||||
childIndex = CPNotFound;
|
||||
|
||||
if (theOperation === CPTableViewDropAbove)
|
||||
{
|
||||
var itemInfo = (parentItem != nil) ? _outlineView._itemInfosForItems[[parentItem UID]] : _outlineView._rootItemInfo,
|
||||
children = itemInfo.children,
|
||||
|
||||
childIndex = [children indexOfObject:droppedItem];
|
||||
}
|
||||
else if (theOperation === CPTableViewDropOn)
|
||||
{
|
||||
parentItem = droppedItem;
|
||||
childIndex = -1;
|
||||
}
|
||||
// var droppedItem = [_outlineView itemAtRow:theRow],
|
||||
// parentItem = [_outlineView parentForItem:droppedItem];
|
||||
// childIndex = CPNotFound;
|
||||
//
|
||||
// if (theOperation === CPTableViewDropAbove)
|
||||
// {
|
||||
// var itemInfo = (parentItem != nil) ? _outlineView._itemInfosForItems[[parentItem UID]] : _outlineView._rootItemInfo,
|
||||
// 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)
|
||||
// {
|
||||
// parentItem = droppedItem;
|
||||
// childIndex = -1;
|
||||
// }
|
||||
var childIndex = [self _childIndexForDropOperation:theOperation item:[_outlineView itemAtRow:theRow]],
|
||||
parentItem = [self _parentItemForDropOperation:theOperation item:[_outlineView itemAtRow:theRow]];
|
||||
|
||||
return [_outlineView._outlineViewDataSource outlineView:_outlineView acceptDrop:theInfo item:parentItem childIndex:childIndex];
|
||||
}
|
||||
|
||||
@@ -2589,6 +2589,11 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
return CPDragOperationNone;
|
||||
}
|
||||
|
||||
- (CPRect)_rectForDropHighlightViewBetweenUpperRow:(int)theUpperRowIndex andLowerRow:(int)theLowerRowIndex offset:(float)theXOffset
|
||||
{
|
||||
return [self rectOfRow:theUpperRowIndex];
|
||||
}
|
||||
|
||||
- (CPDragOperation)draggingUpdated:(id)sender
|
||||
{
|
||||
var location = [self convertPoint:[sender draggingLocation] fromView:nil],
|
||||
@@ -2615,7 +2620,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
|
||||
|
||||
[_dropOperationFeedbackView setDropOperation:dropOperation];
|
||||
[_dropOperationFeedbackView setHidden:(dragOperation == CPDragOperationNone)];
|
||||
[_dropOperationFeedbackView setFrame:rowRect];
|
||||
[_dropOperationFeedbackView setFrame:[self _rectForDropHighlightViewBetweenUpperRow:row andLowerRow:row + 1 offset:location.x]];
|
||||
[_dropOperationFeedbackView setCurrentRow:row];
|
||||
[self addSubview:_dropOperationFeedbackView];
|
||||
|
||||
|
||||
@@ -49,22 +49,12 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
|
||||
- (CPString)description
|
||||
{
|
||||
return [self descriptionWithChildren:YES];
|
||||
}
|
||||
|
||||
- (CPString)descriptionWithChildren:(BOOL)showChildren
|
||||
{
|
||||
var description = [super description] + @" " + [self title];
|
||||
|
||||
if (showChildren && [[self children] count] > 0)
|
||||
description = @"\n" + [description stringByAppendingFormat:@" children: %@", [self children]];
|
||||
|
||||
return description;
|
||||
return [self title];
|
||||
}
|
||||
|
||||
- (void)insertSubmenu:(Menu)theItem atIndex:(int)theIndex
|
||||
{
|
||||
CPLog.debug(@"insert menu: %@ in menu: %@ at index: %i", [theItem descriptionWithChildren:NO], [self descriptionWithChildren:NO], theIndex);
|
||||
CPLog.debug(@"insert menu: %@ in menu: %@ at index: %i", theItem, self, theIndex);
|
||||
|
||||
if ([[self children] containsObject:theItem])
|
||||
return;
|
||||
@@ -78,7 +68,7 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
|
||||
- (void)removeFromMenu
|
||||
{
|
||||
CPLog.debug(@"remove menu: %@ from menu: %@", [self descriptionWithChildren:NO], [[self menu] descriptionWithChildren:NO]);
|
||||
CPLog.debug(@"remove menu: %@ from menu: %@", self, [self menu]);
|
||||
|
||||
[[[self menu] children] removeObject:self];
|
||||
|
||||
@@ -193,27 +183,15 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
|
||||
[_outlineView setDataSource:self];
|
||||
[_outlineView setAllowsMultipleSelection:YES];
|
||||
[_outlineView expandItem:nil expandChildren:YES];
|
||||
// [_outlineView setIntercellSpacing:CPSizeMake(0.0, 0.0)]
|
||||
|
||||
// [scrollView setDocumentView:_outlineView];
|
||||
[theWindow setContentView:_outlineView];
|
||||
|
||||
[self expandItem:[self menu]];
|
||||
|
||||
[theWindow orderFront:self];
|
||||
}
|
||||
|
||||
- (void)expandItem:(Menu)item
|
||||
{
|
||||
var children = [item children],
|
||||
childIndex = [children count];
|
||||
|
||||
while (childIndex--)
|
||||
[self expandItem:[children objectAtIndex:childIndex]];
|
||||
|
||||
[_outlineView expandItem:item];
|
||||
}
|
||||
|
||||
- (id)outlineView:(CPOutlineView)theOutlineView child:(int)theIndex ofItem:(id)theItem
|
||||
{
|
||||
if (theItem === nil)
|
||||
@@ -265,6 +243,11 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
|
||||
- (CPDragOperation)outlineView:(CPOutlineView)anOutlineView validateDrop:(id < CPDraggingInfo >)theInfo proposedItem:(id)theItem proposedChildIndex:(int)theIndex
|
||||
{
|
||||
if (theItem === nil)
|
||||
theItem = [self menu];
|
||||
|
||||
CPLog.debug(@"validate item: %@ at index: %i", theItem, theIndex);
|
||||
|
||||
return CPDragOperationEvery;
|
||||
}
|
||||
|
||||
@@ -272,6 +255,8 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
{
|
||||
if (theItem === nil)
|
||||
theItem = [self menu];
|
||||
|
||||
CPLog.debug(@"drop item: %@ at index: %i", theItem, theIndex);
|
||||
|
||||
var menuIndex = [_draggedItems count];
|
||||
while (menuIndex--)
|
||||
@@ -285,7 +270,7 @@ CustomOutlineViewDragType = @"CustomOutlineViewDragType";
|
||||
theIndex += 1;
|
||||
}
|
||||
|
||||
CPLog.debug([[self menu] descriptionWithChildren:YES]);
|
||||
CPLog.debug([self menu]);
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ CPLogRegister(CPLogConsole);
|
||||
dataSet1 = [],
|
||||
dataSet2 = [];
|
||||
|
||||
for(var i = 1; i < 500000; i++)
|
||||
for(var i = 1; i < 100; i++)
|
||||
{
|
||||
dataSet1[i - 1] = i;
|
||||
dataSet2[i - 1] = i + 10;
|
||||
|
||||
Reference in new issue
Block a user