예제 #1
0
 public virtual void ScrollViewDidZoom(CCScrollView view)
 {
 }
예제 #2
0
        public virtual void ScrollViewDidScroll(CCScrollView view)
        {
            var uCountOfItems = DataSource.NumberOfCellsInTableView(this);
            if (uCountOfItems == 0)
            {
                return;
            }

            if (Delegate != null)
            {
                Delegate.ScrollViewDidScroll(this);
            }

            int startIdx = 0, endIdx = 0, idx = 0, maxIdx = 0;
            CCPoint offset = ContentOffset * -1;
            maxIdx = Math.Max(uCountOfItems - 1, 0);

            if (vordering == CCTableViewVerticalFillOrder.FillTopDown)
            {
                offset.Y = offset.Y + ViewSize.Height / Container.ScaleY;
            }
            startIdx = IndexFromOffset(offset);
            if (startIdx == CCArrayForObjectSorting.CC_INVALID_INDEX)
            {
                startIdx = uCountOfItems - 1;
            }

            if (vordering == CCTableViewVerticalFillOrder.FillTopDown)
            {
                offset.Y -= ViewSize.Height / Container.ScaleY;
            }
            else
            {
                offset.Y += ViewSize.Height / Container.ScaleY;
            }
            offset.X += ViewSize.Width / Container.ScaleX;

            endIdx = IndexFromOffset(offset);
            if (endIdx == CCArrayForObjectSorting.CC_INVALID_INDEX)
            {
                endIdx = uCountOfItems - 1;
            }

#if DEBUG_ // For Testing.
			int i = 0;
			foreach (object pObj in cellsUsed)
			{
				var pCell = (CCTableViewCell)pObj;
				CCLog.Log("cells Used index {0}, value = {1}", i, pCell.getIdx());
				i++;
			}
			CCLog.Log("---------------------------------------");
			i = 0;
			foreach(object pObj in cellsFreed)
			{
				var pCell = (CCTableViewCell)pObj;
				CCLog.Log("cells freed index {0}, value = {1}", i, pCell.getIdx());
				i++;
			}
			CCLog.Log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
#endif

            if (cellsUsed.Count > 0)
            {
                var cell = (CCTableViewCell) cellsUsed[0];

                idx = cell.Index;
                while (idx < startIdx)
                {
					MoveCellOutOfSight(cell);
                    if (cellsUsed.Count > 0)
                    {
                        cell = (CCTableViewCell) cellsUsed[0];
                        idx = cell.Index;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            if (cellsUsed.Count > 0)
            {
                var cell = (CCTableViewCell) cellsUsed[cellsUsed.Count - 1];
                idx = cell.Index;

                while (idx <= maxIdx && idx > endIdx)
                {
                    MoveCellOutOfSight(cell);
                    if (cellsUsed.Count > 0)
                    {
                        cell = (CCTableViewCell) cellsUsed[cellsUsed.Count - 1];
                        idx = cell.Index;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            for (int i = startIdx; i <= endIdx; i++)
            {
                if (indices.Contains(i))
                {
                    continue;
                }
                UpdateCellAtIndex(i);
            }
        }