From 35a74563026c25d4d2c074e579a338daeeb048f1 Mon Sep 17 00:00:00 2001 From: cacaodev Date: Mon, 1 Feb 2010 11:51:50 +0100 Subject: [PATCH 1/5] Fixes rows drawing when alternatingRowBackgroundColors > 2. TableTest showing 3 row colors --- AppKit/CPTableView.j | 12 ++++-------- Tests/Manual/TableTest/AppController.j | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 062ab6594..cdb0866bd 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -1954,11 +1954,6 @@ window.setTimeout(function(){ [self highlightSelectionInClipRect:exposedRect]; } -- (void)drawRect:(CGRect)aRect -{ - [_tableDrawView display]; -} - - (void)drawBackgroundInClipRect:(CGRect)aRect { if (![self usesAlternatingRowBackgroundColors]) @@ -1982,20 +1977,21 @@ window.setTimeout(function(){ // CGContextFillRect(context, CGRectIntersection(aRect, fillRect)); // console.profile("row-paint"); var exposedRows = [self rowsInRect:aRect], - firstRow = exposedRows.location -1, + firstRow = exposedRows.location, lastRow = CPMaxRange(exposedRows) - 1, colorIndex = MIN(exposedRows.length, colorCount), heightFilled = 0.0; while (colorIndex--) { - var row = firstRow % colorCount + firstRow + colorIndex, + var row = firstRow - firstRow % colorCount + colorIndex, fillRect = nil; CGContextBeginPath(context); for (; row <= lastRow; row += colorCount) - CGContextAddRect(context, CGRectIntersection(aRect, fillRect = [self rectOfRow:row])); + if (row >= firstRow) + CGContextAddRect(context, CGRectIntersection(aRect, fillRect = [self rectOfRow:row])); if (row - colorCount === lastRow) heightFilled = _CGRectGetMaxY(fillRect); diff --git a/Tests/Manual/TableTest/AppController.j b/Tests/Manual/TableTest/AppController.j index eb4b7830a..98fb0d160 100644 --- a/Tests/Manual/TableTest/AppController.j +++ b/Tests/Manual/TableTest/AppController.j @@ -39,6 +39,7 @@ CPLogRegister(CPLogConsole); [tableView setAllowsMultipleSelection:YES]; [tableView setAllowsColumnSelection:YES]; [tableView setUsesAlternatingRowBackgroundColors:YES]; + [tableView setAlternatingRowBackgroundColors:[[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"], [CPColor colorWithHexString:@"f4e7ff"]]]; [tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask]; // [tableView setBackgroundColor:[CPColor blueColor]]; From 775c1c1c8b9665ea0ccb8762545e6c93db2c76b5 Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Mon, 1 Feb 2010 11:11:51 -0500 Subject: [PATCH 2/5] Fixed the outline view again... --- AppKit/CPTableView.j | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index cdb0866bd..bc12f321e 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -245,11 +245,11 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; [_headerView setTableView:self]; _cornerView = [[_CPCornerView alloc] initWithFrame:CGRectMake(0, 0, [CPScroller scrollerWidth], CGRectGetHeight([_headerView frame]))]; - - +//FIX ME: This is disgusting! but used to fix a Safari bug where the outlineview breaks for whatever reason... +window.setTimeout(function(){ _selectedColumnIndexes = [CPIndexSet indexSet]; _selectedRowIndexes = [CPIndexSet indexSet]; -window.setTimeout(function(){ + self._draggedRowIndexes = [CPIndexSet indexSet]; self._verticalMotionCanDrag = YES; self._isSelectingSession = NO; From cc74f941c67233aa47a5802d9794dd8d42455763 Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Mon, 1 Feb 2010 11:44:24 -0500 Subject: [PATCH 3/5] Better "fix" for Safari breaking the outlineview... This bug still needs a reduction though. --- AppKit/CPOutlineView.j | 236 +++++++++++++++++++++-------------------- AppKit/CPTableView.j | 36 +++---- 2 files changed, 138 insertions(+), 134 deletions(-) diff --git a/AppKit/CPOutlineView.j b/AppKit/CPOutlineView.j index 972d48d64..b38f754e4 100644 --- a/AppKit/CPOutlineView.j +++ b/AppKit/CPOutlineView.j @@ -618,140 +618,146 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_ @end +// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever... var _reloadItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem) { if (!anItem) return; - - // Get the existing info if it exists. - var itemInfosForItems = anOutlineView._itemInfosForItems, - dataSource = anOutlineView._outlineViewDataSource, - itemUID = [anItem UID], - itemInfo = itemInfosForItems[itemUID]; - - // If we're not in the tree, then just bail. - if (!itemInfo) - return []; - - // See if the item itself can be swapped out. - var parent = itemInfo.parent, - parentItemInfo = parent ? itemInfosForItems[[parent UID]] : anOutlineView._rootItemInfo, - parentChildren = parentItemInfo.children, - index = [parentChildren indexOfObjectIdenticalTo:anItem], - newItem = [dataSource outlineView:anOutlineView child:index ofItem:parent]; - - if (anItem !== newItem) - { - itemInfosForItems[[anItem UID]] = nil; - itemInfosForItems[[newItem UID]] = itemInfo; - - parentChildren[index] = newItem; - anOutlineView._itemsForRows[itemInfo.row] = newItem; - } - - itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:newItem]; - itemInfo.isExpanded = itemInfo.isExpandable && itemInfo.isExpanded; -} - -var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem, /*BOOL*/ isIntermediate) -{ - var itemInfosForItems = anOutlineView._itemInfosForItems, - dataSource = anOutlineView._outlineViewDataSource; - - if (!anItem) - var itemInfo = anOutlineView._rootItemInfo; - - else + with(anOutlineView) { // Get the existing info if it exists. - var itemUID = [anItem UID], + var itemInfosForItems = _itemInfosForItems, + dataSource = _outlineViewDataSource, + itemUID = [anItem UID], itemInfo = itemInfosForItems[itemUID]; - + // If we're not in the tree, then just bail. if (!itemInfo) return []; - - itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:anItem]; - - // If we were previously expanded, but now no longer expandable, "de-expand". - // NOTE: we are *not* collapsing, thus no notification is posted. - if (!itemInfo.isExpandable && itemInfo.isExpanded) + + // See if the item itself can be swapped out. + var parent = itemInfo.parent, + parentItemInfo = parent ? itemInfosForItems[[parent UID]] : _rootItemInfo, + parentChildren = parentItemInfo.children, + index = [parentChildren indexOfObjectIdenticalTo:anItem], + newItem = [dataSource outlineView:anOutlineView child:index ofItem:parent]; + + if (anItem !== newItem) { - itemInfo.isExpanded = NO; + itemInfosForItems[[anItem UID]] = nil; + itemInfosForItems[[newItem UID]] = itemInfo; + + parentChildren[index] = newItem; + _itemsForRows[itemInfo.row] = newItem; + } + + itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:newItem]; + itemInfo.isExpanded = itemInfo.isExpandable && itemInfo.isExpanded; + } +} + +// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever... +var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem, /*BOOL*/ isIntermediate) +{ + with(anOutlineView) + { + var itemInfosForItems = _itemInfosForItems, + dataSource = _outlineViewDataSource; + + if (!anItem) + var itemInfo = _rootItemInfo; + + else + { + // Get the existing info if it exists. + var itemUID = [anItem UID], + itemInfo = itemInfosForItems[itemUID]; + + // If we're not in the tree, then just bail. + if (!itemInfo) + return []; + + itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:anItem]; + + // If we were previously expanded, but now no longer expandable, "de-expand". + // NOTE: we are *not* collapsing, thus no notification is posted. + if (!itemInfo.isExpandable && itemInfo.isExpanded) + { + itemInfo.isExpanded = NO; + itemInfo.children = []; + } + } + + // The root item does not count as a descendant. + var weight = itemInfo.weight, + descendants = anItem ? [anItem] : []; + + if (itemInfo.isExpanded && (!(_implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_shouldDeferDisplayingChildrenOfItem_) || + ![dataSource outlineView:anOutlineView shouldDeferDisplayingChildrenOfItem:anItem])) + { + var index = 0, + count = [dataSource outlineView:anOutlineView numberOfChildrenOfItem:anItem], + level = itemInfo.level + 1; + itemInfo.children = []; - } - } - - // The root item does not count as a descendant. - var weight = itemInfo.weight, - descendants = anItem ? [anItem] : []; - - if (itemInfo.isExpanded && (!(anOutlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_shouldDeferDisplayingChildrenOfItem_) || - ![dataSource outlineView:anOutlineView shouldDeferDisplayingChildrenOfItem:anItem])) - { - var index = 0, - count = [dataSource outlineView:anOutlineView numberOfChildrenOfItem:anItem], - level = itemInfo.level + 1; - - itemInfo.children = []; - - for (; index < count; ++index) - { - var childItem = [dataSource outlineView:anOutlineView child:index ofItem:anItem], - childItemInfo = itemInfosForItems[[childItem UID]]; - - if (!childItemInfo) + + for (; index < count; ++index) { - childItemInfo = { isExpanded:NO, isExpandable:NO, children:[], weight:1 }; - itemInfosForItems[[childItem UID]] = childItemInfo; + var childItem = [dataSource outlineView:anOutlineView child:index ofItem:anItem], + childItemInfo = itemInfosForItems[[childItem UID]]; + + if (!childItemInfo) + { + childItemInfo = { isExpanded:NO, isExpandable:NO, children:[], weight:1 }; + itemInfosForItems[[childItem UID]] = childItemInfo; + } + + itemInfo.children[index] = childItem; + + var childDescendants = _loadItemInfoForItem(anOutlineView, childItem, YES); + + childItemInfo.parent = anItem; + childItemInfo.level = level; + descendants = descendants.concat(childDescendants); } - - itemInfo.children[index] = childItem; - - var childDescendants = _loadItemInfoForItem(anOutlineView, childItem, YES); - - childItemInfo.parent = anItem; - childItemInfo.level = level; - descendants = descendants.concat(childDescendants); } - } - - itemInfo.weight = descendants.length; - - if (!isIntermediate) - { - // row = -1 is the root item, so just go to row 0 since it is ignored. - var index = MAX(itemInfo.row, 0), - itemsForRows = anOutlineView._itemsForRows; - - descendants.unshift(index, weight); - - itemsForRows.splice.apply(itemsForRows, descendants); - - var count = itemsForRows.length; - - for (; index < count; ++index) - itemInfosForItems[[itemsForRows[index] UID]].row = index; - - var deltaWeight = itemInfo.weight - weight; - - if (deltaWeight !== 0) + + itemInfo.weight = descendants.length; + + if (!isIntermediate) { - var parent = itemInfo.parent; - - while (parent) + // row = -1 is the root item, so just go to row 0 since it is ignored. + var index = MAX(itemInfo.row, 0), + itemsForRows = _itemsForRows; + + descendants.unshift(index, weight); + + itemsForRows.splice.apply(itemsForRows, descendants); + + var count = itemsForRows.length; + + for (; index < count; ++index) + itemInfosForItems[[itemsForRows[index] UID]].row = index; + + var deltaWeight = itemInfo.weight - weight; + + if (deltaWeight !== 0) { - var parentItemInfo = itemInfosForItems[[parent UID]]; - - parentItemInfo.weight += deltaWeight; - parent = parentItemInfo.parent; + var parent = itemInfo.parent; + + while (parent) + { + var parentItemInfo = itemInfosForItems[[parent UID]]; + + parentItemInfo.weight += deltaWeight; + parent = parentItemInfo.parent; + } + + if (anItem) + _rootItemInfo.weight += deltaWeight; } - - if (anItem) - anOutlineView._rootItemInfo.weight += deltaWeight; } - } - + }//end of with return descendants; } diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index bc12f321e..74aeaffc6 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -190,14 +190,14 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; SEL _doubleAction; unsigned _columnAutoResizingStyle; -// BOOL _verticalMotionCanDrag; -// unsigned _destinationDragStyle; -// BOOL _isSelectingSession; -// CPIndexSet _draggedRowIndexes; -// _dropOperationDrawingView _dropOperationFeedbackView; -// CPDragOperation _dragOperationDefaultMask; -// int _retargetedDropRow; -// CPDragOperation _retargetedDropOperation; + BOOL _verticalMotionCanDrag; + unsigned _destinationDragStyle; + BOOL _isSelectingSession; + CPIndexSet _draggedRowIndexes; + _dropOperationDrawingView _dropOperationFeedbackView; + CPDragOperation _dragOperationDefaultMask; + int _retargetedDropRow; + CPDragOperation _retargetedDropOperation; } - (id)initWithFrame:(CGRect)aFrame @@ -245,23 +245,21 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; [_headerView setTableView:self]; _cornerView = [[_CPCornerView alloc] initWithFrame:CGRectMake(0, 0, [CPScroller scrollerWidth], CGRectGetHeight([_headerView frame]))]; -//FIX ME: This is disgusting! but used to fix a Safari bug where the outlineview breaks for whatever reason... -window.setTimeout(function(){ + _selectedColumnIndexes = [CPIndexSet indexSet]; _selectedRowIndexes = [CPIndexSet indexSet]; - self._draggedRowIndexes = [CPIndexSet indexSet]; - self._verticalMotionCanDrag = YES; - self._isSelectingSession = NO; - self._retargetedDropRow = nil; - self._retargetedDropOperation = nil; - self._dragOperationDefaultMask = nil; - self._destinationDragStyle = CPTableViewDraggingDestinationFeedbackStyleRegular; - self._dropOperationFeedbackView = [[_dropOperationDrawingView alloc] initWithFrame:_CGRectMakeZero()]; + _draggedRowIndexes = [CPIndexSet indexSet]; + _verticalMotionCanDrag = YES; + _isSelectingSession = NO; + _retargetedDropRow = nil; + _retargetedDropOperation = nil; + _dragOperationDefaultMask = nil; + _destinationDragStyle = CPTableViewDraggingDestinationFeedbackStyleRegular; + _dropOperationFeedbackView = [[_dropOperationDrawingView alloc] initWithFrame:_CGRectMakeZero()]; [self addSubview:_dropOperationFeedbackView]; [_dropOperationFeedbackView setHidden:YES]; [_dropOperationFeedbackView setTableView:self]; -},0); _tableDrawView = [[_CPTableDrawView alloc] initWithTableView:self]; [_tableDrawView setBackgroundColor:[CPColor clearColor]]; From e88ec01fcac66b5de58ad087a611de1f47342537 Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Mon, 1 Feb 2010 23:26:24 -0500 Subject: [PATCH 4/5] Fixed bug where the first click on the CPTableView wouldn't select a row if drag and drop was supported. --- AppKit/CPTableView.j | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 74aeaffc6..1738b0d18 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -2395,9 +2395,9 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; rowIndex = [self rowAtPoint:aPoint]; if (rowIndex !== -1) { - if(_draggedRowIndexes !== nil) + if ([_draggedRowIndexes count] > 0) { - _draggedRowIndexes = nil; + _draggedRowIndexes = [CPIndexSet indexSet]; return; } // if the table has drag support then we use mouseUp to select a single row. From 6b58986ec38706f070dd602ad4d2d73e827ae99d Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Tue, 2 Feb 2010 01:56:53 -0500 Subject: [PATCH 5/5] Added better artwork for pressed header images for the tableview. --- ...tableview-headerview-highlighted-pressed.png | Bin 133 -> 153 bytes .../Resources/tableview-headerview-pressed.png | Bin 136 -> 129 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/AppKit/Resources/tableview-headerview-highlighted-pressed.png b/AppKit/Resources/tableview-headerview-highlighted-pressed.png index cd4464d36692ff7a9eb40de496c2264f30bde8af..b0a0ff82ad5a90c6c9a19763632f32bb64a70c7e 100644 GIT binary patch delta 101 zcmV-r0Gj`W0hs}i7YY{$0ssI2MfkEYgr+Ar-fhs(!vQy}aCi{!9r;$%8W*8yU|X lJC>f3!q8pb diff --git a/AppKit/Resources/tableview-headerview-pressed.png b/AppKit/Resources/tableview-headerview-pressed.png index e79e7253901680bf786dd33639a0dcf2c2231dc5..e032e53dee9cf83b2d246806f34700bb8cbc7b51 100644 GIT binary patch delta 77 zcmeBRY-F4u&Lz&l#K6Gd`eReXL`4k?WltB!kcwML7RAqagqfL{FaQ7lzwnYlPj|no h?di$t{tQe!3>m9+B*cU7eg|q}@O1TaS?83{1OUPr8NC1i delta 84 zcmV-a0IUCj0f+&R7YY^#0ssI2j-+Azks&BQDoI2^RCwBAeE q@zF7oJmbHA|3G}k|Ns931Q-A#_X!vq&5r5-0000