Пример #1
0
        /**
         * Returns a scroll view object
         *
         * @param size view size
         * @param container parent object
         * @return scroll view object
         */

        protected virtual bool InitWithViewSize(CCSize size, CCNode container)
        {
            m_pContainer = container ?? new CCLayer();

            if (base.Init())
            {
                ViewSize = size;

                TouchEnabled        = true;
                m_pTouches          = new List <CCTouch>();
                m_pDelegate         = null;
                m_bBounceable       = true;
                m_bClippingToBounds = true;
                //m_pContainer->setContentSize(CCSizeZero);
                m_eDirection          = CCScrollViewDirection.Both;
                m_pContainer.Position = new CCPoint(0.0f, 0.0f);
                m_fTouchLength        = 0.0f;

                AddChild(m_pContainer);
                m_fMinScale = m_fMaxScale = 1.0f;

                return(true);
            }
            return(false);
        }
Пример #2
0
        /**
         * reloads data from data source.  the view will be refreshed.
         */
        public void ReloadData()
        {
            m_eOldDirection = CCScrollViewDirection.None;

            foreach (CCTableViewCell cell in m_pCellsUsed)
            {
                if (m_pTableViewDelegate != null)
                {
                    m_pTableViewDelegate.TableCellWillRecycle(this, cell);
                }

                m_pCellsFreed.Add(cell);
                cell.Reset();
                if (cell.Parent == Container)
                {
                    Container.RemoveChild(cell, true);
                }
            }

            m_pIndices.Clear();
            m_pCellsUsed = new CCArrayForObjectSorting();

            _updateCellPositions();
            _updateContentSize();
            if (m_pDataSource.NumberOfCellsInTableView(this) > 0)
            {
                ScrollViewDidScroll(this);
            }
        }
Пример #3
0
        /**
         * Returns a scroll view object
         *
         * @param size view size
         * @param container parent object
         * @return scroll view object
         */

        protected virtual bool InitWithViewSize(CCSize size, CCNode container)
        {
            if (base.Init())
            {
                _container = container;

                if (_container == null)
                {
                    _container = new CCLayer();
                    _container.IgnoreAnchorPointForPosition = false;
                    _container.AnchorPoint = CCPoint.Zero;
                }

                ViewSize = size;

                TouchEnabled        = true;
                _touches            = new List <CCTouch>();
                _delegate           = null;
                _bounceable         = true;
                _clippingToBounds   = true;
                _direction          = CCScrollViewDirection.Both;
                _container.Position = new CCPoint(0.0f, 0.0f);
                _touchLength        = 0.0f;

                AddChild(_container);
                _minScale = _maxScale = 1.0f;

                return(true);
            }
            return(false);
        }
Пример #4
0
        protected void _updateContentSize()
        {
            CCSize size, cellSize;
            int    cellCount;

            cellSize  = m_pDataSource.CellSizeForTable(this);
            cellCount = m_pDataSource.NumberOfCellsInTableView(this);

            switch (Direction)
            {
            case CCScrollViewDirection.Horizontal:
                size = new CCSize(cellCount * cellSize.Width, cellSize.Height);
                break;

            default:
                size = new CCSize(cellSize.Width, cellCount * cellSize.Height);
                break;
            }
            ContentSize = size;

            if (m_eOldDirection != m_eDirection)
            {
                if (m_eDirection == CCScrollViewDirection.Horizontal)
                {
                    SetContentOffset(CCPoint.Zero);
                }
                else
                {
                    SetContentOffset(new CCPoint(0, MinContainerOffset.Y));
                }
                m_eOldDirection = m_eDirection;
            }
        }
Пример #5
0
        protected void _updateContentSize()
        {
            CCSize size       = CCSize.Zero;
            int    cellsCount = m_pDataSource.NumberOfCellsInTableView(this);

            if (cellsCount > 0)
            {
                float maxPosition = m_vCellsPositions[cellsCount];

                switch (Direction)
                {
                case CCScrollViewDirection.Horizontal:
                    size = new CCSize(maxPosition, m_tViewSize.Height);
                    break;

                default:
                    size = new CCSize(m_tViewSize.Width, maxPosition);
                    break;
                }
            }

            ContentSize = size;

            if (m_eOldDirection != m_eDirection)
            {
                if (m_eDirection == CCScrollViewDirection.Horizontal)
                {
                    SetContentOffset(CCPoint.Zero);
                }
                else
                {
                    SetContentOffset(new CCPoint(0, MinContainerOffset.Y));
                }
                m_eOldDirection = m_eDirection;
            }
        }
Пример #6
0
 public CCTableView()
 {
     m_eOldDirection = CCScrollViewDirection.None;
 }
