Esempio n. 1
0
        /// <summary>
        /// allocates a TargetedTouchHandler with a delegate, a priority and whether or not it swallows touches or not
        /// </summary>
        public static CCTargetedTouchHandler handlerWithDelegate(ICCTargetedTouchDelegate pDelegate, int nPriority, bool bSwallow)
        {
            CCTargetedTouchHandler pHandler = new CCTargetedTouchHandler();

            pHandler.initWithDelegate(pDelegate, nPriority, bSwallow);
            return(pHandler);
        }
 public bool initWithDelegate(ICCTargetedTouchDelegate pDelegate, int nPriority, bool bSwallow)
 {
     if (!base.initWithDelegate(pDelegate, nPriority))
     {
         return(false);
     }
     this.m_pClaimedTouches  = new List <CCTouch>();
     this.m_bSwallowsTouches = bSwallow;
     return(true);
 }
        /// <summary>
        ///  initializes a TargetedTouchHandler with a delegate, a priority and whether or not it swallows touches or not
        /// </summary>
        public bool initWithDelegate(ICCTargetedTouchDelegate pDelegate, int nPriority, bool bSwallow)
        {
            if (base.initWithDelegate(pDelegate, nPriority))
            {
                m_pClaimedTouches = new List<CCTouch>();
                m_bSwallowsTouches = bSwallow;

                return true;
            }

            return false;
        }
