Exemplo n.º 1
0
        private void OnChangeHeight(float delta)
        {
            if (delta > 0)
            {
                int rowsCount = this.RowsCount;

                // append more visible cells at the end
                for (int cellIndex = this.LastVisibleCellIndex + 1; cellIndex < rowsCount && IsCellVisible(cellIndex); ++cellIndex)
                {
                    TableViewCell cell = TableCellForRow(cellIndex);
                    m_visibleCells.AddLastItem(cell);
                }
            }
            else if (delta < 0)
            {
                // wipe invisible cells
                while (this.VisibleCellsCount > 0 && !IsCellVisible(this.LastVisibleCellIndex))
                {
                    RemoveVisibleCell(this.LastVisibleCell);
                }
            }
        }
Exemplo n.º 2
0
        private void AddCell()
        {
            // the "head" index will be moved after new element is added
            if (m_cellsEntries.RealLength == m_cellsEntries.Capacity)
            {
                // "shift" content to compensate the lost cell
                int headIndex = m_cellsEntries.HeadIndex;
                ShiftContent(m_cellsEntries[headIndex].Height);
            }

            int   cellIndex  = m_cellsEntries.Length;
            float cellHeight = Delegate.HeightForTableCell(cellIndex);

            m_cellsEntries.Add(new TableViewCellEntry(m_totalHeight, cellHeight));

            if (IsCellVisible(cellIndex, m_scrollPos))
            {
                TableViewCell cell = TableCellForRow(cellIndex);
                m_visibleCells.AddLastItem(cell);
            }

            m_totalHeight += cellHeight;
        }
Exemplo n.º 3
0
 private bool IsCellSelected(TableViewCell cell)
 {
     return(IsCellSelected(cell.CellIndex));
 }
Exemplo n.º 4
0
 private void SetCellSelected(TableViewCell cell, bool flag)
 {
     SetCellSelected(cell.CellIndex, flag);
 }
Exemplo n.º 5
0
 protected virtual bool OnMouseDoubleClick(Event evt, TableViewCell cell)
 {
     return(false);
 }
Exemplo n.º 6
0
 protected virtual bool OnMouseDown(Event evt, TableViewCell cell)
 {
     return(this.SelectionMode != TableViewSelectionMode.None && OnCellSelected(cell));
 }
Exemplo n.º 7
0
        protected void OnScroll(float oldPos, float newPos)
        {
            float delta = newPos - oldPos;

            int firstVisibleCellIndex = FirstVisibleCellIndex;
            int lastVisibleCellIndex  = LastVisibleCellIndex;

            if (delta > 0)
            {
                int rowsCount = RowsCount;

                // wipe invisible rows
                while (!IsCellVisible(firstVisibleCellIndex, newPos) && VisibleCellsCount > 0)
                {
                    RemoveVisibleCell(FirstVisibleCell);
                    ++firstVisibleCellIndex;
                }

                if (VisibleCellsCount > 0) // not all rows were wiped: just append more visible cells at the end
                {
                    for (int cellIndex = lastVisibleCellIndex + 1; cellIndex < rowsCount && IsCellVisible(cellIndex, newPos); ++cellIndex)
                    {
                        TableViewCell cell = TableCellForRow(cellIndex);
                        m_visibleCells.AddLastItem(cell);
                    }
                }
                else
                {
                    int rowIndex = FindFirstVisibleRow(newPos, lastVisibleCellIndex + 1, rowsCount - 1);
                    while (rowIndex < rowsCount && IsCellVisible(rowIndex, newPos))
                    {
                        TableViewCell cell = TableCellForRow(rowIndex);
                        m_visibleCells.AddLastItem(cell);
                        ++rowIndex;
                    }
                }
            }
            else if (delta < 0)
            {
                while (this.VisibleCellsCount > 0 && !IsCellVisible(lastVisibleCellIndex, newPos))
                {
                    RemoveVisibleCell(LastVisibleCell);
                    --lastVisibleCellIndex;
                }

                if (VisibleCellsCount > 0) // not all rows were wiped: just prepend more visible cells at the beginning
                {
                    for (int cellIndex = firstVisibleCellIndex - 1; cellIndex >= m_cellsEntries.HeadIndex && IsCellVisible(cellIndex, newPos); --cellIndex)
                    {
                        TableViewCell cell = TableCellForRow(cellIndex);
                        m_visibleCells.AddFirstItem(cell);
                    }
                }
                else
                {
                    int rowIndex = FindLastVisibleRow(newPos, m_cellsEntries.HeadIndex, firstVisibleCellIndex - 1);
                    while (rowIndex >= m_cellsEntries.HeadIndex && IsCellVisible(rowIndex, newPos))
                    {
                        TableViewCell cell = TableCellForRow(rowIndex);
                        m_visibleCells.AddFirstItem(cell);
                        --rowIndex;
                    }
                }
            }

            if (ScrollDelegate != null)
            {
                ScrollDelegate.OnTableScroll(this, oldPos);
            }
        }
Exemplo n.º 8
0
 private void RemoveVisibleCell(TableViewCell cell)
 {
     m_visibleCells.RemoveItem(cell);
     RecycleCell(cell);
 }