Ejemplo n.º 1
0
        internal protected override bool PartialHitTestByContents(ref HitTestArgs args)
        {
            Vector2 localPoint = LocalToWorldTransform.CalcInversed().TransformVector(args.Point);
            Vector2 size       = Size;

            if (size.X < 0)
            {
                localPoint.X = -localPoint.X;
                size.X       = -size.X;
            }
            if (size.Y < 0)
            {
                localPoint.Y = -localPoint.Y;
                size.Y       = -size.Y;
            }
            if (localPoint.X >= 0 && localPoint.Y >= 0 && localPoint.X < size.X && localPoint.Y < size.Y)
            {
                int u = (int)(Texture.ImageSize.Width * (localPoint.X / size.X));
                int v = (int)(Texture.ImageSize.Height * (localPoint.Y / size.Y));
                return(!Texture.IsTransparentPixel(u, v));
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        internal protected override bool PartialHitTest(ref HitTestArgs args)
        {
            switch (ClipChildren)
            {
            case ClipMethod.None:
                return(base.PartialHitTest(ref args));

            case ClipMethod.ScissorTest:
            case ClipMethod.StencilTest:
                if (!(ClipByWidget ?? this).BoundingRectHitTest(args.Point))
                {
                    return(false);
                }
                EnsureRenderChain();
                try {
                    for (var node = FirstChild; node != null; node = node.NextSibling)
                    {
                        node.RenderChainBuilder?.AddToRenderChain(renderChain);
                    }
                    if (renderChain.HitTest(ref args))
                    {
                        return(true);
                    }
                    return(base.PartialHitTest(ref args));
                } finally {
                    renderChain.Clear();
                }

            case ClipMethod.NoRender:
                return(false);

            default:
                throw new InvalidOperationException();
            }
        }
Ejemplo n.º 3
0
        public bool SelfPartialHitTest(Widget widget, ref HitTestArgs args)
        {
            Node targetNode;

            for (targetNode = widget; targetNode != null; targetNode = targetNode.Parent)
            {
                var method = targetNode.AsWidget?.HitTestMethod ?? HitTestMethod.Contents;
                if (method == HitTestMethod.Skip || targetNode != widget && method == HitTestMethod.BoundingRect)
                {
                    return(false);
                }
                if (targetNode.HitTestTarget)
                {
                    break;
                }
            }
            if (targetNode == null)
            {
                return(false);
            }
            if (
                widget.HitTestMethod == HitTestMethod.BoundingRect && widget.BoundingRectHitTest(args.Point) ||
                widget.HitTestMethod == HitTestMethod.Contents && widget.PartialHitTestByContents(ref args)
                )
            {
                args.Node = targetNode;
                return(true);
            }
            return(false);
        }
Ejemplo n.º 4
0
 public bool PartialHitTest(Node node, ref HitTestArgs args)
 {
     foreach (var i in this)
     {
         if (i.PartialHitTest(node, ref args))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 5
0
 internal protected override bool PartialHitTestByContents(ref HitTestArgs args)
 {
     BuildLayout(layout);
     for (int i = 0; i < layout.Length; i++)
     {
         if (PartHitTest(layout[i], args.Point))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 6
0
 internal protected override bool PartialHitTestByContents(ref HitTestArgs args)
 {
     parts = parts ?? new Part[9];
     BuildLayout(parts, (Vector2)Texture.ImageSize, LeftOffset, RightOffset, TopOffset, BottomOffset, Size);
     for (int i = 0; i < parts.Length; i++)
     {
         if (PartHitTest(parts[i], args.Point))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 7
0
        protected internal override bool PartialHitTestByContents(ref HitTestArgs args)
        {
            Vector2 localPoint = LocalToWorldTransform.CalcInversed().TransformVector(args.Point);
            Vector2 size       = Size;

            if (size.X < 0)
            {
                localPoint.X = -localPoint.X;
                size.X       = -size.X;
            }
            if (size.Y < 0)
            {
                localPoint.Y = -localPoint.Y;
                size.Y       = -size.Y;
            }
            for (int i = 0; i < (NumRows + 1) * NumCols; i++)
            {
                if ((i + 1) % (NumCols + 1) == 0)
                {
                    continue;
                }

                var n1     = (DistortionMeshPoint)Nodes[i];
                var n2     = (DistortionMeshPoint)Nodes[i + NumCols + 1];
                var n3     = (DistortionMeshPoint)Nodes[i + NumCols + 2];
                var n4     = (DistortionMeshPoint)Nodes[i + 1];
                var v1     = (n1.TransformedPosition, n1.UV);
                var v2     = (n2.TransformedPosition, n2.UV);
                var v3     = (n3.TransformedPosition, n3.UV);
                var v4     = (n4.TransformedPosition, n4.UV);
                var center = (
                    (v1.TransformedPosition + v2.TransformedPosition + v3.TransformedPosition + v4.TransformedPosition) * .25f,
                    (v1.UV + v2.UV + v3.UV + v4.UV) * .25f
                    );
                if (
                    HitTest(localPoint, v1, center, v2) || HitTest(localPoint, v2, center, v3) ||
                    HitTest(localPoint, v3, center, v4) || HitTest(localPoint, v4, center, v1)
                    )
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 8
0
        internal protected override bool PartialHitTest(ref HitTestArgs args)
        {
            float distance;

            if (!HitTestTarget)
            {
                return(false);
            }
            if (!HitTestBoundingSphere(args.Ray, out distance) || distance > args.Distance)
            {
                return(false);
            }
            if (!HitTestGeometry(args.Ray, out distance) || distance > args.Distance)
            {
                return(false);
            }
            args.Node     = this;
            args.Distance = distance;
            return(true);
        }
Ejemplo n.º 9
0
 public bool HitTest(ref HitTestArgs args)
 {
     for (int i = Layers.Length - 1; i >= 0; i--)
     {
         var list = Layers[i];
         if (list == null || list.Count == 0)
         {
             continue;
         }
         for (int j = 0; j < list.Count; j++)
         {
             var t = list[j];
             if (t.Presenter.PartialHitTest(t.Node, ref args))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 10
0
        private Node LookForNodeUnderMouse(RenderChain renderChain)
        {
#if iOS || ANDROID
            if (!Window.Input.IsTouching(0) && !Window.Input.WasTouchEnded(0))
            {
                return(null);
            }
#endif
            var hitTestArgs = new HitTestArgs(Window.Input.MousePosition);
            renderChain.HitTest(ref hitTestArgs);
            var n = hitTestArgs.Node;
            if (
                n != null &&
                WidgetInput.InputScopeStack.Top != null &&
                !n.SameOrDescendantOf(WidgetInput.InputScopeStack.Top)
                )
            {
                n = null;
            }
            return(n);
        }
Ejemplo n.º 11
0
        public bool PartialHitTest(Node node, ref HitTestArgs args)
        {
            var widget = (Widget)node;

            if (!widget.BoundingRectHitTest(args.Point))
            {
                return(false);
            }
            var savedLayer = renderChain.CurrentLayer;

            try {
                renderChain.CurrentLayer = widget.Layer;
                for (var child = widget.FirstChild; child != null; child = child.NextSibling)
                {
                    child.RenderChainBuilder?.AddToRenderChain(renderChain);
                }
                return(renderChain.HitTest(ref args) || SelfPartialHitTest(widget, ref args));
            } finally {
                renderChain.Clear();
                renderChain.CurrentLayer = savedLayer;
            }
        }
Ejemplo n.º 12
0
            public bool PartialHitTest(Node node, ref HitTestArgs args)
            {
                var splitter = (Splitter)node;

                for (int i = 0; i < splitter.Nodes.Count - 1; i++)
                {
                    var widget    = splitter.Nodes[i + 1].AsWidget;
                    var widgetPos = widget.GlobalPosition;
                    var mousePos  = Window.Current.Input.MousePosition;
                    if (Mathf.Abs(mousePos.Y - (widgetPos.Y - splitter.SeparatorWidth * 0.5f)) < splitter.SeparatorActiveAreaWidth * 0.5f)
                    {
                        if (mousePos.X > widgetPos.X && mousePos.X < widgetPos.X + widget.Width)
                        {
                            SeparatorUnderMouse = i;
                            args.Node           = splitter;
                            return(true);
                        }
                    }
                }
                SeparatorUnderMouse = -1;
                return(false);
            }
Ejemplo n.º 13
0
 internal protected override bool PartialHitTest(ref HitTestArgs args)
 {
     try {
         if (Camera == null)
         {
             return(false);
         }
         args.Ray      = ScreenPointToRay(args.Point);
         args.Distance = float.MaxValue;
         foreach (var node in Nodes)
         {
             node.RenderChainBuilder?.AddToRenderChain(renderChain);
         }
         var layers = renderChain.Layers;
         for (var i = layers.Length - 1; i >= 0; i--)
         {
             var list = layers[i];
             if (list == null || list.Count == 0)
             {
                 continue;
             }
             var hit = false;
             for (var j = 0; j < list.Count; j++)
             {
                 var t = list[j];
                 hit |= t.Presenter.PartialHitTest(t.Node, ref args);
             }
             if (hit)
             {
                 return(true);
             }
         }
         return(false);
     } finally {
         renderChain.Clear();
     }
 }
Ejemplo n.º 14
0
 protected override bool InternalPartialHitTest(T node, ref HitTestArgs args)
 {
     return(partialHitTest != null && partialHitTest(node, ref args));
 }
Ejemplo n.º 15
0
 public override bool PartialHitTest(Node node, ref HitTestArgs args)
 {
     return(hitTest != null && hitTest((T)node, ref args));
 }
Ejemplo n.º 16
0
 internal protected virtual bool PartialHitTest(ref HitTestArgs args)
 {
     return(false);
 }
Ejemplo n.º 17
0
 public bool PartialHitTest(Node node, ref HitTestArgs args) => false;
Ejemplo n.º 18
0
 public bool PartialHitTest(Node node, ref HitTestArgs args)
 {
     return(node.PartialHitTest(ref args));
 }
Ejemplo n.º 19
0
 public bool PartialHitTest(Node node, ref HitTestArgs args) => node.PartialHitTest(ref args);
Ejemplo n.º 20
0
 public virtual bool PartialHitTest(Node node, ref HitTestArgs args)
 {
     return(false);
 }
Ejemplo n.º 21
0
 public bool PartialHitTest(Node node, ref HitTestArgs args)
 {
     throw new NotImplementedException();
 }