Exemple #1
0
        public void ProcessEvent(ref PWGraphEditorEventInfo editorEvents)
        {
            var  e        = Event.current;
            bool contains = false;

            if (e.type == EventType.ContextClick)
            {
                Debug.Log(e.mousePosition);
            }
            foreach (var anchor in anchors)
            {
                if (anchor.visibility == PWVisibility.Visible && anchor.rect.Contains(e.mousePosition))
                {
                    editorEvents.mouseOverAnchor        = anchor;
                    editorEvents.isMouseOverAnchorFrame = true;
                    if (e.type == EventType.MouseDown && e.button == 0)
                    {
                        editorEvents.isMouseClickOnAnchor = true;
                    }
                    contains = true;
                }
            }

            //clean anchor field if the old anchor was in this anchorField
            if (!contains)
            {
                if (anchors.Contains(editorEvents.mouseOverAnchor))
                {
                    editorEvents.mouseOverAnchor = null;
                }
            }
        }
Exemple #2
0
        public void ProcessAnchorEvents()
        {
            PWGraphEditorEventInfo editorEvents = graphRef.editorEvents;

            oldEventInfos = editorEvents.Clone(oldEventInfos);

            //process events on every anchors:
            foreach (var anchorField in inputAnchorFields)
            {
                anchorField.ProcessEvent(ref editorEvents);
            }
            foreach (var anchorField in outputAnchorFields)
            {
                anchorField.ProcessEvent(ref editorEvents);
            }

            //link anchor event is we release the mouse with a draggingLink.
            if (editorEvents.isMouseOverAnchor)
            {
                if (e.rawType == EventType.MouseUp && editorEvents.isDraggingLink)
                {
                    OnAnchorLinked(editorEvents.mouseOverAnchor);
                }
            }

            if (editorEvents.isDraggingLink)
            {
                if (oldEventInfos.mouseOverAnchor != editorEvents.mouseOverAnchor)
                {
                    if (editorEvents.mouseOverAnchor == null && OnDraggedLinkQuitAnchor != null)
                    {
                        OnDraggedLinkQuitAnchor(oldEventInfos.mouseOverAnchor);
                    }
                    else if (OnDraggedLinkOverAnchor != null)
                    {
                        OnDraggedLinkOverAnchor(editorEvents.mouseOverAnchor);
                    }
                }
            }
        }