Пример #7
0
        protected void _updateContentSize()
        {
            CCSize size, cellSize;
            int cellCount;

            cellSize = m_pDataSource.CellSizeForTable(this);
            cellCount = m_pDataSource.NumberOfCellsInTableView(this);

            switch (Direction)
            {
                case CCScrollViewDirection.Horizontal:
                    size = new CCSize(cellCount * cellSize.Width, cellSize.Height);
                    break;
                default:
                    size = new CCSize(cellSize.Width, cellCount * cellSize.Height);
                    break;
            }
            ContentSize = size;

            if (m_eOldDirection != m_eDirection)
            {
                if (m_eDirection == CCScrollViewDirection.Horizontal)
                {
                    SetContentOffset(CCPoint.Zero);
                }
                else
                {
                    SetContentOffset(new CCPoint(0, MinContainerOffset.Y));
                }
                m_eOldDirection = m_eDirection;
            }
        }
Пример #8
0
 public CCTableView()
 {
     m_eOldDirection = CCScrollViewDirection.None;
 }
Пример #9
0
 public CCScrollView()
 {
     m_eDirection = CCScrollViewDirection.Both;
     Init();
 }
Пример #10
0
 public CCScrollView()
 {
     m_eDirection = CCScrollViewDirection.Both;
 }
Пример #11
0
        /**
         * Returns a scroll view object
         *
         * @param size view size
         * @param container parent object
         * @return scroll view object
         */
        public bool InitWithViewSize(CCSize size, CCNode container)
        {
            m_pContainer = container ?? new CCLayer();

            if (base.Init())
            {
                ViewSize = size;

                TouchEnabled = true;
                m_pTouches = new List<CCTouch>();
                m_pDelegate = null;
                m_bBounceable = true;
                m_bClippingToBounds = true;
                //m_pContainer->setContentSize(CCSizeZero);
                m_eDirection = CCScrollViewDirection.Both;
                m_pContainer.Position = new CCPoint(0.0f, 0.0f);
                m_fTouchLength = 0.0f;

                AddChild(m_pContainer);
                m_fMinScale = m_fMaxScale = 1.0f;

                return true;
            }
            return false;
        }
Пример #12
0
        /**
     * Returns a scroll view object
     *
     * @param size view size
     * @param container parent object
     * @return scroll view object
     */

        protected virtual bool InitWithViewSize(CCSize size, CCNode container)
        {
            if (base.Init())
            {
				_container = container;

                if (_container == null)
                {
                    _container = new CCLayer();
                    _container.IgnoreAnchorPointForPosition = false;
                    _container.AnchorPoint = CCPoint.Zero;
                }

                ViewSize = size;

                TouchEnabled = true;
                _touches = new List<CCTouch>();
                _delegate = null;
                _bounceable = true;
                _clippingToBounds = true;
                _direction = CCScrollViewDirection.Both;
                _container.Position = new CCPoint(0.0f, 0.0f);
                _touchLength = 0.0f;

                AddChild(_container);
                _minScale = _maxScale = 1.0f;

                return true;
            }
            return false;
        }
Пример #13
0
        protected void _updateContentSize()
        {
            CCSize size = CCSize.Zero;
            int cellsCount = m_pDataSource.NumberOfCellsInTableView(this);

            if (cellsCount > 0)
            {
                float maxPosition = m_vCellsPositions[cellsCount];

                switch (Direction)
                {
                    case CCScrollViewDirection.Horizontal:
                        size = new CCSize(maxPosition, m_tViewSize.Height);
                        break;
                    default:
                        size = new CCSize(m_tViewSize.Width, maxPosition);
                        break;
                }
            }

            ContentSize = size;

            if (m_eOldDirection != m_eDirection)
            {
                if (m_eDirection == CCScrollViewDirection.Horizontal)
                {
                    SetContentOffset(CCPoint.Zero);
                }
                else
                {
                    SetContentOffset(new CCPoint(0, MinContainerOffset.Y));
                }
                m_eOldDirection = m_eDirection;
            }
        }
Пример #14
0
        /**
         * reloads data from data source.  the view will be refreshed.
         */
        public void ReloadData()
        {
            m_eOldDirection = CCScrollViewDirection.None;

            foreach (CCTableViewCell cell in m_pCellsUsed)
            {
                if (m_pTableViewDelegate != null)
                {
                    m_pTableViewDelegate.TableCellWillRecycle(this, cell);
                }

                m_pCellsFreed.Add(cell);
                cell.Reset();
                if (cell.Parent == Container)
                {
                    Container.RemoveChild(cell, true);
                }
            }

            m_pIndices.Clear();
            m_pCellsUsed = new CCArrayForObjectSorting();

            _updateCellPositions();
            _updateContentSize();
            if (m_pDataSource.NumberOfCellsInTableView(this) > 0)
            {
                ScrollViewDidScroll(this);
            }
        }