Esempio n. 1
0
        public override void Release()
        {
            s_MemberAccessExpressionPool.Release(this);
            for (int i = 0; i < parts.Count; i++)
            {
                parts[i].Release();
            }

            LightList <ASTNode> .Release(ref parts);
        }
Esempio n. 2
0
        public override void Release()
        {
            for (int i = 0; i < arguments.Count; i++)
            {
                arguments[i].Release();
            }
            LightList <ASTNode> .Release(ref arguments);

            s_IndexExpressionPool.Release(this);
        }
Esempio n. 3
0
        private void RunWriteBindingsAndReleaseList(LightList <UIElement> elementsToUpdate)
        {
            for (int i = 0; i < elementsToUpdate.size; i++)
            {
                LinqBindingNode bindingNode = elementsToUpdate[i].bindingNode;
                bindingNode?.lateBindings?.Invoke(bindingNode.root, bindingNode.element);
            }

            elementsToUpdate.Release();
        }
Esempio n. 4
0
        public override void Release()
        {
            for (int i = 0; i < list.Count; i++)
            {
                list[i].Release();
            }

            LightList <ASTNode> .Release(ref list);

            s_ListInitializerPool.Release(this);
        }
Esempio n. 5
0
        public override void Release()
        {
            for (int i = 0; i < parameters.Count; i++)
            {
                parameters[i].Release();
            }

            LightList <ASTNode> .Release(ref parameters);

            s_InvokeNodePool.Release(this);
        }
Esempio n. 6
0
        private static void ReleaseList(LightList <ASTNode> list)
        {
            if (list == null)
            {
                return;
            }
            for (int i = 0; i < list.Count; i++)
            {
                list[i].Release();
            }

            LightList <ASTNode> .Release(ref list);
        }
Esempio n. 7
0
        private void ResetSharedStyles(LightList <UIStyleGroupContainer> updatedStyles)
        {
            int count = updatedStyles.Count;

            UIStyleGroupContainer[] updatedStyleArray = updatedStyles.array;

            for (int i = 0; i < styleGroupContainers.size; i++)
            {
                if (!updatedStyles.Contains(styleGroupContainers.array[i]))
                {
                    for (int j = 0; j < styleGroupContainers.array[i].groups.Length; j++)
                    {
                        RunCommands(styleGroupContainers.array[i].groups[j].normal.runCommands, false);
                    }
                }
            }

            availableStyles.Clear();
            styleGroupContainers.Clear();
            isInheritedMap = 0;
            propertyMap.Clear();

            styleGroupContainers.EnsureCapacity(updatedStyles.size);

            containedStates    = 0;
            hasAttributeStyles = false;

            LightList <StylePropertyId> toUpdate = LightList <StylePropertyId> .Get();

            if (instanceStyle != null)
            {
                CreateStyleEntry(toUpdate, instanceStyle, instanceStyle.normal, StyleType.Instance, StyleState.Normal, 0);
                CreateStyleEntry(toUpdate, instanceStyle, instanceStyle.hover, StyleType.Instance, StyleState.Hover, 0);
                CreateStyleEntry(toUpdate, instanceStyle, instanceStyle.focused, StyleType.Instance, StyleState.Focused, 0);
                CreateStyleEntry(toUpdate, instanceStyle, instanceStyle.active, StyleType.Instance, StyleState.Active, 0);
            }

            for (int i = 0; i < count; i++)
            {
                CreateStyleGroups(updatedStyleArray[i], toUpdate);
                styleGroupContainers.array[i] = updatedStyleArray[i];
            }

            styleGroupContainers.size = count;

            SortStyles();

            UpdatePropertyMap(toUpdate);

            LightList <StylePropertyId> .Release(ref toUpdate);
        }
Esempio n. 8
0
        public override void Release()
        {
            if (parameters != null)
            {
                for (int i = 0; i < parameters.Count; i++)
                {
                    parameters[i].Release();
                }
            }

            typeLookup.Release();
            LightList <ASTNode> .Release(ref parameters);

            s_NewExpressionNodePool.Release(this);
        }
