public ConnectionPointData AddInputPoint(string label, string type, int max = 1) { var p = new ConnectionPointData(label, type, max, this, true); m_inputPoints.Add(p); return(p); }
public ConnectionPointData AddOutputPoint(string label, string type, int max = 1) { var p = new ConnectionPointData(label, type, max, this, false); m_outputPoints.Add(p); return(p); }
internal virtual string GetConnectType(Model.ConnectionPointData output, Model.ConnectionPointData input) { if (output.Type == input.Type) { return(output.Type); } return(null); }
public NodeEvent(EventType type, NodeGUI node, Vector2 localMousePos, Model.ConnectionPointData point) { this.eventType = type; this.eventSourceNode = node; this.point = point; this.position = localMousePos; this.globalMousePosition = new Vector2(localMousePos.x + node.GetX(), localMousePos.y + node.GetY()); }
public ConnectionPointData(ConnectionPointData p) { this.id = p.id; this.label = p.label; this.parentId = p.parentId; this.isInput = p.isInput; this.buttonRect = p.buttonRect; this.max = p.max; this.type = p.type; }
public ConnectionData(string type, Connection connection, ConnectionPointData output, ConnectionPointData input) { m_id = Guid.NewGuid().ToString(); m_type = type; m_fromNodeId = output.NodeId; m_fromNodeConnectionPointId = output.Id; m_toNodeId = input.NodeId; m_toNodeConnectionPoiontId = input.Id; m_connection = connection; }
//private bool IsValidInputConnectionPoint(Model.ConnectionPointData point) //{ // return m_data.Operation.Object.IsValidInputConnectionPoint(point); //} /** * retrieve mouse events for this node in this GraphEditor window. */ private void HandleNodeMouseEvent() { switch (Event.current.type) { /* * handling release of mouse drag from this node to another node. * this node doesn't know about where the other node is. the master only knows. * only emit event. */ case EventType.Ignore: { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTING_END, this, Event.current.mousePosition, null)); break; } /* * check if the mouse-down point is over one of the connectionPoint in this node. * then emit event. */ case EventType.MouseDown: { Model.ConnectionPointData result = IsOverConnectionPoint(Event.current.mousePosition); if (result != null) { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTING_BEGIN, this, Event.current.mousePosition, result)); break; } else { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_CLICKED, this, Event.current.mousePosition, null)); } break; } } /* * retrieve mouse events for this node in|out of this GraphTool window. */ switch (Event.current.rawType) { case EventType.MouseUp: { bool eventSent = false; // send EVENT_CONNECTION_ESTABLISHED event if MouseUp performed on ConnectionPoint Action <Model.ConnectionPointData> raiseEventIfHit = (Model.ConnectionPointData point) => { // Only one connectionPoint can send NodeEvent. if (eventSent) { return; } //// If InputConnectionPoint is not valid at this moment, ignore //if (!IsValidInputConnectionPoint(point)) //{ // return; //} if (point.Region.Contains(Event.current.mousePosition)) { NodeGUIUtility.NodeEventHandler( new NodeEvent(NodeEvent.EventType.EVENT_CONNECTION_ESTABLISHED, this, Event.current.mousePosition, point)); eventSent = true; return; } if (nodeDataDrawer != null) { nodeDataDrawer.OnClickNodeGUI(this, Event.current.mousePosition, IsOverConnectionPoint(Event.current.mousePosition)); } }; m_data.InputPoints.ForEach(raiseEventIfHit); m_data.OutputPoints.ForEach(raiseEventIfHit); break; } } /* * right click to open Context menu */ if (Event.current.type == EventType.ContextClick || (Event.current.type == EventType.MouseUp && Event.current.button == 1)) { var menu = new GenericMenu(); if (nodeDataDrawer != null) { nodeDataDrawer.OnContextMenuGUI(menu, this); } menu.AddItem( new GUIContent("Delete"), false, () => { NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_DELETE, this, Vector2.zero, null)); } ); menu.ShowAsContext(); Event.current.Use(); } }