/// <summary>
        /// Returns the node at the specified canvas-space position in the specified editor and returns a possible focused knob aswell
        /// </summary>
        public static Node NodeAtPosition(NodeEditorState editorState, Vector2 canvasPos, out NodeKnob focusedKnob)
        {
            focusedKnob = null;
            if (NodeEditorInputSystem.shouldIgnoreInput(editorState))
            {
                return(null);
            }
            NodeCanvas canvas = editorState.canvas;

            for (int nodeCnt = canvas.nodes.Count - 1; nodeCnt >= 0; nodeCnt--)
            {             // Check from top to bottom because of the render order
                Node node = canvas.nodes [nodeCnt];
                if (node.rect.Contains(canvasPos))
                {
                    return(node);
                }
                for (int knobCnt = 0; knobCnt < node.nodeKnobs.Count; knobCnt++)
                {                 // Check if any nodeKnob is focused instead
                    if (node.nodeKnobs[knobCnt].GetCanvasSpaceKnob().Contains(canvasPos))
                    {
                        focusedKnob = node.nodeKnobs[knobCnt];
                        return(node);
                    }
                }
            }
            return(null);
        }
        public static Node NodeAtPosition(NodeEditorState editorState, Vector2 canvasPos, out NodeKnob focusedKnob)
        {
            focusedKnob = null;
            if (NodeEditorInputSystem.shouldIgnoreInput(editorState))
            {
                return(null);
            }
            NodeCanvas canvas = editorState.canvas;

            for (int num = canvas.nodes.Count - 1; num >= 0; num--)
            {
                Node node = canvas.nodes[num];
                if (node.rect.Contains(canvasPos))
                {
                    return(node);
                }
                for (int i = 0; i < node.nodeKnobs.Count; i++)
                {
                    if (node.nodeKnobs[i].GetCanvasSpaceKnob().Contains(canvasPos))
                    {
                        focusedKnob = node.nodeKnobs[i];
                        return(node);
                    }
                }
            }
            return(null);
        }
Beispiel #3
0
 /// <summary>
 /// Gets a NodeGroup under the mouse. If multiple groups are adressed, the group lowest in the pin hierarchy is returned.
 /// </summary>
 private static NodeGroup GroupAtPosition(NodeEditorState state, Vector2 canvasPos)
 {
     if (NodeEditorInputSystem.shouldIgnoreInput(state))
     {
         return(null);
     }
     for (int i = state.canvas.groups.Count - 1; i >= 0; i--)
     {
         NodeGroup group = state.canvas.groups[i];
         if (group.headerRect.Contains(canvasPos) || group.rect.Contains(canvasPos))
         {
             return(group);
         }
     }
     return(null);
 }
        /// <summary>
        /// Gets a NodeGroup under the mouse. If multiple groups are adressed, the smallest is returned.
        /// </summary>
        private static NodeGroup GroupAtPosition(NodeEditorState state, Vector2 canvasPos)
        {
            if (NodeEditorInputSystem.shouldIgnoreInput(state))
            {
                return(null);
            }
            NodeCanvas canvas = state.canvas;

            for (int groupCnt = canvas.groups.Count - 1; groupCnt >= 0; groupCnt--)
            {
                if (canvas.groups [groupCnt].rect.Contains(canvasPos) || canvas.groups [groupCnt].headerRect.Contains(canvasPos))
                {
                    return(canvas.groups [groupCnt]);
                }
            }
            return(null);
        }
Beispiel #5
0
        /// <summary>
        /// Gets a NodeGroup under the mouse that requires input (header or border). If multiple groups are adressed, the group lowest in the pin hierarchy is returned.
        /// 获取鼠标点击的需要执行操作的Group(Header或Border),如果找到了多个group,则只处理第一个group
        /// </summary>
        private static NodeGroup GroupAtPositionInput(NodeEditorState state, Vector2 canvasPos)
        {
            if (NodeEditorInputSystem.shouldIgnoreInput(state))
            {
                return(null);
            }
            for (int i = state.canvas.groups.Count - 1; i >= 0; i--)
            {
                NodeGroup       group = state.canvas.groups[i];
                BorderSelection border;
                if (group.headerRect.Contains(canvasPos) || CheckBorderSelection(state, group.bodyRect, canvasPos, out border))
                {
                    return(group);
                }
            }

            return(null);
        }
Beispiel #6
0
        /// <summary>
        /// Returns the node at the specified canvas-space position in the specified editor and returns a possible focused knob aswell
        /// </summary>
        public static Node NodeAtPosition(NodeEditorState editorState, Vector2 canvasPos, out ConnectionKnob focusedKnob)
        {
            focusedKnob = null;
            if (editorState == null || NodeEditorInputSystem.shouldIgnoreInput(editorState))
            {
                return(null);
            }
            NodeCanvas canvas = editorState.canvas;

            for (int nodeCnt = canvas.nodes.Count - 1; nodeCnt >= 0; nodeCnt--)
            {             // Check from top to bottom because of the render order
                Node node = canvas.nodes [nodeCnt];
                if (node.ClickTest(canvasPos, out focusedKnob))
                {
                    return(node);                    // Node is clicked on
                }
            }
            return(null);
        }