Esempio n. 9
0
        private bool ParseListExpression(ref LightList <ASTNode> retn, ExpressionTokenType openExpressionToken, ExpressionTokenType closeExpressionToken)
        {
            if (tokenStream.Current != openExpressionToken)
            {
                return(false);
            }

            int range = tokenStream.FindMatchingIndex(openExpressionToken, closeExpressionToken);

            tokenStream.Save();

            if (range == 1)
            {
                tokenStream.Advance(2);
                retn = LightList <ASTNode> .Get();

                return(true);
            }

            if (retn != null)
            {
                LightList <ASTNode> .Release(ref retn);
            }

            retn = LightList <ASTNode> .Get();

            //todo find next comma at same level (meaning not inside [ or ( or <

            ExpressionParser parser = CreateSubParser(range);
            bool             valid  = parser.ParseListExpressionStep(ref retn);

            parser.Release();

            if (!valid)
            {
                tokenStream.Restore();
                ReleaseList(retn);
                return(false);
            }

            return(true);
        }
Esempio n. 10
0
        public void ClearStore()
        {
            if (onRecordRemoved == null)
            {
                recordStore.Clear();
                return;
            }

            LightList <T> records = LightList <T> .Get();

            records.EnsureCapacity(recordStore.Count);
            recordStore.GetAllRecords(records);
            T[] recordsArray = records.Array;
            recordStore.Clear();
            for (int i = 0; i < records.Count; i++)
            {
                onRecordRemoved.Invoke(recordsArray[i]);
            }

            LightList <T> .Release(ref records);
        }
Esempio n. 11
0
        internal void EnterState(StyleState state)
        {
            if (state == StyleState.Normal || (currentState & state) != 0)
            {
                return;
            }

            StyleState oldState = currentState;

            currentState |= state;

            if ((containedStates & state) == 0)
            {
                return;
            }

            LightList <StylePropertyId> toUpdate = LightList <StylePropertyId> .Get();

            IStyleSystem styleSystem = element.application.styleSystem;

            StyleEntry[] styleEntries = availableStyles.Array;
            for (int i = 0; i < availableStyles.Count; i++)
            {
                StyleEntry entry = styleEntries[i];

                // if this is a state we had not been in before, mark it's properties for update
                if ((entry.state & oldState) == 0 && (entry.state & state) != 0)
                {
                    AddMissingProperties(toUpdate, entry.styleRunCommand.style);
                    RunCommands(entry.styleRunCommand.runCommands);
                }
            }

            UpdatePropertyMap(toUpdate);

            LightList <StylePropertyId> .Release(ref toUpdate);
        }
Esempio n. 12
0
        internal void ExitState(StyleState state)
        {
            if (state == StyleState.Normal || (currentState & state) == 0)
            {
                return;
            }

            StyleState oldState = currentState;

            currentState &= ~(state);
            currentState |= StyleState.Normal;

            if ((containedStates & state) == 0)
            {
                return;
            }

            LightList <StylePropertyId> toUpdate = LightList <StylePropertyId> .Get();

            StyleEntry[] styleEntries = availableStyles.Array;
            for (int i = 0; i < availableStyles.Count; i++)
            {
                StyleEntry entry = styleEntries[i];

                // if this a state we were in that is now invalid, mark it's properties for update
                if ((entry.state & oldState) != 0 && (entry.state & state) != 0)
                {
                    AddMissingProperties(toUpdate, entry.styleRunCommand.style);
                    RunCommands(entry.styleRunCommand.runCommands, false);
                }
            }

            UpdatePropertyMap(toUpdate);

            LightList <StylePropertyId> .Release(ref toUpdate);
        }
