/// <summary> /// Get touches from the selected source list /// </summary> protected IEnumerable <Touch> GetTouchesFromSource(NotuiElement element, InteractingTouchSource touchsrc = InteractingTouchSource.Touching) { switch (touchsrc) { case InteractingTouchSource.Touching: return(element.Touching.Keys); case InteractingTouchSource.Hitting: return(element.Hitting.Keys); case InteractingTouchSource.Mice: return(element.Mice); default: return(Enumerable.Empty <Touch>()); } }
/// <summary> /// Get all the touches which can act on this behavior /// </summary> /// <param name="element"></param> /// <param name="touchsrc"></param> /// <returns></returns> protected List <Touch> GetBehavingTouches(NotuiElement element, InteractingTouchSource touchsrc = InteractingTouchSource.Touching) { List <Touch> touches; if (UseOnlyWithSpecificChildren == null) { touches = GetTouchesFromSource(element, touchsrc).ToList(); if (UseChildrenInteracting) { AddChildrenTouches(element, touches, touchsrc); } } else { touches = new List <Touch>(); var selectedChildren = UseOnlyWithSpecificChildren(element); foreach (var child in selectedChildren) { touches.AddRange(GetTouchesFromSource(child, touchsrc)); } } return(touches); }
/// <summary> /// Recursive function which adds touches interacting with the children to this behavior /// </summary> /// <param name="element"></param> /// <param name="touches"></param> /// <param name="touchsrc"></param> protected void AddChildrenTouches(NotuiElement element, List <Touch> touches, InteractingTouchSource touchsrc = InteractingTouchSource.Touching) { foreach (var child in element.Children.Values) { touches.AddRange(GetTouchesFromSource(child, touchsrc)); AddChildrenTouches(child, touches, touchsrc); } }