/// <summary> /// Changes the priority of a previously added delegate. /// The lower the number, the higher the priority /// </summary> public void SetPriority(int nPriority, ICCTouchDelegate pDelegate) { CCTouchHandler handler = FindHandler(pDelegate); handler.Priority = nPriority; RearrangeHandlers(m_pTargetedHandlers); RearrangeHandlers(m_pStandardHandlers); }
/// <summary> /// Use this to update the priority of the given delegate when its graph priority /// changes due to a parenting change. /// </summary> /// <param name="d"></param> public void UpdateGraphPriority(ICCTouchDelegate d) { CCTouchHandler h = FindHandler(d); if (h != null) { h.Priority = d.TouchPriority; RearrangeAllHandlersUponTouch(); } }
/// <summary> /// Adds a standard touch delegate to the dispatcher's list. /// See StandardTouchDelegate description. /// IMPORTANT: The delegate will be retained. /// </summary> public void AddStandardDelegate(ICCStandardTouchDelegate pDelegate, int nPriority) { CCTouchHandler pHandler = CCStandardTouchHandler.HandlerWithDelegate(pDelegate, nPriority); if (!m_bLocked) { ForceAddHandler(pHandler, m_pStandardHandlers); } else { m_pHandlersToAdd.Add(pHandler); m_bToAdd = true; } }
/// <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; } }
protected void ForceAddHandler(CCTouchHandler pHandler, List <CCTouchHandler> pArray) { int u = 0; for (int i = 0; i < pArray.Count; i++) { CCTouchHandler h = pArray[i]; if (h != null) { if (h.Priority < pHandler.Priority) { ++u; } if (h.Delegate == pHandler.Delegate) { return; } } } pArray.Insert(u, pHandler); }
/// <summary> /// Used for sort /// </summary> private int Less(CCTouchHandler p1, CCTouchHandler p2) { return(p1.Priority - p2.Priority); }
/// <summary> /// Used for sort /// </summary> private int Less(CCTouchHandler p1, CCTouchHandler p2) { return p1.Priority - p2.Priority; }
protected void ForceAddHandler(CCTouchHandler pHandler, List<CCTouchHandler> pArray) { int u = 0; for (int i = 0; i < pArray.Count; i++) { CCTouchHandler h = pArray[i]; if (h != null) { if (h.Priority < pHandler.Priority) { ++u; } if (h.Delegate == pHandler.Delegate) { return; } } } pArray.Insert(u, pHandler); }
public static CCTouchHandler Create(ICCTouchDelegate pDelegate, int nPriority) { var pHandler = new CCTouchHandler(pDelegate, nPriority); return pHandler; }
public static CCTouchHandler Create(ICCTouchDelegate pDelegate, int nPriority) { var pHandler = new CCTouchHandler(pDelegate, nPriority); return(pHandler); }
/// <summary> /// Used for sorting high to low order of priority /// </summary> private int HighToLow(CCTouchHandler p1, CCTouchHandler p2) { return(p2.Priority - p1.Priority); }
/// <summary> /// Used for sorting low to high order of priority /// </summary> private int LowToHigh(CCTouchHandler p1, CCTouchHandler p2) { return(p1.Priority - p2.Priority); }
/// <summary> /// Used for sorting high to low order of priority /// </summary> private int HighToLow(CCTouchHandler p1, CCTouchHandler p2) { return p2.Priority - p1.Priority; }
/// <summary> /// Used for sorting low to high order of priority /// </summary> private int LowToHigh(CCTouchHandler p1, CCTouchHandler p2) { return p1.Priority - p2.Priority; }