Esempio n. 4
0
        /// <summary>
        ///  initializes a TargetedTouchHandler with a delegate, a priority and whether or not it swallows touches or not
        /// </summary>
        public bool InitWithDelegate(ICCTargetedTouchDelegate pDelegate, int nPriority, bool bSwallow)
        {
            if (base.InitWithDelegate(pDelegate, nPriority))
            {
                m_pClaimedTouches  = new List <CCTouch>();
                m_bConsumesTouches = bSwallow;

                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        public void addTargetedDelegate(ICCTargetedTouchDelegate pDelegate, int nPriority, bool bSwallowsTouches)
        {
            CCTouchHandler cCTouchHandler = CCTargetedTouchHandler.handlerWithDelegate(pDelegate, nPriority, bSwallowsTouches);

            if (!this.m_bLocked)
            {
                this.forceAddHandler(cCTouchHandler, this.m_pTargetedHandlers);
                return;
            }
            this.m_pHandlersToAdd.Add(cCTouchHandler);
            this.m_bToAdd = true;
        }
Esempio n. 6
0
 /// <summary>
 /// Adds a targeted touch delegate to the dispatcher's list.
 /// See TargetedTouchDelegate description.
 /// IMPORTANT: The delegate will be retained.
 /// </summary>
 public void AddTargetedDelegate(ICCTargetedTouchDelegate pDelegate, int nPriority, bool bSwallowsTouches)
 {
     CCTouchHandler pHandler = CCTargetedTouchHandler.HandlerWithDelegate(pDelegate, nPriority, bSwallowsTouches);
     if (!m_bLocked)
     {
         ForceAddHandler(pHandler, m_pTargetedHandlers);
     }
     else
     {
         m_pHandlersToAdd.Add(pHandler);
         m_bToAdd = true;
     }
 }
Esempio n. 7
0
        /// <summary>
        /// Adds a targeted touch delegate to the dispatcher's list.
        /// See TargetedTouchDelegate description.
        /// IMPORTANT: The delegate will be retained.
        /// </summary>
        public void AddTargetedDelegate(ICCTargetedTouchDelegate pDelegate, int nPriority, bool bSwallowsTouches)
        {
            CCTouchHandler pHandler = CCTargetedTouchHandler.HandlerWithDelegate(pDelegate, nPriority, bSwallowsTouches);

            if (!m_bLocked)
            {
                ForceAddHandler(pHandler, m_pTargetedHandlers);
            }
            else
            {
                m_pHandlersToAdd.Add(pHandler);
                m_bToAdd = true;
            }
        }
Esempio n. 8
0
 public void AddTargetedDelegate(ICCTargetedTouchDelegate pDelegate)
 {
     AddTargetedDelegate(pDelegate, pDelegate.TouchPriority, true);
     m_bRearrangeTargetedHandlersUponTouch = true;
 }
Esempio n. 9
0
 public void AddTargetedDelegate(ICCTargetedTouchDelegate pDelegate, bool bConsumesTouches)
 {
     AddTargetedDelegate(pDelegate, pDelegate.TouchPriority, bConsumesTouches);
     m_bRearrangeTargetedHandlersUponTouch = true;
 }
 /// <summary>
 /// allocates a TargetedTouchHandler with a delegate, a priority and whether or not it swallows touches or not 
 /// </summary>
 public static CCTargetedTouchHandler handlerWithDelegate(ICCTargetedTouchDelegate pDelegate, int nPriority, bool bSwallow)
 {
     CCTargetedTouchHandler pHandler = new CCTargetedTouchHandler();
     pHandler.initWithDelegate(pDelegate, nPriority, bSwallow);
     return pHandler;
 }
Esempio n. 11
0
        public void touches(List <CCTouch> pTouches, CCEvent pEvent, int uIndex)
        {
            List <CCTouch> pMutableTouches;

            m_bLocked = true;

            // optimization to prevent a mutable copy when it is not necessary
            int  uTargetedHandlersCount = m_pTargetedHandlers.Count;
            int  uStandardHandlersCount = m_pStandardHandlers.Count;
            bool bNeedsMutableSet       = (uTargetedHandlersCount > 0 && uStandardHandlersCount > 0);

            if (bNeedsMutableSet)
            {
                CCTouch[] tempArray = pTouches.ToArray();
                pMutableTouches = tempArray.ToList();
            }
            else
            {
                pMutableTouches = pTouches;
            }

            CCTouchType sHelper = (CCTouchType)uIndex;

            // process the target handlers 1st
            if (uTargetedHandlersCount > 0)
            {
                #region CCTargetedTouchHandler

                foreach (CCTouch pTouch in pTouches)
                {
                    foreach (CCTargetedTouchHandler pHandler in m_pTargetedHandlers)
                    {
                        ICCTargetedTouchDelegate pDelegate = (ICCTargetedTouchDelegate)(pHandler.Delegate);

                        bool bClaimed = false;
                        if (sHelper == CCTouchType.CCTOUCHBEGAN)
                        {
                            bClaimed = pDelegate.ccTouchBegan(pTouch, pEvent);

                            if (bClaimed)
                            {
                                pHandler.ClaimedTouches.Add(pTouch);
                            }
                        }
                        else
                        {
                            if (pHandler.ClaimedTouches.Contains(pTouch))
                            {
                                // moved ended cancelled
                                bClaimed = true;

                                switch (sHelper)
                                {
                                case CCTouchType.CCTOUCHMOVED:
                                    pDelegate.ccTouchMoved(pTouch, pEvent);
                                    break;

                                case CCTouchType.CCTOUCHENDED:
                                    pDelegate.ccTouchEnded(pTouch, pEvent);
                                    pHandler.ClaimedTouches.Remove(pTouch);
                                    break;

                                case CCTouchType.CCTOUCHCANCELLED:
                                    pDelegate.ccTouchCancelled(pTouch, pEvent);
                                    pHandler.ClaimedTouches.Remove(pTouch);
                                    break;
                                }
                            }
                        }

                        if (bClaimed && pHandler.IsSwallowsTouches)
                        {
                            if (bNeedsMutableSet)
                            {
                                pMutableTouches.Remove(pTouch);
                            }

                            break;
                        }
                    }
                }

                #endregion
            }

            // process standard handlers 2nd
            if (uStandardHandlersCount > 0 && pMutableTouches.Count > 0)
            {
                #region CCStandardTouchHandler
                foreach (CCStandardTouchHandler pHandler in m_pStandardHandlers)
                {
                    ICCStandardTouchDelegate pDelegate = (ICCStandardTouchDelegate)pHandler.Delegate;
                    switch (sHelper)
                    {
                    case CCTouchType.CCTOUCHBEGAN:
                        pDelegate.ccTouchesBegan(pMutableTouches, pEvent);
                        break;

                    case CCTouchType.CCTOUCHMOVED:
                        pDelegate.ccTouchesMoved(pMutableTouches, pEvent);
                        break;

                    case CCTouchType.CCTOUCHENDED:
                        pDelegate.ccTouchesEnded(pMutableTouches, pEvent);
                        break;

                    case CCTouchType.CCTOUCHCANCELLED:
                        pDelegate.ccTouchesCancelled(pMutableTouches, pEvent);
                        break;
                    }
                }
                #endregion
            }

            if (bNeedsMutableSet)
            {
                pMutableTouches = null;
            }

            //
            // Optimization. To prevent a [handlers copy] which is expensive
            // the add/removes/quit is done after the iterations
            //
            m_bLocked = false;
            if (m_bToRemove)
            {
                m_bToRemove = false;
                for (int i = 0; i < m_pHandlersToRemove.Count; ++i)
                {
                    forceRemoveDelegate((ICCTouchDelegate)m_pHandlersToRemove[i]);
                }
                m_pHandlersToRemove.Clear();
            }

            if (m_bToAdd)
            {
                m_bToAdd = false;
                foreach (CCTouchHandler pHandler in m_pHandlersToAdd)
                {
                    if (pHandler is CCTargetedTouchHandler && pHandler.Delegate is ICCTargetedTouchDelegate)
                    {
                        forceAddHandler(pHandler, m_pTargetedHandlers);
                    }
                    else if (pHandler is CCStandardTouchHandler && pHandler.Delegate is ICCStandardTouchDelegate)
                    {
                        forceAddHandler(pHandler, m_pStandardHandlers);
                    }
                    else
                    {
                        CCLog.Log("ERROR: inconsistent touch handler and delegate found in m_pHandlersToAdd of CCTouchDispatcher");
                    }
                }

                m_pHandlersToAdd.Clear();
            }

            if (m_bToQuit)
            {
                m_bToQuit = false;
                forceRemoveAllDelegates();
            }
        }
Esempio n. 12
0
        public void touches(List <CCTouch> pTouches, CCEvent pEvent, int uIndex)
        {
            List <CCTouch> cCTouches;

            this.m_bLocked = true;
            int  count = this.m_pTargetedHandlers.Count;
            int  num   = this.m_pStandardHandlers.Count;
            bool flag  = (count <= 0 ? false : num > 0);

            cCTouches = (!flag ? pTouches : pTouches.ToArray().ToList <CCTouch>());
            CCTouchType cCTouchType = (CCTouchType)uIndex;

            if (count > 0)
            {
                foreach (CCTouch pTouch in pTouches)
                {
                    foreach (CCTargetedTouchHandler mPTargetedHandler in this.m_pTargetedHandlers)
                    {
                        ICCTargetedTouchDelegate @delegate = (ICCTargetedTouchDelegate)mPTargetedHandler.Delegate;
                        bool flag1 = false;
                        if (cCTouchType == CCTouchType.CCTOUCHBEGAN)
                        {
                            flag1 = @delegate.ccTouchBegan(pTouch, pEvent);
                            if (flag1)
                            {
                                mPTargetedHandler.ClaimedTouches.Add(pTouch);
                            }
                        }
                        else if (mPTargetedHandler.ClaimedTouches.Contains(pTouch))
                        {
                            flag1 = true;
                            switch (cCTouchType)
                            {
                            case CCTouchType.CCTOUCHMOVED:
                            {
                                @delegate.ccTouchMoved(pTouch, pEvent);
                                break;
                            }

                            case CCTouchType.CCTOUCHENDED:
                            {
                                @delegate.ccTouchEnded(pTouch, pEvent);
                                mPTargetedHandler.ClaimedTouches.Remove(pTouch);
                                break;
                            }

                            case CCTouchType.CCTOUCHCANCELLED:
                            {
                                @delegate.ccTouchCancelled(pTouch, pEvent);
                                mPTargetedHandler.ClaimedTouches.Remove(pTouch);
                                break;
                            }
                            }
                        }
                        if (!flag1 || !mPTargetedHandler.IsSwallowsTouches)
                        {
                            continue;
                        }
                        if (!flag)
                        {
                            break;
                        }
                        cCTouches.Remove(pTouch);
                        break;
                    }
                }
            }
            if (num > 0 && cCTouches.Count > 0)
            {
                foreach (CCStandardTouchHandler mPStandardHandler in this.m_pStandardHandlers)
                {
                    ICCStandardTouchDelegate cCStandardTouchDelegate = (ICCStandardTouchDelegate)mPStandardHandler.Delegate;
                    switch (cCTouchType)
                    {
                    case CCTouchType.CCTOUCHBEGAN:
                    {
                        cCStandardTouchDelegate.ccTouchesBegan(cCTouches, pEvent);
                        continue;
                    }

                    case CCTouchType.CCTOUCHMOVED:
                    {
                        cCStandardTouchDelegate.ccTouchesMoved(cCTouches, pEvent);
                        continue;
                    }

                    case CCTouchType.CCTOUCHENDED:
                    {
                        cCStandardTouchDelegate.ccTouchesEnded(cCTouches, pEvent);
                        continue;
                    }

                    case CCTouchType.CCTOUCHCANCELLED:
                    {
                        cCStandardTouchDelegate.ccTouchesCancelled(cCTouches, pEvent);
                        continue;
                    }

                    default:
                    {
                        continue;
                    }
                    }
                }
            }
            if (flag)
            {
                cCTouches = null;
            }
            this.m_bLocked = false;
            if (this.m_bToRemove)
            {
                this.m_bToRemove = false;
                for (int i = 0; i < this.m_pHandlersToRemove.Count; i++)
                {
                    this.forceRemoveDelegate((ICCTouchDelegate)this.m_pHandlersToRemove[i]);
                }
                this.m_pHandlersToRemove.Clear();
            }
            if (this.m_bToAdd)
            {
                this.m_bToAdd = false;
                foreach (CCTouchHandler mPHandlersToAdd in this.m_pHandlersToAdd)
                {
                    if (mPHandlersToAdd is CCTargetedTouchHandler && mPHandlersToAdd.Delegate is ICCTargetedTouchDelegate)
                    {
                        this.forceAddHandler(mPHandlersToAdd, this.m_pTargetedHandlers);
                    }
                    else if (!(mPHandlersToAdd is CCStandardTouchHandler) || !(mPHandlersToAdd.Delegate is ICCStandardTouchDelegate))
                    {
                        CCLog.Log("ERROR: inconsistent touch handler and delegate found in m_pHandlersToAdd of CCTouchDispatcher");
                    }
                    else
                    {
                        this.forceAddHandler(mPHandlersToAdd, this.m_pStandardHandlers);
                    }
                }
                this.m_pHandlersToAdd.Clear();
            }
            if (this.m_bToQuit)
            {
                this.m_bToQuit = false;
                this.forceRemoveAllDelegates();
            }
        }
Esempio n. 13
0
 public CCTargetedTouchHandler(ICCTargetedTouchDelegate pDelegate, int nPriority, bool bSwallow) : base(pDelegate, nPriority)
 {
     m_pClaimedTouches = new List<CCTouch>();
     m_bConsumesTouches = bSwallow;
 }
Esempio n. 14
0
 public CCTargetedTouchHandler(ICCTargetedTouchDelegate pDelegate, int nPriority, bool bSwallow) : base(pDelegate, nPriority)
 {
     m_pClaimedTouches  = new List <CCTouch>();
     m_bConsumesTouches = bSwallow;
 }
Esempio n. 15
0
 public void AddTargetedDelegate(ICCTargetedTouchDelegate pDelegate)
 {
     AddTargetedDelegate(pDelegate, pDelegate.TouchPriority, true);
     m_bRearrangeTargetedHandlersUponTouch = true;
 }
Esempio n. 16
0
 public void AddTargetedDelegate(ICCTargetedTouchDelegate pDelegate, bool bConsumesTouches)
 {
     AddTargetedDelegate(pDelegate, pDelegate.TouchPriority, bConsumesTouches);
     m_bRearrangeTargetedHandlersUponTouch = true;
 }