public void Tick() { Initialize(); if (m_ActiveTransitions.Count == 0) { return; } for (int i = 0; i < m_ActiveTransitions.Count; i++) { RouteTransitionState state = m_ActiveTransitions[i].fn(tickElapsed); if (state == RouteTransitionState.Cancelled) { // reset transition state m_ActiveTransitions.Clear(); return; } if (state == RouteTransitionState.Completed) { m_ActiveTransitions.RemoveAt(i--); } } if (m_ActiveTransitions.Count == 0) { EnterRoute(default);
public void RemoveTask(UITask task) { int index = taskStatusPairs.FindIndex(task, (t, item) => item == t.task); if (index != -1) { taskStatusPairs.RemoveAt(index); } }
public T RemoveRecord(long id) { int count = store.Count; T[] array = store.Array; for (int i = 0; i < count; i++) { if (array[i].Id == id) { T retn = array[i]; store.RemoveAt(i); return(retn); } } return(null); }
private void ProcessMouseInput() { // if element does not have state requested -> hover flag, drag listener, pointer events = none, don't add // buckets feel like a lot of overhead // for each element, track if has overflowing children // if it does not and element is culled, skip directly to children's children and repeat // if aabb yMin is below screen height or aabb ymax is less than 0 -> cull // broadphase culling and input querying are related // neither uses render bounds, just obb and aabb // if dragging only attempt intersections with elements who have drag responders // if not dragging only attempt intersections with elements who have hover state (if mouse is present) or drag create or mouse / touch interactions LightList <UIElement> queryResults = (LightList <UIElement>)m_LayoutSystem.QueryPoint(mouseState.mousePosition, LightList <UIElement> .Get()); // todo -- bug! queryResults.Sort((a, b) => { int viewDepthComparison = b.View.Depth - a.View.Depth; if (viewDepthComparison != 0) { return(viewDepthComparison); } if (b.layoutBox.layer != a.layoutBox.layer) { return(b.layoutBox.layer - a.layoutBox.layer); } if (b.layoutBox.zIndex != a.layoutBox.zIndex) { return(b.layoutBox.zIndex - a.layoutBox.zIndex); } return(b.layoutBox.traversalIndex - a.layoutBox.traversalIndex); }); m_AllElementsThisFrame.Clear(); m_AllElementsThisFrame.AddRange(queryResults); if (!IsDragging) { LightList <UIElement> ancestorElements = LightList <UIElement> .Get(); if (queryResults.size > 0) { /* * Every following element must be a parent of the first. * This makes no sense for drag events but a lot for every other. */ UIElement firstElement = queryResults[0]; ancestorElements.Add(firstElement); for (int index = 1; index < queryResults.size; index++) { UIElement element = queryResults[index]; if (IsParentOf(element, firstElement)) { ancestorElements.Add(element); } } LightList <UIElement> .Release(ref queryResults); queryResults = ancestorElements; } } bool didMouseMove = mouseState.DidMove; if (didMouseMove) { for (int i = 0; i < hoveredElements.size; i++) { UIElement element = hoveredElements.array[i]; if ((element.flags & UIElementFlags.EnabledFlagSet) != UIElementFlags.EnabledFlagSet) { hoveredElements.RemoveAt(i--); continue; } if (!queryResults.Contains(element)) { hoveredElements.RemoveAt(i--); element.style.ExitState(StyleState.Hover); } } for (int i = 0; i < queryResults.Count; i++) { UIElement element = queryResults.array[i]; if ((element.style.currentState & StyleState.Hover) == 0) { hoveredElements.Add(element); element.style.EnterState(StyleState.Hover); } } } for (int i = 0; i < queryResults.Count; i++) { UIElement element = queryResults[i]; m_ElementsThisFrame.Add(element); if (!m_ElementsLastFrame.Contains(element)) { m_EnteredElements.Add(element); } if (IsMouseLeftDownThisFrame) { element.style?.EnterState(StyleState.Active); m_ActiveElements.Add(element); } } for (int i = 0; i < m_ElementsLastFrame.Count; i++) { if (!m_ElementsThisFrame.Contains(m_ElementsLastFrame[i])) { m_ExitedElements.Add(m_ElementsLastFrame[i]); } } if (IsMouseLeftUpThisFrame) { for (int i = 0; i < m_ActiveElements.Count; i++) { m_ActiveElements[i].style?.ExitState(StyleState.Active); } m_ActiveElements.Clear(); } if (!IsDragging) { CursorStyle newCursor = null; if (m_ElementsThisFrame.Count > 0) { for (int i = 0; i < m_ElementsThisFrame.Count; i++) { UIElement element = m_ElementsThisFrame[i]; if (element.isDestroyed) { continue; } if (element.style.IsDefined(StylePropertyId.Cursor)) { newCursor = element.style.Cursor; if (!newCursor.Equals(currentCursor)) { Cursor.SetCursor(newCursor.texture, newCursor.hotSpot, CursorMode.Auto); } break; } } } if (currentCursor != null && newCursor == null) { Cursor.SetCursor(null, new Vector2(0, 0), CursorMode.Auto); } currentCursor = newCursor; if (mouseState.AnyMouseDownThisFrame) { m_MouseDownElements.AddRange(m_ElementsThisFrame); } } LightList <UIElement> .Release(ref queryResults); }