예제 #1
0
        private static void HandleNodeDragging(NodeEditorInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.editorState;

            if (state.dragNode)
            {
                // If conditions apply, drag the selected node, else disable dragging
                if (state.selectedNodes.Count > 0 && inputInfo.editorState.dragUserID == "node")
                {
                    // Apply new position for the dragged node
                    Vector2 newOffset = state.UpdateDrag("node", inputInfo.inputPos);
                    foreach (var node in state.selectedNodes)
                    {
                        node.position += newOffset;
                    }

                    NodeEditor.RepaintClients();
                }
                else
                {
                    state.dragNode = false;
                }
                Event.current.Use();
            }
        }
        private static void HandleNodeDragging(NodeEditorInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.editorState;

            if (state.dragNode)
            {             // If conditions apply, drag the selected node, else disable dragging
                if (state.selectedNode != null && inputInfo.editorState.dragUserID == "node")
                {         // Apply new position for the dragged node
                    state.UpdateDrag("node", inputInfo.inputPos);
                    if ((state.dragObjectPos - state.dragObjectStart).magnitude > 10)
                    {
                        state.selectedNode.position = state.dragObjectPos;
                    }
                    else
                    {
                        state.selectedNode.position = state.dragObjectStart;
                    }
                    NodeEditor.RepaintClients();
                }
                else
                {
                    state.dragNode = false;
                }
            }
        }
예제 #3
0
        private static void HandleGroupDragging(NodeEditorInputInfo inputInfo)
        {
            NodeEditorState state  = inputInfo.editorState;
            NodeGroup       active = state.activeGroup;

            if (active != null)
            {
                // Handle dragging and resizing of active group
                if (state.dragUserID != "group")
                {
                    state.activeGroup = null;
                    state.resizeGroup = false;
                    return;
                }

                // Update drag operation
                Vector2 dragChange = state.UpdateDrag("group", inputInfo.inputPos);
                Vector2 newSizePos = state.dragObjectPos;
                if (state.resizeGroup)
                {
                    // Resizing -> Apply drag to selected borders while keeping a minimum size
                    // Note: Binary operator and !=0 checks of the flag is enabled, but not necessarily the only flag (in which case you would use ==)
                    Rect r = active.rect;
                    if ((NodeGroup.resizeDir & BorderSelection.Left) != 0)
                    {
                        active.rect.xMin = r.xMax - Math.Max(minGroupSize, r.xMax - newSizePos.x);
                    }
                    else if ((NodeGroup.resizeDir & BorderSelection.Right) != 0)
                    {
                        active.rect.xMax = r.xMin + Math.Max(minGroupSize, newSizePos.x - r.xMin);
                    }

                    if ((NodeGroup.resizeDir & BorderSelection.Top) != 0)
                    {
                        active.rect.yMin = r.yMax - Math.Max(minGroupSize, r.yMax - newSizePos.y);
                    }
                    else if ((NodeGroup.resizeDir & BorderSelection.Bottom) != 0)
                    {
                        active.rect.yMax = r.yMin + Math.Max(minGroupSize, newSizePos.y - r.yMin);
                    }
                }
                else
                {
                    // Dragging -> Apply drag to body and pinned nodes
                    active.rect.position = newSizePos;
                    foreach (Node pinnedNode in active.pinnedNodes)
                    {
                        pinnedNode.position += dragChange;
                    }
                    foreach (NodeGroup pinnedGroup in active.pinnedGroups)
                    {
                        pinnedGroup.rect.position += dragChange;
                    }
                }

                inputInfo.inputEvent.Use();
                NodeEditor.RepaintClients();
            }
        }
예제 #4
0
        private static void HandleWindowPanning(NodeEditorInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.editorState;

            if (state.panWindow)
            {             // Calculate change in panOffset
                if (inputInfo.editorState.dragUserID == "window")
                {
                    state.panOffset += state.UpdateDrag("window", inputInfo.inputPos);
                }
                else
                {
                    state.panWindow = false;
                }
                NodeEditor.RepaintClients();
            }
        }
예제 #5
0
        private static void HandleNodeDragging(NodeEditorInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.editorState;

            if (state.dragNode)
            {             // If conditions apply, drag the selected node, else disable dragging
                if (state.selectedNode != null && GUIUtility.hotControl == 0 && inputInfo.editorState.dragUserID == "node")
                {         // Apply new position for the dragged node
                    state.UpdateDrag("node", inputInfo.inputPos);
                    state.selectedNode.position = state.dragObjectPos;
                    NodeEditor.RepaintClients();
                }
                else
                {
                    state.dragNode = false;
                }
            }
        }