Esempio n. 13
0
        private void AppendSharedStyles(LightList <UIStyleGroupContainer> updatedStyles, int index)
        {
            int count = updatedStyles.Count;

            UIStyleGroupContainer[] updatedStyleArray = updatedStyles.Array;

            LightList <StylePropertyId> toUpdate = LightList <StylePropertyId> .Get();

            styleGroupContainers.EnsureAdditionalCapacity(updatedStyles.Count - index);

            for (int i = index; i < count; i++)
            {
                CreateStyleGroups(updatedStyleArray[i], toUpdate);
                styleGroupContainers.array[i] = updatedStyleArray[i];
            }

            styleGroupContainers.size = count;

            SortStyles();

            UpdatePropertyMap(toUpdate);

            LightList <StylePropertyId> .Release(ref toUpdate);
        }
Esempio n. 14
0
        // something.someValue
        // something[i]
        // something(*).x(*).y
        private bool ParseAccessExpression(ref ASTNode retn)
        {
            if (tokenStream.Current != ExpressionTokenType.Identifier)
            {
                return(false);
            }

            string identifier = tokenStream.Current.value;

            tokenStream.Save();
            LightList <ASTNode> parts = LightList <ASTNode> .Get();

            tokenStream.Advance();
            while (tokenStream.HasMoreTokens)
            {
                if (tokenStream.Current == ExpressionTokenType.Dot || tokenStream.Current == ExpressionTokenType.Elvis)
                {
                    if (tokenStream.Next != ExpressionTokenType.Identifier)
                    {
                        break;
                    }

                    tokenStream.Advance();
                    parts.Add(ASTNode.DotAccessNode(tokenStream.Current.value, tokenStream.Previous == ExpressionTokenType.Elvis));
                    tokenStream.Advance();
                    if (tokenStream.HasMoreTokens)
                    {
                        continue;
                    }
                }
                else if (tokenStream.Current == ExpressionTokenType.ArrayAccessOpen || tokenStream.Current == ExpressionTokenType.QuestionMark && tokenStream.NextTokenIs(ExpressionTokenType.ArrayAccessOpen))
                {
                    bool isElvis = false;
                    if (tokenStream.Current == ExpressionTokenType.QuestionMark)
                    {
                        isElvis = true;
                        tokenStream.Advance();
                    }

                    int advance = tokenStream.FindMatchingIndex(ExpressionTokenType.ArrayAccessOpen, ExpressionTokenType.ArrayAccessClose);
                    if (advance == -1)
                    {
                        Abort("Unmatched array bracket");
                    }

                    ExpressionParser subParser = CreateSubParser(advance);
                    parts.Add(ASTNode.IndexExpressionNode(subParser.ParseLoop(), isElvis));
                    subParser.Release();
                    if (tokenStream.HasMoreTokens)
                    {
                        continue;
                    }
                }
                else if (tokenStream.Current == ExpressionTokenType.ParenOpen)
                {
                    LightList <ASTNode> parameters = null;

                    if (!ParseListExpression(ref parameters, ExpressionTokenType.ParenOpen, ExpressionTokenType.ParenClose))
                    {
                        Abort();
                    }

                    parts.Add(ASTNode.InvokeNode(parameters));
                    if (tokenStream.HasMoreTokens)
                    {
                        continue;
                    }
                }

                else if (tokenStream.Current == ExpressionTokenType.LessThan)
                {
                    // shortcut the << operator since we can't have a << in a generic type node. List<<string>> is invalid for example
                    if (tokenStream.HasMoreTokens && tokenStream.Next == ExpressionTokenType.LessThan)
                    {
                        tokenStream.Restore();
                        LightList <ASTNode> .Release(ref parts);

                        return(false);
                    }

                    TypeLookup typePath = new TypeLookup();

                    if (!(ParseTypePathGenerics(ref typePath)))
                    {
                        tokenStream.Restore();
                        LightList <ASTNode> .Release(ref parts);

                        return(false);
                    }

                    parts.Add(ASTNode.GenericTypePath(typePath));
                    if (tokenStream.HasMoreTokens)
                    {
                        continue;
                    }
                }

                if (parts.Count == 0)
                {
                    tokenStream.Restore();
                    LightList <ASTNode> .Release(ref parts);

                    return(false);
                }

                retn = ASTNode.MemberAccessExpressionNode(identifier, parts).WithLocation(tokenStream.Peek());
                return(true);
            }

            ReleaseList(parts);
            tokenStream.Restore();
            return(false);
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        // Namespace resolution
        //    if there is only one element with a name then no namespace is needed
        //    if there are multiple elements with a name
        //        namespace is required in order to match the correct one
        //    using declarations can provide implicit namespaces
        public static ProcessedType ResolveTagName(string tagName, string namespacePrefix, IReadOnlyList <string> namespaces)
        {
            FilterAssemblies();

            namespaces = namespaces ?? EmptyNamespaceList;

            if (string.IsNullOrEmpty(namespacePrefix))
            {
                namespacePrefix = null;
            }
            if (string.IsNullOrWhiteSpace(namespacePrefix))
            {
                namespacePrefix = null;
            }

            if (templateTypeMap.TryGetValue(tagName, out TypeList typeList))
            {
                // if this is null we resolve using just the tag name
                if (namespacePrefix == null)
                {
                    // if only one type has this tag name we can safely return it
                    if (typeList.types == null)
                    {
                        return(typeList.mainType.Reference());
                    }

                    // if there are multiple tags with this name, we need to search our namespaces
                    // if only one match is found, we can return it. If multiple are found, throw
                    // and ambiguous reference exception
                    LightList <ProcessedType> resultList = LightList <ProcessedType> .Get();

                    for (int i = 0; i < namespaces.Count; i++)
                    {
                        for (int j = 0; j < typeList.types.Length; j++)
                        {
                            string        namespaceName = namespaces[i];
                            ProcessedType testType      = typeList.types[j];
                            if (namespaceName == testType.namespaceName)
                            {
                                resultList.Add(testType);
                            }
                        }
                    }

                    if (resultList.size == 1)
                    {
                        ProcessedType retn = resultList[0];
                        resultList.Release();
                        return(retn.Reference());
                    }

                    List <string> list = resultList.Select((s) => s.namespaceName).ToList();
                    throw new ParseException("Ambiguous TagName reference: " + tagName + ". References found in namespaces " + StringUtil.ListToString(list, ", "));
                }

                if (typeList.types == null)
                {
                    if (namespacePrefix == typeList.mainType.namespaceName)
                    {
                        return(typeList.mainType.Reference());
                    }
                }
                else
                {
                    // if prefix is not null we can only return a match for that namespace
                    for (int j = 0; j < typeList.types.Length; j++)
                    {
                        ProcessedType testType = typeList.types[j];
                        if (namespacePrefix == testType.namespaceName)
                        {
                            return(testType.Reference());
                        }
                    }
                }

                return(null);
            }

            if (s_GenericMap.TryGetValue(tagName, out ProcessedType processedType))
            {
                return(processedType);
            }

            return(null);
        }
Esempio n. 17
0
        private bool ParseDeclaration(ref ASTNode node)
        {
            AttributeNode             attrNode   = null;
            LightList <AttributeNode> attributes = LightList <AttributeNode> .Get();

            while (ParseAttribute(ref attrNode))
            {
                attributes.Add(attrNode);
                if (tokenStream.Current != ExpressionTokenType.ArrayAccessOpen)
                {
                    break;
                }
            }

            if (attributes.size == 0)
            {
                LightList <AttributeNode> .Release(ref attributes);
            }

            if (tokenStream.Current != ExpressionTokenType.Identifier)
            {
                return(false);
            }

            // modifiers? -> returnType -> name -> signature -> openBrace * closeBrace

            tokenStream.Save();

            bool isStatic = false;

            if (tokenStream.Current == "static")
            {
                isStatic = true;
                tokenStream.Advance();
            }

            ExpressionParser            parser    = new ExpressionParser(tokenStream);
            StructList <LambdaArgument> signature = null;
            TypeLookup typeLookup = default;

            if (!parser.ParseTypePath(ref typeLookup))
            {
                goto fail;
            }

            tokenStream.Set(parser.GetTokenPosition());
            parser.Release(false);

            if (tokenStream.Current != ExpressionTokenType.Identifier)
            {
                goto fail;
            }

            string name = tokenStream.Current.value;

            tokenStream.Advance();

            // if semi colon then we have a field!
            if (tokenStream.Current == ExpressionTokenType.SemiColon)
            {
                tokenStream.Advance();
                node = new FieldNode()
                {
                    name       = name,
                    isStatic   = isStatic,
                    attributes = attributes,
                    typeLookup = typeLookup
                };
                return(true);
            }

            if (tokenStream.Current != ExpressionTokenType.ParenOpen)
            {
                goto fail;
            }

            signature = StructList <LambdaArgument> .Get();

            if (tokenStream.NextTokenIs(ExpressionTokenType.ParenClose))
            {
                tokenStream.Advance(2);
            }
            else
            {
                int matchingIndex = tokenStream.FindMatchingIndex(ExpressionTokenType.ParenOpen, ExpressionTokenType.ParenClose);

                if (matchingIndex == -1)
                {
                    goto fail;
                }

                TokenStream subStream = tokenStream.AdvanceAndReturnSubStream(matchingIndex);
                subStream.Advance();
                tokenStream.Advance();
                if (!ExpressionParser.ParseSignature(subStream, signature))
                {
                    goto fail;
                }

                for (int i = 0; i < signature.size; i++)
                {
                    if (signature.array[i].type == null)
                    {
                        throw new ParseException($"When defining a method you must specify a type for all arguments. Found identifier {signature.array[i].identifier} but no type was given.");
                    }
                }
            }

            if (tokenStream.Current != ExpressionTokenType.ExpressionOpen)
            {
                goto fail;
            }

            BlockNode block = ParseBlock();

            node = new MethodNode()
            {
                body             = block,
                returnTypeLookup = typeLookup,
                attributes       = attributes,
                name             = name,
                isStatic         = isStatic,
                signatureList    = signature != null?signature.ToArray() : s_EmptySignature
            };

            StructList <LambdaArgument> .Release(ref signature);

            parser.Release(false);

            return(true);

fail:
            {
                tokenStream.Restore();
                parser.Release(false);
                typeLookup.Release();
                signature?.Release();
                return(false);
            }
        }
Esempio n. 18
0
        private bool ParseIfStatement(ref ASTNode node)
        {
            if (tokenStream.Current != ExpressionTokenType.If)
            {
                return(false);
            }

            LightList <ElseIfNode> statements = LightList <ElseIfNode> .Get();

            tokenStream.Advance();

            ASTNode condition = null;

            if (!ParseParenExpression(ref condition))
            {
                throw new ParseException("Expected a condition statement wrapped in parentheses but failed.");
            }

            BlockNode thenBlock = ParseBlock();

            if (thenBlock == null)
            {
                throw new ParseException("Expected a block statement following an if statement but failed to parse the block");
            }

            if (tokenStream.Current != ExpressionTokenType.ElseIf && tokenStream.Current != ExpressionTokenType.Else)
            {
                node = new IfStatementNode()
                {
                    // elseIfStatements = statements.ToArray(),
                    condition = condition,
                    thenBlock = thenBlock
                };
                return(true);
            }

            while (tokenStream.Current == ExpressionTokenType.ElseIf)
            {
                tokenStream.Advance();

                ASTNode elseIfCondition = null;

                if (!ParseParenExpression(ref elseIfCondition))
                {
                    throw new ParseException("Expected a condition statement wrapped in parentheses but failed.");
                }

                BlockNode block = ParseBlock();

                if (block == null)
                {
                    throw new ParseException("Expected a block statement following an if statement but failed to parse the block");
                }

                statements.Add(new ElseIfNode()
                {
                    condition = elseIfCondition,
                    thenBlock = block
                });
            }

            BlockNode elseBlock = null;

            if (tokenStream.Current == ExpressionTokenType.Else)
            {
                tokenStream.Advance();
                elseBlock = ParseBlock();

                if (elseBlock == null)
                {
                    throw new ParseException("Expected a block statement following an else statement but failed to parse the block");
                }
            }

            node = new IfStatementNode()
            {
                condition        = condition,
                thenBlock        = thenBlock,
                elseIfStatements = statements.size == 0 ? null : statements.ToArray(),
                elseBlock        = elseBlock
            };

            statements.Release();

            return(true);
        }
Esempio n. 19
0
        private void RunDragEvent(List <UIElement> elements, InputEventType eventType)
        {
            if (currentDragEvent.IsCanceled && eventType != InputEventType.DragCancel)
            {
                return;
            }

            currentDragEvent.CurrentEventType = eventType;
            currentDragEvent.source           = m_EventPropagator;

            m_EventPropagator.Reset(mouseState);

            LightList <Action <DragEvent> > captureList = LightList <Action <DragEvent> > .Get();

            for (int i = 0; i < elements.Count; i++)
            {
                UIElement element = elements[i];

                if (element.isDestroyed || element.isDisabled)
                {
                    continue;
                }

                if (element.inputHandlers == null)
                {
                    continue;
                }

                if ((element.inputHandlers.handledEvents & eventType) == 0)
                {
                    continue;
                }

                for (int j = 0; j < element.inputHandlers.eventHandlers.size; j++)
                {
                    ref InputHandlerGroup.HandlerData handler = ref element.inputHandlers.eventHandlers.array[j];

                    if ((handler.eventType & eventType) == 0)
                    {
                        continue;
                    }

                    Action <DragEvent> castHandler = (Action <DragEvent>)handler.handlerFn;

                    if (handler.eventPhase != EventPhase.Bubble)
                    {
                        captureList.Add(castHandler);
                        continue;
                    }

                    CurrentDragEvent.element = element;
                    castHandler.Invoke(currentDragEvent);

                    if (currentDragEvent.IsCanceled || m_EventPropagator.shouldStopPropagation)
                    {
                        break;
                    }
                }

                if (currentDragEvent.IsCanceled || m_EventPropagator.shouldStopPropagation)
                {
                    captureList.Release();
                    return;
                }
            }
Esempio n. 20
0
        public bool Run(UIElement origin, UIElement element)
        {
            LightList <UIElement> list = LightList <UIElement> .Get();

            int templateId = origin.templateMetaData.id;

            switch (navigationOperator)
            {
            case NavigationOperator.Parent: {
                UIElement ptr = element.parent;

                while (ptr != origin)
                {
                    if (ptr.templateMetaData.id == templateId)
                    {
                        list.Add(ptr);
                        break;
                    }

                    ptr = ptr.parent;
                }

                break;
            }

            case NavigationOperator.Ancestor: {
                UIElement ptr = element.parent;

                while (ptr != origin)
                {
                    if (ptr.templateMetaData.id == templateId)
                    {
                        list.Add(ptr);
                    }

                    ptr = ptr.parent;
                }

                break;
            }

            case NavigationOperator.Sibling:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            ApplyModifiers(origin, list);

            Filter(origin, list);

            if (list.size == 0)
            {
                list.Release();
                return(false);
            }

            if (next == null)
            {
                list.Release();
                return(true);
            }

            for (int i = 0; i < list.size; i++)
            {
                if (!next.Run(origin, list.array[i]))
                {
                    list.Release();
                    return(false);
                }
            }

            list.Release();
            return(true);
        }