Ejemplo n.º 1
0
        private void ProcessInputsRecursive(IGuiElement component, IRectangle clipRect)
        {
            if (!component.GetVisible())
            {
                return;
            }

            if (component is IGuiElementContainer)
            {
                var container = (IGuiElementContainer)component;
                var children  = container.GetChildren();

                var componenetClipRect = component.GetLayoutProcessingData().ClipRect;
                // merge the two rectangle to get the cut-set
                var resultingClipRect = clipRect.Intersect(componenetClipRect);

                // just go further in the recursion if there is space left in the clip rect
                if (resultingClipRect.Width > 0 && resultingClipRect.Height > 0)
                {
                    // first go down the recursion
                    // But we have to go from the last to the first child. We have to do it, so the top most child (with same parent as its sibblings)
                    // will receive events like Clicked, that are only sent to one gui element.
                    var count = children.Count;
                    for (var i = count - 1; i >= 0; --i)
                    {
                        var child = children[i];
                        ProcessInputsRecursive(child, resultingClipRect);
                    }
                }
                // on the back path check for events
                ProcessComponentInputs(component, clipRect);
            }
            else
            {
                ProcessComponentInputs(component, clipRect);
            }
        }